Skip to content

Commit 22888cd

Browse files
natcldceejay
authored andcommitted
node-red-node-discovery: Add status information (#383)
1 parent 8c0c7ee commit 22888cd

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

io/mdns/mdns.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ module.exports = function(RED) {
6666

6767
this.on("input", function(msg) {
6868
if (msg.payload == false) {
69-
if (node.ad) { node.ad.stop(); }
69+
this.stop();
7070
}
7171
else {
7272
var service = node.service || msg.service;
@@ -76,9 +76,10 @@ module.exports = function(RED) {
7676
options.name = (node.name || msg.name).replace(/\%h/g, os.hostname());
7777
}
7878
if (node.txt || msg.txtRecord) { options.txtRecord = node.txt || msg.txtRecord }
79-
if (node.ad) { node.ad.stop(); }
79+
this.stop();
8080
node.ad = mdns.createAdvertisement(service, port, options);
8181
node.ad.start();
82+
node.status({fill: "green", shape: "dot"});
8283
}
8384
});
8485

@@ -87,9 +88,16 @@ module.exports = function(RED) {
8788
});
8889

8990
this.on("close", function() {
90-
if (node.ad) { node.ad.stop(); }
91+
this.stop();
9192
});
9293

94+
this.stop = function() {
95+
if (node.ad) {
96+
node.ad.stop();
97+
node.status({fill: "red", shape: "ring"});
98+
}
99+
}
100+
93101
}
94102
RED.nodes.registerType("announce", MdnsAnnNode);
95103
}

io/mdns/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name" : "node-red-node-discovery",
3-
"version" : "0.0.19",
3+
"version" : "0.0.20",
44
"description" : "A Node-RED node that uses Bonjour / Avahi to discover nearby services.",
55
"dependencies" : {
66
"mdns" : "~2.3.3"

0 commit comments

Comments
 (0)