This is a wrapper around the jmmdns (multi-homed) part of the jmdns library.
On the surface it does not look as if we need this wrapper since jmdns has quite a nice api, but it turned out to be quite awkward to use. There are some broken api, others that need some black magic, and also the ouput (in ServiceInfo types) is fixed - you can't modify, or merge them to simplify the output list of discovered services.
Currently working with the jmdns guy and merging convenient additions here upstream but its a gradual process that needs alot of testing.
In summary, this is a nice, simple api for publishing services and doing service discovery (either via polling or via callback).
Definition at line 57 of file Zeroconf.java.
Definition at line 70 of file Zeroconf.java.
com.github.rosjava.zeroconf_jmdns_suite.jmdns.Zeroconf.Zeroconf | ( | ZeroconfLogger | logger | ) | [inline] |
Definition at line 88 of file Zeroconf.java.
void com.github.rosjava.zeroconf_jmdns_suite.jmdns.Zeroconf.addListener | ( | String | service_type, |
String | domain | ||
) | [inline] |
Definition at line 112 of file Zeroconf.java.
void com.github.rosjava.zeroconf_jmdns_suite.jmdns.Zeroconf.addListener | ( | String | service_type, |
String | domain, | ||
ZeroconfDiscoveryHandler | listener_callback | ||
) | [inline] |
If you call this early in your program, the jmmdns.addServiceListener will often do nothing as it hasn't discovered the interfaces yet. In this case, we save the listener data (listeners.add(service) and add them when the network interfaces come up.
Definition at line 121 of file Zeroconf.java.
void com.github.rosjava.zeroconf_jmdns_suite.jmdns.Zeroconf.addService | ( | String | name, |
String | type, | ||
String | domain, | ||
int | port, | ||
String | description | ||
) | [inline] |
Publish a zeroconf service.
Should actually provide a return value here, so the user can see the actually published name.
name | : english readable name for the service |
type | : zeroconf service type, e.g. _ros-master._tcp |
domain | : domain to advertise on (usually 'local') |
port | : port number |
description | : |
Definition at line 161 of file Zeroconf.java.
void com.github.rosjava.zeroconf_jmdns_suite.jmdns.Zeroconf.display | ( | DiscoveredService | discovered_service | ) | [inline] |
Definition at line 375 of file Zeroconf.java.
void com.github.rosjava.zeroconf_jmdns_suite.jmdns.Zeroconf.inetAddressAdded | ( | NetworkTopologyEvent | event | ) | [inline] |
A network address has been added.
event | The NetworkTopologyEvent providing the name and fully qualified type of the service. |
Implements javax.jmdns.NetworkTopologyListener.
Definition at line 322 of file Zeroconf.java.
void com.github.rosjava.zeroconf_jmdns_suite.jmdns.Zeroconf.inetAddressRemoved | ( | NetworkTopologyEvent | event | ) | [inline] |
A network address has been removed.
event | The NetworkTopologyEvent providing the name and fully qualified type of the service. |
Implements javax.jmdns.NetworkTopologyListener.
Definition at line 347 of file Zeroconf.java.
List<DiscoveredService> com.github.rosjava.zeroconf_jmdns_suite.jmdns.Zeroconf.listDiscoveredServices | ( | ) | [inline] |
If you try calling this immediately after a service added callback occurred, you probably wont see anything - it needs some time to resolve.
It will block if it needs to resolve services (and aren't in its cache yet).
Definition at line 188 of file Zeroconf.java.
void com.github.rosjava.zeroconf_jmdns_suite.jmdns.Zeroconf.removeAllServices | ( | ) | [inline] |
This should be called when your application shuts down to remove all services so you don't pollute the zeroconf namespace with hanging, unresolvable services.
Definition at line 243 of file Zeroconf.java.
void com.github.rosjava.zeroconf_jmdns_suite.jmdns.Zeroconf.removeListener | ( | String | service_type, |
String | domain | ||
) | [inline] |
Removes a single listener - though we're not likely to use this much.
Definition at line 135 of file Zeroconf.java.
void com.github.rosjava.zeroconf_jmdns_suite.jmdns.Zeroconf.serviceAdded | ( | ServiceEvent | event | ) | [inline] |
A service has been added.
Note:This event is only the service added event. The service info associated with this event does not include resolution information.
To get the full resolved information you need to listen to serviceResolved(ServiceEvent) or call JmDNS#getServiceInfo(String, String, long)
ServiceInfo info = event.getDNS().getServiceInfo(event.getType(), event.getName())
Please note that service resolution may take a few second to resolve.
event | The ServiceEvent providing the name and fully qualified type of the service. |
Implements javax.jmdns.ServiceListener.
Definition at line 259 of file Zeroconf.java.
void com.github.rosjava.zeroconf_jmdns_suite.jmdns.Zeroconf.serviceRemoved | ( | ServiceEvent | event | ) | [inline] |
A service has been removed.
event | The ServiceEvent providing the name and fully qualified type of the service. |
Implements javax.jmdns.ServiceListener.
Definition at line 273 of file Zeroconf.java.
void com.github.rosjava.zeroconf_jmdns_suite.jmdns.Zeroconf.serviceResolved | ( | ServiceEvent | event | ) | [inline] |
This implements service resolved in a very simple way. If the user has callbacks, then it just directly resolves the service info to a ros service info. Note that if you have multiple interfaces (e.g. eth0, wlan0) then this won't provide the resolved artifact for all interfaces. It might be worth adding a check for that service across all interfaces here and providing a fully updated (with regards to addresses) ros service info artifact to the user's callback here.
Implements javax.jmdns.ServiceListener.
Definition at line 293 of file Zeroconf.java.
void com.github.rosjava.zeroconf_jmdns_suite.jmdns.Zeroconf.serviceTypeAdded | ( | ServiceEvent | event | ) | [inline] |
A new service type was discovered.
event | The service event providing the fully qualified type of the service. |
Implements javax.jmdns.ServiceTypeListener.
Definition at line 308 of file Zeroconf.java.
void com.github.rosjava.zeroconf_jmdns_suite.jmdns.Zeroconf.setDefaultDiscoveryCallback | ( | ZeroconfDiscoveryHandler | listener_callback | ) | [inline] |
Definition at line 109 of file Zeroconf.java.
void com.github.rosjava.zeroconf_jmdns_suite.jmdns.Zeroconf.shutdown | ( | ) | throws IOException [inline] |
Definition at line 249 of file Zeroconf.java.
void com.github.rosjava.zeroconf_jmdns_suite.jmdns.Zeroconf.subTypeForServiceTypeAdded | ( | ServiceEvent | event | ) | [inline] |
A new subtype for the service type was discovered.
<sub>._sub.<app>.<protocol>.<servicedomain>.<parentdomain>.
event | The service event providing the fully qualified type of the service with subtype. |
Implements javax.jmdns.ServiceTypeListener.
Definition at line 314 of file Zeroconf.java.
DiscoveredService com.github.rosjava.zeroconf_jmdns_suite.jmdns.Zeroconf.toDiscoveredService | ( | ServiceInfo | service_info | ) | [inline, private] |
If you try calling this immediately after a service added callback occurred, you probably wont see anything - it needs some time to resolve.
It will block if it needs to resolve services (and aren't in its cache yet).
Definition at line 429 of file Zeroconf.java.
String com.github.rosjava.zeroconf_jmdns_suite.jmdns.Zeroconf.toString | ( | DiscoveredService | discovered_service | ) | [inline] |
Definition at line 388 of file Zeroconf.java.
ZeroconfDiscoveryHandler com.github.rosjava.zeroconf_jmdns_suite.jmdns.Zeroconf.default_listener_callback [package] |
Definition at line 68 of file Zeroconf.java.
Definition at line 63 of file Zeroconf.java.
Map<String, ZeroconfDiscoveryHandler> com.github.rosjava.zeroconf_jmdns_suite.jmdns.Zeroconf.listener_callbacks [package] |
Definition at line 67 of file Zeroconf.java.
Set<String> com.github.rosjava.zeroconf_jmdns_suite.jmdns.Zeroconf.listeners [package] |
Definition at line 64 of file Zeroconf.java.
Definition at line 66 of file Zeroconf.java.
Definition at line 65 of file Zeroconf.java.