package com.peterhi.obsolete;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.SocketAddress;
import com.peterhi.obsolete.MultithreadedRudpLocalEndpoint;
import com.peterhi.obsolete.RemoteRegistry;
import com.peterhi.obsolete.RudpLocalEndpoint;
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());
}
}