Defining the Server InterfaceThe server interface defines methods for registering a client, and posting a message to the server. Listing 11.1 ServerInterface.javaimport java.rmi.*; // Remote server interface public interface ServerInterface extends Remote{ //method used to post a message to the //server. public void passMessage(String message) throws RemoteException; //method used to register a client. //It gets a reference //to the remote client that is //used to identify the client. public String getRegistered(ClientInterface ci) throws RemoteException; }
ExplanationThe first method is the passMessage() method. This method is used to pass a message to server. The method takes a string object as parameter. public void passMessage(String message) throws RemoteException; The getRegistered() method is used by the clients to get registered with the server. The method takes a reference to the remote client as its argument. public String getRegistered(ClientInterface ci) throws RemoteException; |
||
|
||
Copyright © 2001 www.universalteacher.com |
||