becvert / cordova-plugin-zeroconf

Cordova ZeroConf Plugin
MIT License
81 stars 57 forks source link

No error callback in watch #18

Closed ghost closed 7 years ago

ghost commented 7 years ago

Thanks for creating this plugin, i've been looking for it for quite a while! However, i am unable to check if a certain device is present. If the the service is not found, i cannot get an error or timeout event. Can you help me?

zeroconf.watch('_customservice._tcp.local.', function(result) { var action = result.action; var service = result.service; if(!result) { //do something here } if (action == 'added') { console.log('service found', JSON.stringify(service.addresses[0])); } else { console.log('something else'); } });

or

zeroconf.watch('service._tcp', function(succes, error) { // etc. }

or zeroconf.watch('service._tcp') .then, function (data) { //etc } .catch, function(error) { }

Would that be possible?

becvert commented 7 years ago

Next version of the plugin is coming up soon. Success and Failure callbacks included.

But it isn't the purpose of ZeroConf to say if a device is present or not. The plugin just watches for properly advertised services. So there might not be an error at all in your case. A timeout might be used at the application level. That's your responsability and not the plugin's one.

ghost commented 7 years ago

Thanks, yes, i figured that out. I'll close this issue.