diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2020-09-16 22:22:43 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-16 22:22:43 +0200 |
commit | 6c4da0e429eb47dae6a220c5576a39f137615bb8 (patch) | |
tree | a8715428caea00105acc9a10fcd0f356085d3fa7 /cli/rt/27_websocket.js | |
parent | 104aebdfb5d01f7482bacef6d58c2ce16da44334 (diff) |
refactor: remove dispatch_json.js from cli/rt and cli/tsc (#7521)
Instead use Deno.core.jsonOpSync and Deno.core.jsonOpAsync
Diffstat (limited to 'cli/rt/27_websocket.js')
-rw-r--r-- | cli/rt/27_websocket.js | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/cli/rt/27_websocket.js b/cli/rt/27_websocket.js index fdb5333e3..d7fc03169 100644 --- a/cli/rt/27_websocket.js +++ b/cli/rt/27_websocket.js @@ -1,7 +1,7 @@ // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. ((window) => { - const { sendAsync } = window.__bootstrap.dispatchJson; + const core = window.Deno.core; const { close } = window.__bootstrap.resources; const { requiredArguments } = window.__bootstrap.webUtil; const CONNECTING = 0; @@ -47,7 +47,7 @@ ); } - sendAsync("op_ws_create", { + core.jsonOpAsync("op_ws_create", { url: wsURL.href, protocols: protocols.join("; "), }).then((create) => { @@ -57,7 +57,7 @@ this.#protocol = create.protocol; if (this.#readyState === CLOSING) { - sendAsync("op_ws_close", { + core.jsonOpAsync("op_ws_close", { rid: this.#rid, }).then(() => { this.#readyState = CLOSED; @@ -172,7 +172,7 @@ const sendTypedArray = (ta) => { this.#bufferedAmount += ta.size; - sendAsync("op_ws_send", { + core.jsonOpAsync("op_ws_send", { rid: this.#rid, }, ta).then(() => { this.#bufferedAmount -= ta.size; @@ -198,7 +198,7 @@ const encoder = new TextEncoder(); const d = encoder.encode(string); this.#bufferedAmount += d.size; - sendAsync("op_ws_send", { + core.jsonOpAsync("op_ws_send", { rid: this.#rid, text: string, }).then(() => { @@ -228,7 +228,7 @@ } else if (this.#readyState === OPEN) { this.#readyState = CLOSING; - sendAsync("op_ws_close", { + core.jsonOpAsync("op_ws_close", { rid: this.#rid, code, reason, @@ -249,7 +249,10 @@ async #eventLoop() { if (this.#readyState === OPEN) { - const message = await sendAsync("op_ws_next_event", { rid: this.#rid }); + const message = await core.jsonOpAsync( + "op_ws_next_event", + { rid: this.#rid }, + ); if (message.type === "string" || message.type === "binary") { let data; |