Publisher.java
Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2013 Yujin Robot.
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
00005  * use this file except in compliance with the License. You may obtain a copy of
00006  * the License at
00007  *
00008  * http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
00012  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
00013  * License for the specific language governing permissions and limitations under
00014  * the License.
00015  */
00016 package com.github.rosjava.zeroconf_jmdns_suite.jmdns.tutorials;
00017 
00018 import java.io.IOException;
00019 
00020 import com.github.rosjava.zeroconf_jmdns_suite.jmdns.StandardLogger;
00021 import com.github.rosjava.zeroconf_jmdns_suite.jmdns.Zeroconf;
00022 
00023 public class Publisher {
00024         
00025         public static void main_publisher() throws IOException {
00026         Zeroconf publisher = new Zeroconf(new StandardLogger());
00027         System.out.println("Publishing DudeMaster for 8 seconds, then removing");
00028         publisher.addService("DudeMaster", "_ros-master._tcp", "local", 8888, "Dude's test master");
00029         int i = 0;
00030         while(true) {
00031                 try {
00032                         Thread.sleep(1000L);
00033                     } catch (InterruptedException e) {
00034                         e.printStackTrace();
00035                     }
00036                 ++i;
00037                 if ( i == 8 ) {
00038                         publisher.removeAllServices();
00039                 }
00040         }
00041     }
00042 }


zeroconf_jmdns_suite
Author(s): Daniel Stonier
autogenerated on Thu Aug 27 2015 15:50:27