import com.peterhi.working.Registry;
public class Requester {
public static void main(String[] args) throws Exception {
final Registry registry = new Registry(0);
registry.run();
SocketAddress address = new InetSocketAddress(InetAddress.getLocalHost(), 22222);
final AboutMe aboutMe = registry.subscribe(address, "aboutMe", AboutMe.class, 0);
System.out.println("Returned! " + aboutMe.getClass());
System.out.println("NAME = " + aboutMe.getName());
Hobbies h = aboutMe.getHobbies();
int c = h.getCount();
System.out.println(c);
for (int i = 0; i < c; i++) {
System.out.println(h.getHobby(i));
}
AboutMeListener listener = new AboutMeListener() {
@Override
public void callback(String message) {
final AboutMeListener me = this;
System.out.println("Callback! " + message);
/*new Thread() {
@Override
public void run() {
aboutMe.removeAboutMeListener(me);
registry.unregister(me);
}
}.run();*/
}
};
registry.register(AboutMeListener.class, listener);
aboutMe.addAboutMeListener(listener);
}