summaryrefslogtreecommitdiff
path: root/ext/websocket/02_websocketstream.js
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2023-04-25 13:53:06 +0200
committerGitHub <noreply@github.com>2023-04-25 13:53:06 +0200
commit531754c35497568aa2f19179344eb9e205c9a4b3 (patch)
treebd8f843ff60cc311083f1a9851b51c7d271dea59 /ext/websocket/02_websocketstream.js
parent21c888d4dbe2175333cc9d58b227661e2d0185d8 (diff)
refactor(ext/websocket): use specialized ops (#18819)
Instead of relying on `op_ws_send` to send different kinds of messages, use specialized ops everywhere.
Diffstat (limited to 'ext/websocket/02_websocketstream.js')
-rw-r--r--ext/websocket/02_websocketstream.js14
1 files changed, 3 insertions, 11 deletions
diff --git a/ext/websocket/02_websocketstream.js b/ext/websocket/02_websocketstream.js
index 0d01e62ee..f545d7a99 100644
--- a/ext/websocket/02_websocketstream.js
+++ b/ext/websocket/02_websocketstream.js
@@ -207,17 +207,11 @@ class WebSocketStream {
const writable = new WritableStream({
write: async (chunk) => {
if (typeof chunk === "string") {
- await core.opAsync("op_ws_send", this[_rid], {
- kind: "text",
- value: chunk,
- });
+ await core.opAsync2("op_ws_send_text", this[_rid], chunk);
} else if (
ObjectPrototypeIsPrototypeOf(Uint8ArrayPrototype, chunk)
) {
- await core.opAsync("op_ws_send", this[_rid], {
- kind: "binary",
- value: chunk,
- }, chunk);
+ await core.opAsync2("op_ws_send_binary", this[_rid], chunk);
} else {
throw new TypeError(
"A chunk may only be either a string or an Uint8Array",
@@ -265,9 +259,7 @@ class WebSocketStream {
}
case 3: {
/* ping */
- await core.opAsync("op_ws_send", this[_rid], {
- kind: "pong",
- });
+ await core.opAsync("op_ws_send_pong", this[_rid]);
await pull(controller);
break;
}