mirror of
https://github.com/denoland/deno.git
synced 2025-08-03 10:33:54 +00:00
refactor(ext/websocket): use fastwebsockets client (#18725)
This commit is contained in:
parent
f520284081
commit
1976504c63
7 changed files with 183 additions and 451 deletions
|
@ -317,9 +317,7 @@ class WebSocket extends EventTarget {
|
|||
this[_bufferedAmount] += byteLength;
|
||||
PromisePrototypeThen(
|
||||
core.opAsync2(
|
||||
this[_role] === SERVER
|
||||
? "op_server_ws_send_binary"
|
||||
: "op_ws_send_binary",
|
||||
"op_ws_send_binary",
|
||||
this[_rid],
|
||||
view,
|
||||
),
|
||||
|
@ -357,7 +355,7 @@ class WebSocket extends EventTarget {
|
|||
this[_bufferedAmount] += TypedArrayPrototypeGetByteLength(d);
|
||||
PromisePrototypeThen(
|
||||
core.opAsync2(
|
||||
this[_role] === SERVER ? "op_server_ws_send_text" : "op_ws_send_text",
|
||||
"op_ws_send_text",
|
||||
this[_rid],
|
||||
string,
|
||||
),
|
||||
|
@ -416,7 +414,7 @@ class WebSocket extends EventTarget {
|
|||
|
||||
PromisePrototypeCatch(
|
||||
core.opAsync(
|
||||
this[_role] === SERVER ? "op_server_ws_close" : "op_ws_close",
|
||||
"op_ws_close",
|
||||
this[_rid],
|
||||
code,
|
||||
reason,
|
||||
|
@ -441,7 +439,7 @@ class WebSocket extends EventTarget {
|
|||
async [_eventLoop]() {
|
||||
while (this[_readyState] !== CLOSED) {
|
||||
const { 0: kind, 1: value } = await core.opAsync2(
|
||||
this[_role] === SERVER ? "op_server_ws_next_event" : "op_ws_next_event",
|
||||
"op_ws_next_event",
|
||||
this[_rid],
|
||||
);
|
||||
|
||||
|
@ -508,7 +506,7 @@ class WebSocket extends EventTarget {
|
|||
if (prevState === OPEN) {
|
||||
try {
|
||||
await core.opAsync(
|
||||
this[_role] === SERVER ? "op_server_ws_close" : "op_ws_close",
|
||||
"op_ws_close",
|
||||
this[_rid],
|
||||
code,
|
||||
value,
|
||||
|
@ -537,7 +535,7 @@ class WebSocket extends EventTarget {
|
|||
this[_idleTimeoutTimeout] = setTimeout(async () => {
|
||||
if (this[_readyState] === OPEN) {
|
||||
await core.opAsync(
|
||||
this[_role] === SERVER ? "op_server_ws_send" : "op_ws_send",
|
||||
"op_ws_send",
|
||||
this[_rid],
|
||||
{
|
||||
kind: "ping",
|
||||
|
@ -548,7 +546,7 @@ class WebSocket extends EventTarget {
|
|||
this[_readyState] = CLOSING;
|
||||
const reason = "No response from ping frame.";
|
||||
await core.opAsync(
|
||||
this[_role] === SERVER ? "op_server_ws_close" : "op_ws_close",
|
||||
"op_ws_close",
|
||||
this[_rid],
|
||||
1001,
|
||||
reason,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue