summaryrefslogtreecommitdiff
path: root/ext/websocket/lib.rs
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2023-04-28 16:48:00 +0200
committerGitHub <noreply@github.com>2023-04-28 16:48:00 +0200
commit142c1ab9fcb6d88f36a8f9f096a59393525da7d0 (patch)
treee5bb04ca271146fcf91a68c87cb8c03bf19c5ac5 /ext/websocket/lib.rs
parent0b296c6378c46c18de7c3838b2a3e1d13eb9bd87 (diff)
fix(ext/websocket): restore op_ws_send_ping (#18891)
Co-authored-by: Divy Srivastava <dj.srivastava23@gmail.com>
Diffstat (limited to 'ext/websocket/lib.rs')
-rw-r--r--ext/websocket/lib.rs15
1 files changed, 15 insertions, 0 deletions
diff --git a/ext/websocket/lib.rs b/ext/websocket/lib.rs
index 9ea341fbb..d2ec14ec3 100644
--- a/ext/websocket/lib.rs
+++ b/ext/websocket/lib.rs
@@ -406,6 +406,20 @@ pub async fn op_ws_send_pong(
resource.write_frame(Frame::pong(vec![])).await
}
+#[op]
+pub async fn op_ws_send_ping(
+ state: Rc<RefCell<OpState>>,
+ rid: ResourceId,
+) -> Result<(), AnyError> {
+ let resource = state
+ .borrow_mut()
+ .resource_table
+ .get::<ServerWebSocket>(rid)?;
+ resource
+ .write_frame(Frame::new(true, OpCode::Ping, None, vec![]))
+ .await
+}
+
#[op(deferred)]
pub async fn op_ws_close(
state: Rc<RefCell<OpState>>,
@@ -499,6 +513,7 @@ deno_core::extension!(deno_websocket,
op_ws_next_event,
op_ws_send_binary,
op_ws_send_text,
+ op_ws_send_ping,
op_ws_send_pong,
op_ws_server_create,
],