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) {
clearInterval(node.outstandingIntervals.pop())
}
this.status({});
})
} catch(err) {
// eg SyntaxError - which v8 doesn't include line number information

View File

@ -205,6 +205,10 @@ module.exports = function(RED) {
}
req.end();
});
this.on("close",function() {
node.status({});
});
}
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); }
else { node.emit('closed'); }
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);
});
socket.on('error', function(err) {
node.emit('erro');
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
node._serverListeners = {};
var storeListener = function(/*String*/event,/*function*/listener){
if(event == "error" || event == "upgrade" || event == "listening"){
var storeListener = function(/*String*/event,/*function*/listener) {
if (event == "error" || event == "upgrade" || event == "listening") {
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;
if (this.wholemsg) {
try {
@ -205,11 +205,10 @@ module.exports = function(RED) {
} else {
this.error(RED._("websocket.errors.missing-conf"));
}
this.on('close', function() {
node.serverConfig.removeInputNode(node);
node.status({});
});
}
RED.nodes.registerType("websocket in",WebSocketInNode);
@ -244,7 +243,7 @@ module.exports = function(RED) {
if (msg._session && msg._session.type == "websocket") {
node.serverConfig.reply(msg._session.id,payload);
} else {
node.serverConfig.broadcast(payload,function(error){
node.serverConfig.broadcast(payload,function(error) {
if (!!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);
}

View File

@ -91,6 +91,9 @@ module.exports = function(RED) {
}
}
});
this.on('close', function() {
node.status({});
});
}
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);
}