You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would like to have a raspberry pi with a service announced in a continuous way, in that way an app could detect the service and start operating with it.
I suggest to make it configurable via publish options. Does it make sense?
I think I could implement this feature and I'm open for pull requests, are they welcome?
My proposal would be to pass those parameters via publish opts and then fetch them inside registry.js.
Something like this:
Registry.prototype.publish=function(opts){varservice=newService(opts)service.start=start.bind(service,this)service.stop=stop.bind(service,this)service.start({probe: opts.probe!==false,reannounceFactor: opts.reannounceFactor||REANNOUNCE_FACTOR,reannounceMaxMs: opts.reannounceFactor||REANNOUNCE_MAX_MS})returnservice}functionstart(registry,opts){if(this._activated)returnthis._activated=trueregistry._services.push(this)if(opts.probe){varservice=thisprobe(registry._server.mdns,this,function(exists){if(exists){service.stop()service.emit('error',newError('Service name is already in use on the network'))return}announce(registry._server,service,opts)})}else{announce(registry._server,this,opts)}}functionannounce(server,service,opts){vardelay=1000varpacket=service._records()server.register(packet);(functionbroadcast(){// abort if the service have or is being stopped in the meantimeif(!service._activated||service._destroyed)returnserver.mdns.respond(packet,function(){// This function will optionally be called with an error object. We'll// just silently ignore it and retry as we normally wouldif(!service.published){service._activated=trueservice.published=trueservice.emit('up')}delay=delay*opts.reannounceFactorif(delay<opts.reannounceMaxMs&&!service._destroyed){setTimeout(broadcast,delay).unref()}})})()}
The text was updated successfully, but these errors were encountered:
The current implementation announces each service record on a fixed schedule, but doesn't respond at all to incoming query packets. Rather than alter the schedule to produce unsolicited announcements more regularly, could it work for you to add handlers in registry.js that responded to query events? The RFC describes the approach. Responding to incoming queries would likely reduce latency and increase reliability of service discovery in your setting without increasing traffic caused by unsolicited announcements.
I would like to have a raspberry pi with a service announced in a continuous way, in that way an app could detect the service and start operating with it.
Digging inside
registry.js
I've seen that the delay is autocalculated with fixed constants:REANNOUNCE_FACTOR
andREANNOUNCE_MAX_MS
(https://github.com/watson/bonjour/blob/master/lib/registry.js#L147)I suggest to make it configurable via publish options. Does it make sense?
I think I could implement this feature and I'm open for pull requests, are they welcome?
My proposal would be to pass those parameters via
publish
opts and then fetch them insideregistry.js
.Something like this:
The text was updated successfully, but these errors were encountered: