13
0

WebSockets: throw error if trying to send() before open() in MessageChannel

This commit is contained in:
Luciano Iam 2020-04-12 14:51:54 +02:00 committed by Robin Gareus
parent 7aca159017
commit bfcba85336
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04

View File

@ -61,7 +61,11 @@ export class MessageChannel {
}
send (msg) {
this.socket.send(msg.toJsonText());
if (this.socket) {
this.socket.send(msg.toJsonText());
} else {
throw Error('MessageChannel: cannot call send() before open()');
}
}
closeCallback () {