mirror of
https://git.sr.ht/~emersion/gamja
synced 2024-12-04 13:21:21 -05:00
lib/client: catch handleMessage errors
This commit is contained in:
parent
4f927b5536
commit
bc3abbec32
1 changed files with 9 additions and 1 deletions
|
@ -115,7 +115,15 @@ export default class Client extends EventTarget {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.ws.addEventListener("open", this.handleOpen.bind(this));
|
this.ws.addEventListener("open", this.handleOpen.bind(this));
|
||||||
this.ws.addEventListener("message", this.handleMessage.bind(this));
|
|
||||||
|
this.ws.addEventListener("message", (event) => {
|
||||||
|
try {
|
||||||
|
this.handleMessage(event);
|
||||||
|
} catch (err) {
|
||||||
|
this.dispatchEvent(new CustomEvent("error", { detail: err }));
|
||||||
|
this.disconnect();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
this.ws.addEventListener("close", (event) => {
|
this.ws.addEventListener("close", (event) => {
|
||||||
console.log("Connection closed (code: " + event.code + ")");
|
console.log("Connection closed (code: " + event.code + ")");
|
||||||
|
|
Loading…
Reference in a new issue