diff options
author | Luciano Iam <lucianito@gmail.com> | 2020-04-12 14:51:54 +0200 |
---|---|---|
committer | Robin Gareus <robin@gareus.org> | 2020-04-13 16:29:40 +0200 |
commit | bfcba853366c76940b4cd2ed27bb30e9cfb1a968 (patch) | |
tree | a33425ca101e47c0a047136e9727eb81b564b570 /share | |
parent | 7aca159017a17c19513b63e65eb93d35e22609a2 (diff) |
WebSockets: throw error if trying to send() before open() in MessageChannel
Diffstat (limited to 'share')
-rw-r--r-- | share/web_surfaces/shared/channel.js | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/share/web_surfaces/shared/channel.js b/share/web_surfaces/shared/channel.js index ae02aad8bd..99a80fd354 100644 --- a/share/web_surfaces/shared/channel.js +++ b/share/web_surfaces/shared/channel.js @@ -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 () { |