Classes | Public Member Functions | Package Attributes | Private Member Functions
org.rosbuilding.zeroconf.Zeroconf Class Reference
Inheritance diagram for org.rosbuilding.zeroconf.Zeroconf:
Inheritance graph
[legend]

List of all members.

Classes

class  DefaultLogger

Public Member Functions

void addListener (String service_type, String domain)
void addListener (String service_type, String domain, ZeroconfDiscoveryHandler listener_callback)
void addService (String name, String type, String domain, int port, String description)
void addService (String name, String type, String domain, int port, HashMap< String, byte[]> properties)
void addService (DiscoveredService service)
void display (DiscoveredService discovered_service)
void inetAddressAdded (NetworkTopologyEvent event)
void inetAddressRemoved (NetworkTopologyEvent event)
List< DiscoveredServicelistDiscoveredServices ()
void removeAllServices ()
void removeListener (String service_type, String domain)
void serviceAdded (ServiceEvent event)
void serviceRemoved (ServiceEvent event)
void serviceResolved (ServiceEvent event)
void serviceTypeAdded (ServiceEvent event)
void setDefaultDiscoveryCallback (ZeroconfDiscoveryHandler listener_callback)
void shutdown () throws IOException
void subTypeForServiceTypeAdded (ServiceEvent event)
String toString (DiscoveredService discovered_service)
 Zeroconf ()
 Zeroconf (ZeroconfLogger logger)

Package Attributes

ZeroconfDiscoveryHandler default_listener_callback
JmmDNS jmmdns
Map< String,
ZeroconfDiscoveryHandler > 
listener_callbacks
Set< String > listeners
ZeroconfLogger logger
Set< ServiceInfo > services

Private Member Functions

DiscoveredService toDiscoveredService (ServiceInfo service_info)

Detailed Description

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 61 of file Zeroconf.java.


Constructor & Destructor Documentation

Definition at line 74 of file Zeroconf.java.

org.rosbuilding.zeroconf.Zeroconf.Zeroconf ( ZeroconfLogger  logger) [inline]

Definition at line 92 of file Zeroconf.java.


Member Function Documentation

void org.rosbuilding.zeroconf.Zeroconf.addListener ( String  service_type,
String  domain 
) [inline]

Definition at line 116 of file Zeroconf.java.

void org.rosbuilding.zeroconf.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 125 of file Zeroconf.java.

void org.rosbuilding.zeroconf.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.

Parameters:
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 165 of file Zeroconf.java.

void org.rosbuilding.zeroconf.Zeroconf.addService ( String  name,
String  type,
String  domain,
int  port,
HashMap< String, byte[]>  properties 
) [inline]

Definition at line 186 of file Zeroconf.java.

Definition at line 204 of file Zeroconf.java.

void org.rosbuilding.zeroconf.Zeroconf.display ( DiscoveredService  discovered_service) [inline]

Definition at line 415 of file Zeroconf.java.

void org.rosbuilding.zeroconf.Zeroconf.inetAddressAdded ( NetworkTopologyEvent  event) [inline]

Definition at line 362 of file Zeroconf.java.

void org.rosbuilding.zeroconf.Zeroconf.inetAddressRemoved ( NetworkTopologyEvent  event) [inline]

Definition at line 387 of file Zeroconf.java.

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 228 of file Zeroconf.java.

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 283 of file Zeroconf.java.

void org.rosbuilding.zeroconf.Zeroconf.removeListener ( String  service_type,
String  domain 
) [inline]

Removes a single listener - though we're not likely to use this much.

Definition at line 139 of file Zeroconf.java.

void org.rosbuilding.zeroconf.Zeroconf.serviceAdded ( ServiceEvent  event) [inline]

Definition at line 299 of file Zeroconf.java.

void org.rosbuilding.zeroconf.Zeroconf.serviceRemoved ( ServiceEvent  event) [inline]

Definition at line 313 of file Zeroconf.java.

void org.rosbuilding.zeroconf.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.

Definition at line 333 of file Zeroconf.java.

void org.rosbuilding.zeroconf.Zeroconf.serviceTypeAdded ( ServiceEvent  event) [inline]

Definition at line 348 of file Zeroconf.java.

void org.rosbuilding.zeroconf.Zeroconf.setDefaultDiscoveryCallback ( ZeroconfDiscoveryHandler  listener_callback) [inline]

Definition at line 113 of file Zeroconf.java.

void org.rosbuilding.zeroconf.Zeroconf.shutdown ( ) throws IOException [inline]

Definition at line 289 of file Zeroconf.java.

void org.rosbuilding.zeroconf.Zeroconf.subTypeForServiceTypeAdded ( ServiceEvent  event) [inline]

Definition at line 354 of file Zeroconf.java.

DiscoveredService org.rosbuilding.zeroconf.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).

See also:
listDiscoveredServices
Returns:
service_infos : an array of discovered ServiceInfo objects.

Definition at line 469 of file Zeroconf.java.

String org.rosbuilding.zeroconf.Zeroconf.toString ( DiscoveredService  discovered_service) [inline]

Definition at line 428 of file Zeroconf.java.


Member Data Documentation

Definition at line 72 of file Zeroconf.java.

Definition at line 67 of file Zeroconf.java.

Map<String, ZeroconfDiscoveryHandler> org.rosbuilding.zeroconf.Zeroconf.listener_callbacks [package]

Definition at line 71 of file Zeroconf.java.

Definition at line 68 of file Zeroconf.java.

ZeroconfLogger org.rosbuilding.zeroconf.Zeroconf.logger [package]

Definition at line 70 of file Zeroconf.java.

Set<ServiceInfo> org.rosbuilding.zeroconf.Zeroconf.services [package]

Definition at line 69 of file Zeroconf.java.


The documentation for this class was generated from the following file:


smarthome_network_zeroconf
Author(s): Mickael Gaillard , Erwan Le Huitouze
autogenerated on Sat Jun 8 2019 18:23:02