NLS status text in editor not runtime

This commit is contained in:
Nick O'Leary
2015-07-01 23:02:50 +01:00
parent fbccf01933
commit 726069bc4b
5 changed files with 36 additions and 33 deletions

View File

@@ -44,13 +44,13 @@ module.exports = function(RED) {
var end = false;
var setupTcpClient = function() {
node.log(RED._("tcpin.status.connecting",{host:node.host,port:node.port}));
node.status({fill:"grey",shape:"dot",text:RED._("common.status.connecting")});
node.status({fill:"grey",shape:"dot",text:"common.status.connecting"});
var id = (1+Math.random()*4294967295).toString(16);
client = net.connect(node.port, node.host, function() {
buffer = (node.datatype == 'buffer')? new Buffer(0):"";
node.connected = true;
node.log(RED._("tcpin.status.connected",{host:node.host,port:node.port}));
node.status({fill:"green",shape:"dot",text:RED._("common.status.connected")});
node.status({fill:"green",shape:"dot",text:"common.status.connected"});
});
connectionPool[id] = client;
@@ -96,7 +96,7 @@ module.exports = function(RED) {
client.on('close', function() {
delete connectionPool[id];
node.connected = false;
node.status({fill:"red",shape:"ring",text:RED._("common.status.disconnected")});
node.status({fill:"red",shape:"ring",text:"common.status.disconnected"});
if (!node.closing) {
if (end) { // if we were asked to close then try to reconnect once very quick.
end = false;
@@ -229,11 +229,11 @@ module.exports = function(RED) {
var setupTcpClient = function() {
node.log(RED._("tcpin.status.connecting",{host:node.host,port:node.port}));
node.status({fill:"grey",shape:"dot",text:RED._("common.status.connecting")});
node.status({fill:"grey",shape:"dot",text:"common.status.connecting"});
client = net.connect(node.port, node.host, function() {
node.connected = true;
node.log(RED._("tcpin.status.connected",{host:node.host,port:node.port}));
node.status({fill:"green",shape:"dot",text:RED._("common.status.connected")});
node.status({fill:"green",shape:"dot",text:"common.status.connected"});
});
client.on('error', function (err) {
node.log(RED._("tcpin.errors.error",{error:err.toString()}));
@@ -241,7 +241,7 @@ module.exports = function(RED) {
client.on('end', function (err) {
});
client.on('close', function() {
node.status({fill:"red",shape:"ring",text:RED._("common.status.disconnected")});
node.status({fill:"red",shape:"ring",text:"common.status.disconnected"});
node.connected = false;
client.destroy();
if (!node.closing) {
@@ -307,7 +307,7 @@ module.exports = function(RED) {
var remoteDetails = socket.remoteAddress+":"+socket.remotePort;
node.log(RED._("tcpin.status.connection-from",{host:socket.remoteAddress, port:socket.remotePort}));
connectedSockets.push(socket);
node.status({text:connectedSockets.length+" "+RED._("tcpin.status.connections")});
node.status({text:connectedSockets.length+" "+"tcpin.status.connections")});
socket.on('timeout', function() {
node.log(RED._("tcpin.errors.timeout",{port:node.port}));
socket.end();
@@ -315,12 +315,12 @@ module.exports = function(RED) {
socket.on('close',function() {
node.log(RED._("tcpin.status.connection-closed",{host:socket.remoteAddress, port:socket.remotePort}));
connectedSockets.splice(connectedSockets.indexOf(socket),1);
node.status({text:RED._("common.status.connections",{count:connectedSockets.length})});
node.status({text:RED._("tcpin.status.connections",{count:connectedSockets.length})});
});
socket.on('error',function() {
node.log(RED._("tcpin.errors.socket-error",{host:socket.remoteAddress, port:socket.remotePort}));
connectedSockets.splice(connectedSockets.indexOf(socket),1);
node.status({text:RED._("common.status.connections",{count:connectedSockets.length})});
node.status({text:RED._("tcpin.status.connections",{count:connectedSockets.length})});
});
});
@@ -402,7 +402,7 @@ module.exports = function(RED) {
if (host && port) {
client.connect(port, host, function() {
//node.log(RED._("tcpin.errors.client-connected"));
node.status({fill:"green",shape:"dot",text:RED._("common.status.connected")});
node.status({fill:"green",shape:"dot",text:"common.status.connected"});
node.connected = true;
client.write(msg.payload);
});
@@ -477,7 +477,7 @@ module.exports = function(RED) {
client.on('error', function() {
node.error(RED._("tcpin.errors.connect-fail"),msg);
node.status({fill:"red",shape:"ring",text:RED._("common.status.error")});
node.status({fill:"red",shape:"ring",text:"common.status.error"});
if (client) { client.end(); }
});