Package com.peterhi.obsolete

Examples of com.peterhi.obsolete.RemoteRegistry


public class AboutMeServer {

  public static void main(String[] args) throws Exception {
    RudpLocalEndpoint endpoint = new MultithreadedRudpLocalEndpoint(22222);
    RemoteRegistry registry = new RemoteRegistry(endpoint);
    endpoint.run();

    ArrayList<String> friendNames = new ArrayList<String>();
   
    for (int i = 0; i < 100; i++) {
      friendNames.add("Friend " + i);
    }
   
    AboutMeImpl aboutMe = new AboutMeImpl(registry, "Jason", "True name is YZW.", friendNames);
    registry.register("aboutMe", aboutMe);
    Thread.sleep(5000);
    aboutMe.fireChanged("Notice 1!!!");
    Thread.sleep(5000);
    aboutMe.fireChanged("Notice 2!!!");
  }
View Full Code Here


public class AboutMeClient {

  public static void main(String[] args) throws Exception {
    RudpLocalEndpoint endpoint = new MultithreadedRudpLocalEndpoint();
    final RemoteRegistry registry = new RemoteRegistry(endpoint);
    endpoint.run();
   
    SocketAddress address = new InetSocketAddress(InetAddress.getLocalHost(), 22222);
    final AboutMe aboutMe = registry.subscribe(address, "aboutMe", AboutMe.class);
    System.out.println("object = " + aboutMe);
    System.out.println("name = " + aboutMe.getName());
    System.out.println("description = " + aboutMe.getDescription());
    System.out.println("friends = " + aboutMe.getFriendNames(15));
   
    AboutMeListener listener = new AboutMeListener() {
      @Override
      public void changed(String notice) {
        System.out.println("Changed " + notice);
//        aboutMe.removeAboutMeListener(this);
        System.out.println("local empty after remove? " + registry.isLocalEmpty());
      }
    };
    aboutMe.addAboutMeListener(listener);
    System.out.println("local empty after add? " + registry.isLocalEmpty());
    aboutMe.addAboutMeListener(listener);
    System.out.println("local empty after add? " + registry.isLocalEmpty());
  }
View Full Code Here

TOP

Related Classes of com.peterhi.obsolete.RemoteRegistry

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.