FileDocCategorySizeDatePackage
ClientProgram.javaAPI DocExample1742Sun Jun 22 18:58:24 BST 2003None

ClientProgram

public class ClientProgram extends Object
This class tries to be all things to all people: - main program for client to run. - creator of the "Agent" object to run remotely. - "server" program for remote to use Client of

Fields Summary
protected static final String
host
Constructors Summary
Methods Summary
private voiddo_the_work()
This is the server program part


		System.out.println("Client starting");

		// Find the server, and register with it
		System.out.println("Finding server");
		RunServer server = 
			(RunServer)Naming.lookup("rmi://" + host + "/" +
			RunServer.LOOKUP_NAME);

		// Create the Agent as an un-exported Remote
		AgentImpl guts = new AgentImpl();

		// This should cause the server to call us back.
		System.out.println("Passing Agent to server");
		RemoteStub rs = server.connect(guts);
		System.out.println(rs);
		RemoteRef rr = rs.getRef();

		System.out.println("Client program ready.");

		Class[] args = { double.class };
		Method setThreshold = Agent.class.getMethod("setThreshold", args);
		Method getThreshold = Agent.class.getMethod("getThreshold", null);
		//Agent myClient = null;
		for (int i = 0; i < 10; i++) {

			//myClient.setThreshold(10 * i);
			Object[] setArgs = { new Double(10) };
			rr.invoke(rs, setThreshold, setArgs, setThreshold.hashCode());

			//System.out.println("Threshold now " + myClient.getThreshold());
			// ...
			try { Thread.sleep(1000); } catch (Exception ex) { /* */ }
		}
	
public static voidmain(java.lang.String[] argv)
This is the main program, just to get things started.


	           
	       
		new ClientProgram().do_the_work();