From cc7f5c10156333acae8cf9d004bb859ba5c58115 Mon Sep 17 00:00:00 2001 From: Divy Srivastava Date: Thu, 30 Mar 2023 21:22:12 +0530 Subject: perf(ext/websocket): special op for sending text data frames (#18507) Similar to #18506 but for Text frames. --- ext/websocket/lib.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'ext/websocket/lib.rs') diff --git a/ext/websocket/lib.rs b/ext/websocket/lib.rs index 4195f39b8..8eac3e350 100644 --- a/ext/websocket/lib.rs +++ b/ext/websocket/lib.rs @@ -402,6 +402,20 @@ pub enum SendValue { Ping, } +#[op] +pub async fn op_ws_send_text( + state: Rc>, + rid: ResourceId, + data: String, +) -> Result<(), AnyError> { + let resource = state + .borrow_mut() + .resource_table + .get::(rid)?; + resource.send(Message::Text(data)).await?; + Ok(()) +} + #[op] pub async fn op_ws_send( state: Rc>, @@ -504,6 +518,7 @@ deno_core::extension!(deno_websocket, op_ws_send, op_ws_close, op_ws_next_event, + op_ws_send_text, ], esm = [ "01_websocket.js", "02_websocketstream.js" ], options = { -- cgit v1.2.3