mirror of
https://codeberg.org/emersion/gamja
synced 2025-03-13 07:48:37 +01:00
lib/client: remove WebSocket error event handler
The error event handler is useless, because the error event is never emitted without a close event, and doesn't give any details about the error.
This commit is contained in:
parent
ed41f08ba4
commit
beef13d273
@ -22,6 +22,11 @@ const permanentCaps = [
|
||||
|
||||
const RECONNECT_DELAY_SEC = 10;
|
||||
|
||||
// WebSocket status codes
|
||||
// https://www.rfc-editor.org/rfc/rfc6455.html#section-7.4.1
|
||||
const NORMAL_CLOSURE = 1000;
|
||||
const GOING_AWAY = 1001;
|
||||
|
||||
let lastLabel = 0;
|
||||
|
||||
export default class Client extends EventTarget {
|
||||
@ -90,6 +95,10 @@ export default class Client extends EventTarget {
|
||||
this.ws.addEventListener("close", (event) => {
|
||||
console.log("Connection closed (code: " + event.code + ")");
|
||||
|
||||
if (event.code !== NORMAL_CLOSURE && event.code !== GOING_AWAY) {
|
||||
this.dispatchEvent(new CustomEvent("error", { detail: "Connection error" }));
|
||||
}
|
||||
|
||||
this.ws = null;
|
||||
this.setStatus(Client.Status.DISCONNECTED);
|
||||
this.nick = null;
|
||||
@ -118,10 +127,6 @@ export default class Client extends EventTarget {
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
this.ws.addEventListener("error", () => {
|
||||
this.dispatchEvent(new CustomEvent("error", { detail: "Connection error" }));
|
||||
});
|
||||
}
|
||||
|
||||
disconnect() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user