We got a glimpse of the transformation already.

Now we will abstract the transformation away to make it easier to describe:

frilled.cs.indiana.edu%ls -ld *.java
-rw-------   1 dgerman  faculty       511 Dec 23 15:23 Client.java
-rw-------   1 dgerman  faculty        73 Dec 23 15:25 ClientExports.java
-rw-------   1 dgerman  faculty       397 Dec 23 15:31 Server.java
-rw-------   1 dgerman  faculty       123 Dec 23 15:25 ServerExports.java
-rw-------   1 dgerman  faculty       547 Dec 23 15:24 Simulation.java
-rw-------   1 dgerman  faculty       162 Dec 23 15:26 Update.java
frilled.cs.indiana.edu%cat ClientExports.java
public interface ClientExports {
    public void update(Update event);
}
frilled.cs.indiana.edu%cat Client.java
public class Client extends Thread implements ClientExports {
    String name;
    int id;

    ServerExports server;

    public Client(String name) {
	this.name = name;
    }

    public void update(Update event) {
	System.out.println(this.name +
			   " receives: ***(" + event + ")*** ");
    }

    public void run() {
	while (true) {
	    try {
		sleep((int)(Math.random() * 6000 + 10000));
	    } catch (Exception e) {

	    }

	    server.broadcast(new Update(this.name + " says: Howdy!"));

	}
    }
}
frilled.cs.indiana.edu%cat ServerExports.java
public interface ServerExports {
    public int register(ClientExports client);
    public void broadcast(Update event);
}
frilled.cs.indiana.edu%cat Server.java
public class Server implements ServerExports {

    ClientExports clients[] = new ClientExports[100];
    int index = -1;

    synchronized public int register(ClientExports client) {
	clients[++index] = client;
	return index;
    }

    synchronized public void broadcast(Update event) {
	for (int i = 0; i <= index; i++)
	    clients[i].update(event);

	System.out.println(); // fake  

    }
}
frilled.cs.indiana.edu%cat Update.java
import java.io.*; 

public class Update implements Serializable {
    String message;

    Update(String message) {
	this.message = message;
    }

    public String toString() {
	return message;
    }
}

frilled.cs.indiana.edu%cat Simulation.java
class Simulation {
    public static void main(String[] args) {

        // on the server's host
	Server server = new Server();

        // on any of the clients' hosts
	ServerExports far = server;

	Client adrian = new Client("Adrian");
	adrian.id = far.register(adrian);
	adrian.server = far;
	adrian.start();

	Client raja = new Client("Raja");
	raja.id = far.register(raja);
	raja.server = far;
	raja.start();

	Client dijkstra = new Client("Edsger");
	dijkstra.id = far.register(dijkstra);
	dijkstra.server = far;
	dijkstra.start();

    }
}
frilled.cs.indiana.edu%
Here's how this set of classes runs:
frilled.cs.indiana.edu%ls -l
total 6
-rw-------   1 dgerman  faculty       511 Dec 23 15:23 Client.java
-rw-------   1 dgerman  faculty        73 Dec 23 15:25 ClientExports.java
-rw-------   1 dgerman  faculty       397 Dec 23 15:31 Server.java
-rw-------   1 dgerman  faculty       123 Dec 23 15:25 ServerExports.java
-rw-------   1 dgerman  faculty       547 Dec 23 15:24 Simulation.java
-rw-------   1 dgerman  faculty       162 Dec 23 15:26 Update.java
frilled.cs.indiana.edu%javac *.java
frilled.cs.indiana.edu%java Simulation
Adrian receives: ***(Edsger says: Howdy!)*** 
Raja receives: ***(Edsger says: Howdy!)*** 
Edsger receives: ***(Edsger says: Howdy!)*** 

Adrian receives: ***(Adrian says: Howdy!)*** 
Raja receives: ***(Adrian says: Howdy!)*** 
Edsger receives: ***(Adrian says: Howdy!)*** 

Adrian receives: ***(Raja says: Howdy!)*** 
Raja receives: ***(Raja says: Howdy!)*** 
Edsger receives: ***(Raja says: Howdy!)*** 

Adrian receives: ***(Adrian says: Howdy!)*** 
Raja receives: ***(Adrian says: Howdy!)*** 
Edsger receives: ***(Adrian says: Howdy!)*** 

Adrian receives: ***(Edsger says: Howdy!)*** 
Raja receives: ***(Edsger says: Howdy!)*** 
Edsger receives: ***(Edsger says: Howdy!)*** 

Adrian receives: ***(Raja says: Howdy!)*** 
Raja receives: ***(Raja says: Howdy!)*** 
Edsger receives: ***(Raja says: Howdy!)*** 

Adrian receives: ***(Adrian says: Howdy!)*** 
Raja receives: ***(Adrian says: Howdy!)*** 
Edsger receives: ***(Adrian says: Howdy!)*** 

Adrian receives: ***(Edsger says: Howdy!)*** 
Raja receives: ***(Edsger says: Howdy!)*** 
Edsger receives: ***(Edsger says: Howdy!)*** 

Adrian receives: ***(Raja says: Howdy!)*** 
Raja receives: ***(Raja says: Howdy!)*** 
Edsger receives: ***(Raja says: Howdy!)*** 

frilled.cs.indiana.edu%
So that's our starting point here.

We will develop a networked version of this program.

We won't disrupt the previous version of the program.

The two will co-exist.

So here's how we do it: