mirror of
https://codeberg.org/emersion/gamja.git
synced 2024-11-14 19:05:01 -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;
|
||||
}
|
||||
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) => {
|
||||
console.log("Connection closed (code: " + event.code + ")");
|
||||
|
|
Loading…
Reference in a new issue