Discovery.java
Go to the documentation of this file.
00001 package ros.zeroconf.jmdns.demos;
00002 
00003 import java.io.IOException;
00004 import java.util.List;
00005 import org.ros.message.zeroconf_comms.DiscoveredService;
00006 import ros.zeroconf.jmdns.Zeroconf;
00007 import ros.zeroconf.jmdns.StandardLogger;
00008 
00009 public class Discovery {
00010         
00011         public static void main_handler(String argv[]) throws IOException {
00012         Zeroconf zeroconf = new Zeroconf(new StandardLogger());
00013         DiscoveryHandler listener = new DiscoveryHandler();
00014                 zeroconf.setDefaultDiscoveryCallback(listener);
00015         zeroconf.addListener("_ros-master._tcp","local");
00016 //        zeroconf.addListener("_ros-master._udp","local");
00017 //        zeroconf.addListener("_concert-master._tcp","local");
00018 //        zeroconf.addListener("_concert-master._udp","local");
00019 //        zeroconf.addListener("_app-manager._tcp","local");
00020 //        zeroconf.addListener("_app-manager._udp","local");
00021         while(true) {
00022                 try {
00023                         Thread.sleep(1000L);
00024                     } catch (InterruptedException e) {
00025                         e.printStackTrace();
00026                     }
00027         }
00028     }
00029 
00030     public static void main_polling(String argv[]) throws IOException {
00031         Zeroconf browser = new Zeroconf(new StandardLogger());
00032         browser.addListener("_ros-master._tcp","local");
00033         int i = 0;
00034         while( i < 8 ) {
00035                 try {
00036                         List<DiscoveredService> discovered_services = browser.listDiscoveredServices();
00037                         if ( discovered_services.size() > 0 ) {
00038                                 System.out.println("************ Discovered Services ************");
00039                                 for ( DiscoveredService discovered_service : discovered_services ) {
00040                                         browser.display(discovered_service);
00041                                 }
00042                         } else {
00043                                 System.out.println("Waiting for resolvers...");
00044                         }
00045                         Thread.sleep(1000L);
00046                     } catch (InterruptedException e) {
00047                         e.printStackTrace();
00048                     }
00049                 ++i;
00050         }
00051         browser.removeListener("_ros-master._tcp","local");
00052         browser.shutdown();
00053     }
00054 
00055 
00056 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends


zeroconf_jmdns_demos
Author(s): Daniel Stonier
autogenerated on Tue Nov 6 2012 14:19:14