From 6c4da0e429eb47dae6a220c5576a39f137615bb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Wed, 16 Sep 2020 22:22:43 +0200 Subject: refactor: remove dispatch_json.js from cli/rt and cli/tsc (#7521) Instead use Deno.core.jsonOpSync and Deno.core.jsonOpAsync --- cli/rt/27_websocket.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'cli/rt/27_websocket.js') 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; -- cgit v1.2.3