summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ext/websocket/01_websocket.js5
-rw-r--r--ext/websocket/lib.rs15
2 files changed, 16 insertions, 4 deletions
diff --git a/ext/websocket/01_websocket.js b/ext/websocket/01_websocket.js
index d483608d8..06eb08b60 100644
--- a/ext/websocket/01_websocket.js
+++ b/ext/websocket/01_websocket.js
@@ -301,10 +301,7 @@ class WebSocket extends EventTarget {
const sendTypedArray = (ta) => {
this[_bufferedAmount] += ta.byteLength;
PromisePrototypeThen(
- core.opAsync("op_ws_send", this[_rid], {
- kind: "binary",
- value: ta,
- }),
+ core.opAsync("op_ws_send_binary", this[_rid], ta),
() => {
this[_bufferedAmount] -= ta.byteLength;
},
diff --git a/ext/websocket/lib.rs b/ext/websocket/lib.rs
index 8eac3e350..8d3cb20d2 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_binary(
+ state: Rc<RefCell<OpState>>,
+ rid: ResourceId,
+ data: ZeroCopyBuf,
+) -> Result<(), AnyError> {
+ let resource = state
+ .borrow_mut()
+ .resource_table
+ .get::<WsStreamResource>(rid)?;
+ resource.send(Message::Binary(data.to_vec())).await?;
+ Ok(())
+}
+
+#[op]
pub async fn op_ws_send_text(
state: Rc<RefCell<OpState>>,
rid: ResourceId,
@@ -518,6 +532,7 @@ deno_core::extension!(deno_websocket,
op_ws_send,
op_ws_close,
op_ws_next_event,
+ op_ws_send_binary,
op_ws_send_text,
],
esm = [ "01_websocket.js", "02_websocketstream.js" ],