public class Server implements ServerExports {
int index = -1;
public int register(ClientExports client) {
clients[++index] = client;
return index;
}
ClientExports clients[] = new ClientExports [100];
public void broadcast(Update event) { }
}
|
public interface ServerExports {
public int register(ClientExports client);
public void broadcast(Update event);
} |
public class Simulation {
public static void main(String[] args) {
// on the server's host (server starts first)
Server server = new Server();
// on any of the clients' hosts
Client adrian = new Client("Adrian");
Client bjorn = new Client("Bjorn");
Client petchel = new Client("Tom");
adrian.start();
bjorn.start();
petchel.start();
}
}
|
|
public class Client extends Thread implements ClientExports {
public void update(Update event) {
}
public void run() {
}
}
|
public interface ClientExports {
public void update(Update event);
} |
|