mirror of
https://github.com/node-red/node-red-nodes.git
synced 2025-03-01 10:37:43 +00:00
node-red-node-discovery: Add status information (#383)
This commit is contained in:
parent
8c0c7ee272
commit
22888cd8bd
@ -66,7 +66,7 @@ module.exports = function(RED) {
|
|||||||
|
|
||||||
this.on("input", function(msg) {
|
this.on("input", function(msg) {
|
||||||
if (msg.payload == false) {
|
if (msg.payload == false) {
|
||||||
if (node.ad) { node.ad.stop(); }
|
this.stop();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
var service = node.service || msg.service;
|
var service = node.service || msg.service;
|
||||||
@ -76,9 +76,10 @@ module.exports = function(RED) {
|
|||||||
options.name = (node.name || msg.name).replace(/\%h/g, os.hostname());
|
options.name = (node.name || msg.name).replace(/\%h/g, os.hostname());
|
||||||
}
|
}
|
||||||
if (node.txt || msg.txtRecord) { options.txtRecord = node.txt || msg.txtRecord }
|
if (node.txt || msg.txtRecord) { options.txtRecord = node.txt || msg.txtRecord }
|
||||||
if (node.ad) { node.ad.stop(); }
|
this.stop();
|
||||||
node.ad = mdns.createAdvertisement(service, port, options);
|
node.ad = mdns.createAdvertisement(service, port, options);
|
||||||
node.ad.start();
|
node.ad.start();
|
||||||
|
node.status({fill: "green", shape: "dot"});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -87,9 +88,16 @@ module.exports = function(RED) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
this.on("close", function() {
|
this.on("close", function() {
|
||||||
if (node.ad) { node.ad.stop(); }
|
this.stop();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.stop = function() {
|
||||||
|
if (node.ad) {
|
||||||
|
node.ad.stop();
|
||||||
|
node.status({fill: "red", shape: "ring"});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
RED.nodes.registerType("announce", MdnsAnnNode);
|
RED.nodes.registerType("announce", MdnsAnnNode);
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name" : "node-red-node-discovery",
|
"name" : "node-red-node-discovery",
|
||||||
"version" : "0.0.19",
|
"version" : "0.0.20",
|
||||||
"description" : "A Node-RED node that uses Bonjour / Avahi to discover nearby services.",
|
"description" : "A Node-RED node that uses Bonjour / Avahi to discover nearby services.",
|
||||||
"dependencies" : {
|
"dependencies" : {
|
||||||
"mdns" : "~2.3.3"
|
"mdns" : "~2.3.3"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user