diff --git a/editor/js/ui/tab-info.js b/editor/js/ui/tab-info.js index c054ee244..e1a5fd727 100644 --- a/editor/js/ui/tab-info.js +++ b/editor/js/ui/tab-info.js @@ -213,7 +213,6 @@ RED.sidebar.info = (function() { $(''+RED._("sidebar.info.instances")+""+userCount+'').appendTo(tableBody); } } - $(table).appendTo(nodeSection.content); var infoText = ""; diff --git a/nodes/core/io/31-tcpin.js b/nodes/core/io/31-tcpin.js index 53ea9101c..d12ec9fc5 100644 --- a/nodes/core/io/31-tcpin.js +++ b/nodes/core/io/31-tcpin.js @@ -63,7 +63,7 @@ module.exports = function(RED) { if ((node.datatype) === "utf8" && node.newline !== "") { buffer = buffer+data; var parts = buffer.split(node.newline); - for (var i = 0;i 0) { - var msg = {topic:node.topic, payload:buffer}; + var msg = {topic:node.topic, payload:buffer, ip:socket.remoteAddress, port:socket.remotePort}; msg._session = {type:"tcp",id:id}; node.send(msg); } @@ -209,7 +209,6 @@ module.exports = function(RED) { } }); } - } RED.nodes.registerType("tcp in",TcpIn); @@ -461,6 +460,7 @@ module.exports = function(RED) { clients[connection_id].client.on('data', function(data) { if (node.out === "sit") { // if we are staying connected just send the buffer if (clients[connection_id]) { + if (!clients[connection_id].hasOwnProperty("msg")) { clients[connection_id].msg = {}; } clients[connection_id].msg.payload = data; node.send(RED.util.cloneMessage(clients[connection_id].msg)); } @@ -486,7 +486,7 @@ module.exports = function(RED) { buf.copy(clients[connection_id].msg.payload,0,0,i+1); node.send(clients[connection_id].msg); if (clients[connection_id].client) { - node.status({}); + node.status({}); clients[connection_id].client.destroy(); delete clients[connection_id]; } @@ -507,7 +507,7 @@ module.exports = function(RED) { buf.copy(clients[connection_id].msg.payload,0,0,i); node.send(clients[connection_id].msg); if (clients[connection_id].client) { - node.status({}); + node.status({}); clients[connection_id].client.destroy(); delete clients[connection_id]; } @@ -579,14 +579,16 @@ module.exports = function(RED) { clients[connection_id].client.on('timeout',function() { //console.log("TIMEOUT"); - clients[connection_id].connected = false; - node.status({fill:"grey",shape:"dot",text:"tcpin.errors.connect-timeout"}); - //node.warn(RED._("tcpin.errors.connect-timeout")); - if (clients[connection_id] && clients[connection_id].client) { - clients[connection_id].client.connect(port, host, function() { - clients[connection_id].connected = true; - node.status({fill:"green",shape:"dot",text:"common.status.connected"}); - }); + if (clients[connection_id]) { + clients[connection_id].connected = false; + node.status({fill:"grey",shape:"dot",text:"tcpin.errors.connect-timeout"}); + //node.warn(RED._("tcpin.errors.connect-timeout")); + if (clients[connection_id].client) { + clients[connection_id].client.connect(port, host, function() { + clients[connection_id].connected = true; + node.status({fill:"green",shape:"dot",text:"common.status.connected"}); + }); + } } }); } @@ -600,7 +602,9 @@ module.exports = function(RED) { this.on("close", function(done) { node.done = done; for (var client in clients) { - clients[client].client.destroy(); + if (clients.hasOwnProperty("client")) { + clients[client].client.destroy(); + } } node.status({}); diff --git a/red/runtime/nodes/Node.js b/red/runtime/nodes/Node.js index 9d9f4753d..2615d7e0f 100644 --- a/red/runtime/nodes/Node.js +++ b/red/runtime/nodes/Node.js @@ -65,7 +65,7 @@ Node.prototype.updateWires = function(wires) { } Node.prototype.context = function() { if (!this._context) { - this._context = context.get(this._alias||this.id,this.z); + this._context = context.get(this._alias||this.id,this.z); } return this._context; } diff --git a/red/runtime/nodes/context.js b/red/runtime/nodes/context.js index 794050dc1..965f8c264 100644 --- a/red/runtime/nodes/context.js +++ b/red/runtime/nodes/context.js @@ -47,9 +47,9 @@ function getContext(localId,flowId) { var newContext = createContext(contextId); if (flowId) { newContext.flow = getContext(flowId); - if (globalContext) { - newContext.global = globalContext; - } + } + if (globalContext) { + newContext.global = globalContext; } contexts[contextId] = newContext; return newContext;