From 0b0005337c5e455a93d5ab2041f59bad7cc7565a Mon Sep 17 00:00:00 2001 From: Dave Conway-Jones Date: Thu, 25 Jan 2018 13:27:47 +0000 Subject: [PATCH] Decrement connected client count rather than show disconnected to close #1577 --- nodes/core/io/22-websocket.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/nodes/core/io/22-websocket.js b/nodes/core/io/22-websocket.js index fe6c9ed96..a210cdcee 100644 --- a/nodes/core/io/22-websocket.js +++ b/nodes/core/io/22-websocket.js @@ -206,7 +206,10 @@ module.exports = function(RED) { // TODO: nls this.serverConfig.on('opened', function(n) { node.status({fill:"green",shape:"dot",text:"connected "+n}); }); this.serverConfig.on('erro', function() { node.status({fill:"red",shape:"ring",text:"error"}); }); - this.serverConfig.on('closed', function() { node.status({fill:"red",shape:"ring",text:"disconnected"}); }); + this.serverConfig.on('closed', function(n) { + if (n > 0) { node.status({fill:"green",shape:"dot",text:"connected "+n}); } + else { node.status({fill:"red",shape:"ring",text:"disconnected"}); } + }); } else { this.error(RED._("websocket.errors.missing-conf")); } @@ -231,7 +234,10 @@ module.exports = function(RED) { // TODO: nls this.serverConfig.on('opened', function(n) { node.status({fill:"green",shape:"dot",text:"connected "+n}); }); this.serverConfig.on('erro', function() { node.status({fill:"red",shape:"ring",text:"error"}); }); - this.serverConfig.on('closed', function() { node.status({fill:"red",shape:"ring",text:"disconnected"}); }); + this.serverConfig.on('closed', function(n) { + if (n > 0) { node.status({fill:"green",shape:"dot",text:"connected "+n}); } + else { node.status({fill:"red",shape:"ring",text:"disconnected"}); } + }); } this.on("input", function(msg) { var payload;