mirror of
https://github.com/MercuryWorkshop/adrift.git
synced 2025-05-13 06:10:01 -04:00
fix onerror bugs
This commit is contained in:
parent
feaac8d6c3
commit
358075f84b
3 changed files with 27 additions and 9 deletions
|
@ -71,11 +71,21 @@ export class AdriftBareClient extends Client {
|
|||
let initalCloseHappened = false;
|
||||
ws.addEventListener("close", (e) => {
|
||||
if (!initalCloseHappened) {
|
||||
// we can freely mess with the fake readyState here because there is no
|
||||
// readyStateChange listener for WebSockets
|
||||
onReadyState(WebSocket.CONNECTING);
|
||||
e.stopImmediatePropagation();
|
||||
initalCloseHappened = true;
|
||||
}
|
||||
});
|
||||
let initialErrorHappened = false;
|
||||
ws.addEventListener("error", (e) => {
|
||||
if (!initialErrorHappened) {
|
||||
onReadyState(WebSocket.CONNECTING);
|
||||
e.stopImmediatePropagation();
|
||||
initialErrorHappened = true;
|
||||
}
|
||||
});
|
||||
|
||||
let { send, close } = this.connection.wsconnect(
|
||||
remote,
|
||||
|
@ -95,6 +105,7 @@ export class AdriftBareClient extends Client {
|
|||
);
|
||||
},
|
||||
(message: string) => {
|
||||
console.log({ message });
|
||||
ws.dispatchEvent(new ErrorEvent("error", { message }));
|
||||
}
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue