Cordova ZeroConf Plugin
This plugin allows you to browse and publish ZeroConf/Bonjour/mDNS services from applications developed using PhoneGap/Cordova 3.0 or newer.
This is not a background service. When the cordova view is destroyed/terminated, publish and watch operations are stopped.
Installation
In your application project directory:
cordova plugin add cordova-plugin-zeroconf
Usage
var zeroconf = cordovapluginszeroconf;
For Android, you may want set the following options to speed discovery up:
zeroconfregisterAddressFamily = 'ipv4'; // or 'ipv6' ('any' by default)zeroconfwatchAddressFamily = 'ipv4'; // or 'ipv6' ('any' by default)
getHostname(success, failure)
Returns this device's hostname.
zeroconf;
register(type, domain, name, port, txtRecord, success, failure)
Publishes a new service.
zeroconf;
unregister(type, domain, name, success, failure)
Unregisters a service.
zeroconf;
stop(success, failure)
Unregisters all published services.
zeroconf;
watch(type, domain, success, failure)
Starts watching for services of the specified type.
zeroconf;
unwatch(type, domain, success, failure)
Stops watching for services of the specified type.
zeroconf
close(success, failure)
Closes the service browser and stops watching.
zeroconf
reInit(success, failure)
Re-initializes the entire plugin, which resets the browsers and services. Use this if the WiFi network has changed while the app is running.
zeroconf
Credits
Android
It depends on the JmDNS library
iOS
Implements Apple's Bonjour
Licence
The MIT License