From 531754c35497568aa2f19179344eb9e205c9a4b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Tue, 25 Apr 2023 13:53:06 +0200 Subject: refactor(ext/websocket): use specialized ops (#18819) Instead of relying on `op_ws_send` to send different kinds of messages, use specialized ops everywhere. --- ext/websocket/02_websocketstream.js | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) (limited to 'ext/websocket/02_websocketstream.js') 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; } -- cgit v1.2.3