lib/client: error out on unsupported WebSocket data type
This commit is contained in:
parent
beef13d273
commit
76f097e8a8
1 changed files with 8 additions and 1 deletions
|
@ -26,6 +26,7 @@ const RECONNECT_DELAY_SEC = 10;
|
||||||
// https://www.rfc-editor.org/rfc/rfc6455.html#section-7.4.1
|
// https://www.rfc-editor.org/rfc/rfc6455.html#section-7.4.1
|
||||||
const NORMAL_CLOSURE = 1000;
|
const NORMAL_CLOSURE = 1000;
|
||||||
const GOING_AWAY = 1001;
|
const GOING_AWAY = 1001;
|
||||||
|
const UNSUPPORTED_DATA = 1003;
|
||||||
|
|
||||||
let lastLabel = 0;
|
let lastLabel = 0;
|
||||||
|
|
||||||
|
@ -138,7 +139,7 @@ export default class Client extends EventTarget {
|
||||||
this.setPingInterval(0);
|
this.setPingInterval(0);
|
||||||
|
|
||||||
if (this.ws) {
|
if (this.ws) {
|
||||||
this.ws.close(1000);
|
this.ws.close(NORMAL_CLOSURE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -168,6 +169,12 @@ export default class Client extends EventTarget {
|
||||||
}
|
}
|
||||||
|
|
||||||
handleMessage(event) {
|
handleMessage(event) {
|
||||||
|
if (typeof event.data !== "string") {
|
||||||
|
console.error("Received unsupported data type:", event.data);
|
||||||
|
this.ws.close(UNSUPPORTED_DATA);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
let msg = irc.parseMessage(event.data);
|
let msg = irc.parseMessage(event.data);
|
||||||
console.debug("Received:", msg);
|
console.debug("Received:", msg);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue