1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

clean up status on close for several core nodes.

This commit is contained in:
Dave Conway-Jones 2016-10-10 11:08:06 +01:00
parent 85b1c1fe97
commit 3a8820397b
4 changed files with 22 additions and 9 deletions

View File

@ -222,6 +222,7 @@ module.exports = function(RED) {
while (node.outstandingIntervals.length > 0) { while (node.outstandingIntervals.length > 0) {
clearInterval(node.outstandingIntervals.pop()) clearInterval(node.outstandingIntervals.pop())
} }
this.status({});
}) })
} catch(err) { } catch(err) {
// eg SyntaxError - which v8 doesn't include line number information // eg SyntaxError - which v8 doesn't include line number information

View File

@ -205,6 +205,10 @@ module.exports = function(RED) {
} }
req.end(); req.end();
}); });
this.on("close",function() {
node.status({});
});
} }
RED.nodes.registerType("http request",HTTPRequest,{ RED.nodes.registerType("http request",HTTPRequest,{

View File

@ -52,16 +52,16 @@ module.exports = function(RED) {
if (node.isServer) { delete node._clients[id]; node.emit('closed',Object.keys(node._clients).length); } if (node.isServer) { delete node._clients[id]; node.emit('closed',Object.keys(node._clients).length); }
else { node.emit('closed'); } else { node.emit('closed'); }
if (!node.closing && !node.isServer) { if (!node.closing && !node.isServer) {
node.tout = setTimeout(function(){ startconn(); }, 3000); // try to reconnect every 3 secs... bit fast ? node.tout = setTimeout(function() { startconn(); }, 3000); // try to reconnect every 3 secs... bit fast ?
} }
}); });
socket.on('message',function(data,flags){ socket.on('message',function(data,flags) {
node.handleEvent(id,socket,'message',data,flags); node.handleEvent(id,socket,'message',data,flags);
}); });
socket.on('error', function(err) { socket.on('error', function(err) {
node.emit('erro'); node.emit('erro');
if (!node.closing && !node.isServer) { if (!node.closing && !node.isServer) {
node.tout = setTimeout(function(){ startconn(); }, 3000); // try to reconnect every 3 secs... bit fast ? node.tout = setTimeout(function() { startconn(); }, 3000); // try to reconnect every 3 secs... bit fast ?
} }
}); });
} }
@ -74,8 +74,8 @@ module.exports = function(RED) {
// Listen for 'newListener' events from RED.server // Listen for 'newListener' events from RED.server
node._serverListeners = {}; node._serverListeners = {};
var storeListener = function(/*String*/event,/*function*/listener){ var storeListener = function(/*String*/event,/*function*/listener) {
if(event == "error" || event == "upgrade" || event == "listening"){ if (event == "error" || event == "upgrade" || event == "listening") {
node._serverListeners[event] = listener; node._serverListeners[event] = listener;
} }
} }
@ -143,7 +143,7 @@ module.exports = function(RED) {
}); });
} }
WebSocketListenerNode.prototype.handleEvent = function(id,/*socket*/socket,/*String*/event,/*Object*/data,/*Object*/flags){ WebSocketListenerNode.prototype.handleEvent = function(id,/*socket*/socket,/*String*/event,/*Object*/data,/*Object*/flags) {
var msg; var msg;
if (this.wholemsg) { if (this.wholemsg) {
try { try {
@ -205,11 +205,10 @@ module.exports = function(RED) {
} else { } else {
this.error(RED._("websocket.errors.missing-conf")); this.error(RED._("websocket.errors.missing-conf"));
} }
this.on('close', function() { this.on('close', function() {
node.serverConfig.removeInputNode(node); node.serverConfig.removeInputNode(node);
node.status({});
}); });
} }
RED.nodes.registerType("websocket in",WebSocketInNode); RED.nodes.registerType("websocket in",WebSocketInNode);
@ -244,7 +243,7 @@ module.exports = function(RED) {
if (msg._session && msg._session.type == "websocket") { if (msg._session && msg._session.type == "websocket") {
node.serverConfig.reply(msg._session.id,payload); node.serverConfig.reply(msg._session.id,payload);
} else { } else {
node.serverConfig.broadcast(payload,function(error){ node.serverConfig.broadcast(payload,function(error) {
if (!!error) { if (!!error) {
node.warn(RED._("websocket.errors.send-error")+inspect(error)); node.warn(RED._("websocket.errors.send-error")+inspect(error));
} }
@ -252,6 +251,9 @@ module.exports = function(RED) {
} }
} }
}); });
this.on('close', function() {
node.status({});
});
} }
RED.nodes.registerType("websocket out",WebSocketOutNode); RED.nodes.registerType("websocket out",WebSocketOutNode);
} }

View File

@ -91,6 +91,9 @@ module.exports = function(RED) {
} }
} }
}); });
this.on('close', function() {
node.status({});
});
} }
RED.nodes.registerType("file",FileNode); RED.nodes.registerType("file",FileNode);
@ -127,6 +130,9 @@ module.exports = function(RED) {
}); });
} }
}); });
this.on('close', function() {
node.status({});
});
} }
RED.nodes.registerType("file in",FileInNode); RED.nodes.registerType("file in",FileInNode);
} }