mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
parent
712f8b4680
commit
f66886dbdb
@ -48,7 +48,7 @@ module.exports = function(RED) {
|
||||
if (!node.isServer) { node.emit('opened',''); }
|
||||
});
|
||||
socket.on('close',function() {
|
||||
if (node.isServer) { delete node._clients[id]; node.emit('opened',Object.keys(node._clients).length); }
|
||||
if (node.isServer) { delete node._clients[id]; node.emit('closed',Object.keys(node._clients).length); }
|
||||
else { node.emit('closed'); }
|
||||
if (!node.closing && !node.isServer) {
|
||||
node.tout = setTimeout(function(){ startconn(); }, 3000); // try to reconnect every 3 secs... bit fast ?
|
||||
@ -126,6 +126,14 @@ module.exports = function(RED) {
|
||||
this._inputNodes.push(handler);
|
||||
}
|
||||
|
||||
WebSocketListenerNode.prototype.removeInputNode = function(/*Node*/handler) {
|
||||
this._inputNodes.forEach(function(node, i, inputNodes) {
|
||||
if (node === handler) {
|
||||
inputNodes.splice(i, 1);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
WebSocketListenerNode.prototype.handleEvent = function(id,/*socket*/socket,/*String*/event,/*Object*/data,/*Object*/flags){
|
||||
var msg;
|
||||
if (this.wholemsg) {
|
||||
@ -187,6 +195,11 @@ module.exports = function(RED) {
|
||||
} else {
|
||||
this.error(RED._("websocket.errors.missing-conf"));
|
||||
}
|
||||
|
||||
this.on('close', function() {
|
||||
node.serverConfig.removeInputNode(node);
|
||||
});
|
||||
|
||||
}
|
||||
RED.nodes.registerType("websocket in",WebSocketInNode);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user