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:
parent
f2dd4ae062
commit
be810be2e2
@ -86,31 +86,31 @@ module.exports = function(RED) {
|
|||||||
var closing = false;
|
var closing = false;
|
||||||
|
|
||||||
node.client = new StompClient(node.host, node.port, node.userid, node.password, '1.0');
|
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() {
|
var doConnect = function() {
|
||||||
node.client.connect(function(sessionId) {
|
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.log('subscribed to: '+node.topic);
|
||||||
node.client.subscribe(node.topic, function(body, headers) {
|
node.client.subscribe(node.topic, function(body, headers) {
|
||||||
msg.payload = JSON.parse(body);
|
msg.payload = JSON.parse(body);
|
||||||
node.send(msg);
|
node.send(msg);
|
||||||
});
|
});
|
||||||
}, function(error) {
|
}, function(error) {
|
||||||
node.status({fill:"grey",shape:"dot",text:"error"},true);
|
node.status({fill:"grey",shape:"dot",text:"error"});
|
||||||
node.warn(error);
|
node.warn(error);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
node.client.on("disconnect", function() {
|
node.client.on("disconnect", function() {
|
||||||
node.status({fill:"red",shape:"ring",text:"disconnected"},true);
|
node.status({fill:"red",shape:"ring",text:"disconnected"});
|
||||||
if (!closing) {
|
if (!closing) {
|
||||||
setTimeout( function () { doConnect(); }, 15000);
|
setTimeout( function () { doConnect(); }, 15000);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
node.client.on("error", function(error) {
|
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);
|
node.log(error);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -146,17 +146,17 @@ module.exports = function(RED) {
|
|||||||
var closing = false;
|
var closing = false;
|
||||||
|
|
||||||
node.client = new StompClient(node.host, node.port, node.userid, node.password, '1.0');
|
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.client.connect( function(sessionId) {
|
||||||
node.status({fill:"green",shape:"dot",text:"connected"},true);
|
node.status({fill:"green",shape:"dot",text:"connected"});
|
||||||
}, function(error) {
|
}, function(error) {
|
||||||
node.status({fill:"grey",shape:"dot",text:"error"},true);
|
node.status({fill:"grey",shape:"dot",text:"error"});
|
||||||
node.warn(error);
|
node.warn(error);
|
||||||
});
|
});
|
||||||
|
|
||||||
node.client.on("disconnect", function() {
|
node.client.on("disconnect", function() {
|
||||||
node.status({fill:"red",shape:"ring",text:"disconnected"},true);
|
node.status({fill:"red",shape:"ring",text:"disconnected"});
|
||||||
if (!closing) {
|
if (!closing) {
|
||||||
setTimeout( function () { node.client.connect(); }, 15000);
|
setTimeout( function () { node.client.connect(); }, 15000);
|
||||||
}
|
}
|
||||||
|
@ -98,7 +98,7 @@ function XmppInNode(n) {
|
|||||||
|
|
||||||
xmpp.on('online', function() {
|
xmpp.on('online', function() {
|
||||||
node.log('connected to '+node.host+":"+node.port);
|
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');
|
//xmpp.setPresence('online', node.nick+' online');
|
||||||
if (node.join) {
|
if (node.join) {
|
||||||
xmpp.join(node.to+'/'+node.nick);
|
xmpp.join(node.to+'/'+node.nick);
|
||||||
@ -133,7 +133,7 @@ function XmppInNode(n) {
|
|||||||
|
|
||||||
xmpp.on('close', function(err) {
|
xmpp.on('close', function(err) {
|
||||||
node.log('connection closed');
|
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) {
|
xmpp.on('subscribe', function(from) {
|
||||||
@ -152,7 +152,7 @@ function XmppInNode(n) {
|
|||||||
});
|
});
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
node.error("Bad xmpp configuration");
|
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) {
|
node.on("close", function(done) {
|
||||||
@ -184,7 +184,7 @@ function XmppOutNode(n) {
|
|||||||
|
|
||||||
xmpp.on('online', function() {
|
xmpp.on('online', function() {
|
||||||
node.log('connected to '+node.host+":"+node.port);
|
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');
|
xmpp.setPresence('online', node.nick+' online');
|
||||||
if (node.join) {
|
if (node.join) {
|
||||||
xmpp.join(node.to+'/'+node.nick);
|
xmpp.join(node.to+'/'+node.nick);
|
||||||
@ -197,7 +197,7 @@ function XmppOutNode(n) {
|
|||||||
|
|
||||||
xmpp.on('close', function(err) {
|
xmpp.on('close', function(err) {
|
||||||
node.log('connection closed');
|
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) {
|
xmpp.on('subscribe', function(from) {
|
||||||
@ -216,7 +216,7 @@ function XmppOutNode(n) {
|
|||||||
});
|
});
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
node.error("Bad xmpp configuration");
|
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) {
|
node.on("input", function(msg) {
|
||||||
|
@ -42,8 +42,8 @@ module.exports = function(RED) {
|
|||||||
msg = { payload:0, topic:"sun", moon:moon };
|
msg = { payload:0, topic:"sun", moon:moon };
|
||||||
if ((e1 > 0) & (e2 < 0)) { msg.payload = 1; }
|
if ((e1 > 0) & (e2 < 0)) { msg.payload = 1; }
|
||||||
if (oldval == null) { oldval = msg.payload; }
|
if (oldval == null) { oldval = msg.payload; }
|
||||||
if (msg.payload == 1) { node.status({fill:"yellow",shape:"dot",text:"day"},true); }
|
if (msg.payload == 1) { node.status({fill:"yellow",shape:"dot",text:"day"}); }
|
||||||
else { node.status({fill:"blue",shape:"dot",text:"night"},true); }
|
else { node.status({fill:"blue",shape:"dot",text:"night"}); }
|
||||||
if (msg.payload != oldval) {
|
if (msg.payload != oldval) {
|
||||||
oldval = msg.payload;
|
oldval = msg.payload;
|
||||||
msg2 = msg;
|
msg2 = msg;
|
||||||
|
Loading…
Reference in New Issue
Block a user