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

tweak node.status to be consistent with latest thinking

stomp, xmpp and suncalc.
This commit is contained in:
Dave C-J 2014-05-31 20:08:15 +01:00
parent f2dd4ae062
commit be810be2e2
3 changed files with 17 additions and 17 deletions

View File

@ -86,31 +86,31 @@ module.exports = function(RED) {
var closing = false;
node.client = new StompClient(node.host, node.port, node.userid, node.password, '1.0');
node.status({fill:"grey",shape:"ring",text:"connecting"},true);
node.status({fill:"grey",shape:"ring",text:"connecting"});
var doConnect = function() {
node.client.connect(function(sessionId) {
node.status({fill:"green",shape:"dot",text:"connected"},true);
node.status({fill:"green",shape:"dot",text:"connected"});
node.log('subscribed to: '+node.topic);
node.client.subscribe(node.topic, function(body, headers) {
msg.payload = JSON.parse(body);
node.send(msg);
});
}, function(error) {
node.status({fill:"grey",shape:"dot",text:"error"},true);
node.status({fill:"grey",shape:"dot",text:"error"});
node.warn(error);
});
}
node.client.on("disconnect", function() {
node.status({fill:"red",shape:"ring",text:"disconnected"},true);
node.status({fill:"red",shape:"ring",text:"disconnected"});
if (!closing) {
setTimeout( function () { doConnect(); }, 15000);
}
});
node.client.on("error", function(error) {
node.status({fill:"grey",shape:"dot",text:"error"},true);
node.status({fill:"grey",shape:"dot",text:"error"});
node.log(error);
});
@ -146,17 +146,17 @@ module.exports = function(RED) {
var closing = false;
node.client = new StompClient(node.host, node.port, node.userid, node.password, '1.0');
node.status({fill:"grey",shape:"ring",text:"connecting"},true);
node.status({fill:"grey",shape:"ring",text:"connecting"});
node.client.connect( function(sessionId) {
node.status({fill:"green",shape:"dot",text:"connected"},true);
node.status({fill:"green",shape:"dot",text:"connected"});
}, function(error) {
node.status({fill:"grey",shape:"dot",text:"error"},true);
node.status({fill:"grey",shape:"dot",text:"error"});
node.warn(error);
});
node.client.on("disconnect", function() {
node.status({fill:"red",shape:"ring",text:"disconnected"},true);
node.status({fill:"red",shape:"ring",text:"disconnected"});
if (!closing) {
setTimeout( function () { node.client.connect(); }, 15000);
}

View File

@ -98,7 +98,7 @@ function XmppInNode(n) {
xmpp.on('online', function() {
node.log('connected to '+node.host+":"+node.port);
node.status({fill:"green",shape:"dot",text:"connected"},true);
node.status({fill:"green",shape:"dot",text:"connected"});
//xmpp.setPresence('online', node.nick+' online');
if (node.join) {
xmpp.join(node.to+'/'+node.nick);
@ -133,7 +133,7 @@ function XmppInNode(n) {
xmpp.on('close', function(err) {
node.log('connection closed');
node.status({fill:"red",shape:"ring",text:"not connected"},true);
node.status({fill:"red",shape:"ring",text:"not connected"});
});
xmpp.on('subscribe', function(from) {
@ -152,7 +152,7 @@ function XmppInNode(n) {
});
} catch(e) {
node.error("Bad xmpp configuration");
node.status({fill:"red",shape:"ring",text:"not connected"},true);
node.status({fill:"red",shape:"ring",text:"not connected"});
}
node.on("close", function(done) {
@ -184,7 +184,7 @@ function XmppOutNode(n) {
xmpp.on('online', function() {
node.log('connected to '+node.host+":"+node.port);
node.status({fill:"green",shape:"dot",text:"connected"},true);
node.status({fill:"green",shape:"dot",text:"connected"});
xmpp.setPresence('online', node.nick+' online');
if (node.join) {
xmpp.join(node.to+'/'+node.nick);
@ -197,7 +197,7 @@ function XmppOutNode(n) {
xmpp.on('close', function(err) {
node.log('connection closed');
node.status({fill:"red",shape:"ring",text:"not connected"},true);
node.status({fill:"red",shape:"ring",text:"not connected"});
});
xmpp.on('subscribe', function(from) {
@ -216,7 +216,7 @@ function XmppOutNode(n) {
});
} catch(e) {
node.error("Bad xmpp configuration");
node.status({fill:"red",shape:"ring",text:"not connected"},true);
node.status({fill:"red",shape:"ring",text:"not connected"});
}
node.on("input", function(msg) {

View File

@ -42,8 +42,8 @@ module.exports = function(RED) {
msg = { payload:0, topic:"sun", moon:moon };
if ((e1 > 0) & (e2 < 0)) { msg.payload = 1; }
if (oldval == null) { oldval = msg.payload; }
if (msg.payload == 1) { node.status({fill:"yellow",shape:"dot",text:"day"},true); }
else { node.status({fill:"blue",shape:"dot",text:"night"},true); }
if (msg.payload == 1) { node.status({fill:"yellow",shape:"dot",text:"day"}); }
else { node.status({fill:"blue",shape:"dot",text:"night"}); }
if (msg.payload != oldval) {
oldval = msg.payload;
msg2 = msg;