Fix error handling in Websocket broadcast function

Fixes #2182
This commit is contained in:
Nick O'Leary 2019-05-28 11:51:34 +01:00
parent d360f30af6
commit d583c68de5
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9
1 changed files with 12 additions and 9 deletions

View File

@ -194,20 +194,23 @@ module.exports = function(RED) {
}
WebSocketListenerNode.prototype.broadcast = function(data) {
try {
if (this.isServer) {
for (let client in this._clients) {
if (this._clients.hasOwnProperty(client)) {
if (this.isServer) {
for (let client in this._clients) {
if (this._clients.hasOwnProperty(client)) {
try {
this._clients[client].send(data);
} catch(err) {
this.warn(RED._("websocket.errors.send-error")+" "+client+" "+err.toString())
}
}
}
else {
this.server.send(data);
}
}
catch(e) { // swallow any errors
this.warn("ws:"+i+" : "+e);
else {
try {
this.server.send(data);
} catch(err) {
this.warn(RED._("websocket.errors.send-error")+" "+err.toString())
}
}
}