package com.peterhi.remote;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.SocketAddress;
import com.peterhi.net.rudp.RudpServer;
public class RemoteClient {
public static void main(String[] args) throws Exception {
RudpServer client = new RudpServer();
final RemoteRegistry registry = new RemoteRegistry(client, 8000);
client.start(0);
SocketAddress address = new InetSocketAddress(
InetAddress.getLocalHost(), 22222);
final RemoteInterface ri = registry.subscribe(address, "remoteInterface",
RemoteInterface.class, 80000);
System.out.println(ri);
System.out.println(ri.hashCode());
System.out.println(ri.equals(ri));
System.out.println(ri.equals(new Object()));
System.out.println(ri.getPublicAddress(null));
RemoteInterfaceListener listener = new RemoteInterfaceListener() {
@Override
public void callback(RemoteContext context, String message)
throws RemoteException {
System.out.println("Callback " + message);
ri.removeListener(null, this);
System.out.println("HERE!!! " + this.hashCode());
registry.unregister(this);
}
};
listener = registry.register(RemoteInterfaceListener.class, listener);
ri.addListener(null, listener);
}
}