mirror of
https://github.com/node-red/node-red-nodes.git
synced 2025-03-01 10:37:43 +00:00
Ensure service is stopped before being created
This commit is contained in:
parent
6f13776646
commit
46a359f691
@ -32,7 +32,7 @@ service discovery capability.
|
||||
|
||||
`msg.payload` contains the service object on both arrival and leaving.
|
||||
|
||||
`msg.state` contains boolean true or false depending if the service has arrived (true) or gone away (false)..
|
||||
`msg.payload.state` contains boolean true or false depending if the service has arrived (true) or gone away (false)..
|
||||
|
||||
Within the `msg.payload` object the most interesting things are:
|
||||
|
||||
|
@ -18,7 +18,7 @@
|
||||
<script type="text/x-red" data-help-name="discovery">
|
||||
<p>Provides a Bonjour / Avahi / Zeroconf discovery node.</p>
|
||||
<p><code>msg.payload</code> contains the service object on both arrival and leaving.</p>
|
||||
<p><code>msg.state</code> contains boolean <i>true</i> or <i>false</i> depending
|
||||
<p><code>msg.payload.state</code> contains boolean <i>true</i> or <i>false</i> depending
|
||||
if the service has arrived (<i>true</i>) or gone away (<i>false</i>).</p>
|
||||
<p>Within the msg.payload object the most interesting things are:
|
||||
<ul><li>msg.payload.name</li>
|
||||
@ -73,7 +73,7 @@
|
||||
|
||||
<script type="text/x-red" data-help-name="announce">
|
||||
<p>Provides a Bonjour / Avahi / Zeroconf announcement node.</p>
|
||||
<p>If <code>msg.payload</code> is 0 - the announcement is stopped. Any other value starts the announcement process.</p>
|
||||
<p>If <code>msg.payload</code> is <code>false</code> - the announcement is stopped. Any other value starts the announcement process.</p>
|
||||
<p>The announcement can be customised by the msg if not configured in the edit panel.</p>
|
||||
<p><ul>
|
||||
<li><code>msg.service</code> - For a full list of official service types see <i><a href="http://www.dns-sd.org/ServiceTypes.html" target="_new">this list</a></i>.</li>
|
||||
|
@ -65,8 +65,8 @@ module.exports = function(RED) {
|
||||
var node = this;
|
||||
|
||||
this.on("input", function(msg) {
|
||||
if ((msg.payload === 0) || (msg.payload === "0")) {
|
||||
node.ad.stop();
|
||||
if (msg.payload == false) {
|
||||
if (node.ad) { node.ad.stop(); }
|
||||
}
|
||||
else {
|
||||
var service = node.service || msg.service;
|
||||
@ -76,6 +76,7 @@ module.exports = function(RED) {
|
||||
options.name = (node.name || msg.name).replace(/\%h/g, os.hostname());
|
||||
}
|
||||
if (node.txt || msg.txtRecord) { options.txtRecord = node.txt || msg.txtRecord }
|
||||
if (node.ad) { node.ad.stop(); }
|
||||
node.ad = mdns.createAdvertisement(service, port, options);
|
||||
node.ad.start();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user