mirror of
https://github.com/denoland/deno.git
synced 2025-09-26 12:19:12 +00:00
feat(WebSocketStream): rename connection to opened (#20878)
This commit is contained in:
parent
2215a3ea2e
commit
8ba1242a05
5 changed files with 45 additions and 57 deletions
|
@ -82,7 +82,7 @@ const CLOSE_RESPONSE_TIMEOUT = 5000;
|
|||
|
||||
const _rid = Symbol("[[rid]]");
|
||||
const _url = Symbol("[[url]]");
|
||||
const _connection = Symbol("[[connection]]");
|
||||
const _opened = Symbol("[[opened]]");
|
||||
const _closed = Symbol("[[closed]]");
|
||||
const _earlyClose = Symbol("[[earlyClose]]");
|
||||
const _closeSent = Symbol("[[closeSent]]");
|
||||
|
@ -155,7 +155,7 @@ class WebSocketStream {
|
|||
if (options.signal?.aborted) {
|
||||
core.close(cancelRid);
|
||||
const err = options.signal.reason;
|
||||
this[_connection].reject(err);
|
||||
this[_opened].reject(err);
|
||||
this[_closed].reject(err);
|
||||
} else {
|
||||
const abort = () => {
|
||||
|
@ -192,7 +192,7 @@ class WebSocketStream {
|
|||
"Closed while connecting",
|
||||
"NetworkError",
|
||||
);
|
||||
this[_connection].reject(err);
|
||||
this[_opened].reject(err);
|
||||
this[_closed].reject(err);
|
||||
},
|
||||
);
|
||||
|
@ -202,7 +202,7 @@ class WebSocketStream {
|
|||
"Closed while connecting",
|
||||
"NetworkError",
|
||||
);
|
||||
this[_connection].reject(err);
|
||||
this[_opened].reject(err);
|
||||
this[_closed].reject(err);
|
||||
},
|
||||
);
|
||||
|
@ -334,7 +334,7 @@ class WebSocketStream {
|
|||
},
|
||||
});
|
||||
|
||||
this[_connection].resolve({
|
||||
this[_opened].resolve({
|
||||
readable,
|
||||
writable,
|
||||
extensions: create.extensions ?? "",
|
||||
|
@ -349,17 +349,17 @@ class WebSocketStream {
|
|||
} else {
|
||||
core.tryClose(cancelRid);
|
||||
}
|
||||
this[_connection].reject(err);
|
||||
this[_opened].reject(err);
|
||||
this[_closed].reject(err);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
[_connection] = new Deferred();
|
||||
get connection() {
|
||||
[_opened] = new Deferred();
|
||||
get opened() {
|
||||
webidl.assertBranded(this, WebSocketStreamPrototype);
|
||||
return this[_connection].promise;
|
||||
return this[_opened].promise;
|
||||
}
|
||||
|
||||
[_earlyClose] = false;
|
||||
|
@ -405,7 +405,7 @@ class WebSocketStream {
|
|||
code = 1000;
|
||||
}
|
||||
|
||||
if (this[_connection].state === "pending") {
|
||||
if (this[_opened].state === "pending") {
|
||||
this[_earlyClose] = true;
|
||||
} else if (this[_closed].state === "pending") {
|
||||
PromisePrototypeThen(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue