fix(runtime/websocket): respond to ping with pong (#8974)

This commit is contained in:
crowlKats 2021-01-05 13:37:02 +01:00 committed by GitHub
parent c823211a2c
commit f85cd54cb4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 3 deletions

View file

@ -167,6 +167,7 @@
this.#bufferedAmount += ta.size;
core.jsonOpAsync("op_ws_send", {
rid: this.#rid,
kind: "binary",
}, ta).then(() => {
this.#bufferedAmount -= ta.size;
});
@ -193,6 +194,7 @@
this.#bufferedAmount += d.size;
core.jsonOpAsync("op_ws_send", {
rid: this.#rid,
kind: "text",
text: string,
}).then(() => {
this.#bufferedAmount -= d.size;
@ -265,6 +267,13 @@
event.target = this;
this.dispatchEvent(event);
this.#eventLoop();
} else if (message.type === "ping") {
core.jsonOpAsync("op_ws_send", {
rid: this.#rid,
kind: "pong",
});
this.#eventLoop();
} else if (message.type === "close") {
this.#readyState = CLOSED;