summaryrefslogtreecommitdiff
path: root/ext/websocket/lib.rs
diff options
context:
space:
mode:
authorDivy Srivastava <dj.srivastava23@gmail.com>2023-03-30 21:22:12 +0530
committerGitHub <noreply@github.com>2023-03-30 17:52:12 +0200
commitcc7f5c10156333acae8cf9d004bb859ba5c58115 (patch)
tree21525b97b6bbed6bcbbdf82d733bcd17ad2d7e33 /ext/websocket/lib.rs
parent3abc53f8119409916776a5ff277a745022b60680 (diff)
perf(ext/websocket): special op for sending text data frames (#18507)
Similar to #18506 but for Text frames.
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 4195f39b8..8eac3e350 100644
--- a/ext/websocket/lib.rs
+++ b/ext/websocket/lib.rs
@@ -403,6 +403,20 @@ pub enum SendValue {
}
#[op]
+pub async fn op_ws_send_text(
+ state: Rc<RefCell<OpState>>,
+ rid: ResourceId,
+ data: String,
+) -> Result<(), AnyError> {
+ let resource = state
+ .borrow_mut()
+ .resource_table
+ .get::<WsStreamResource>(rid)?;
+ resource.send(Message::Text(data)).await?;
+ Ok(())
+}
+
+#[op]
pub async fn op_ws_send(
state: Rc<RefCell<OpState>>,
rid: ResourceId,
@@ -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 = {