rmiServer
Class Server

java.lang.Object
  extended by java.rmi.server.RemoteObject
      extended by java.rmi.server.RemoteServer
          extended by java.rmi.server.UnicastRemoteObject
              extended by rmiServer.Server
All Implemented Interfaces:
java.io.Serializable, java.rmi.Remote, ServerInterface

public class Server
extends java.rmi.server.UnicastRemoteObject
implements ServerInterface

This class will publish its service on the rmiregistery. the service methods available are listed in ServerInterface.java an instance of the server will contain an array of 50 remote stubs of clients represented as ChatObjectInterface.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class java.rmi.server.RemoteObject
ref
 
Constructor Summary
Server()
          constructor. creats a server for chat application
 
Method Summary
 void connect(java.lang.String name, ChatObjectInterface c)
          Implements the remote server method connect() that clients can use to connect to the server.It passes to the server the clients own remoter interface so that server can send messeges to this client.on successful registrations sends a welcome message to the user.
 void disconnect(ChatObjectInterface c)
          a remote method that a client can use to tell the server that it is quiting the chat service.
static void main(java.lang.String[] args)
          The application launch point.
 void send(java.lang.String message)
          This method is called by a remote client to send a string messege to all the other chat users.It specifically crawls through the servers client list and send the messege to all valid clients through the cleint remote interface
 void stopServer()
          Called by the server to tell all clients that it is shutting down the service.
 
Methods inherited from class java.rmi.server.UnicastRemoteObject
clone, exportObject, exportObject, exportObject, unexportObject
 
Methods inherited from class java.rmi.server.RemoteServer
getClientHost, getLog, setLog
 
Methods inherited from class java.rmi.server.RemoteObject
equals, getRef, hashCode, toString, toStub
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Server

public Server()
       throws java.rmi.RemoteException
constructor. creats a server for chat application

Throws:
java.rmi.RemoteException
Method Detail

connect

public void connect(java.lang.String name,
                    ChatObjectInterface c)
             throws java.rmi.RemoteException
Implements the remote server method connect() that clients can use to connect to the server.It passes to the server the clients own remoter interface so that server can send messeges to this client.on successful registrations sends a welcome message to the user.

Specified by:
connect in interface ServerInterface
Parameters:
name - String could be used to enforce unique nickname for each user
c - ChatObjectInterface
Throws:
java.rmi.RemoteException

send

public void send(java.lang.String message)
          throws java.rmi.RemoteException
This method is called by a remote client to send a string messege to all the other chat users.It specifically crawls through the servers client list and send the messege to all valid clients through the cleint remote interface

Specified by:
send in interface ServerInterface
Parameters:
message - String
Throws:
java.rmi.RemoteException

disconnect

public void disconnect(ChatObjectInterface c)
                throws java.rmi.RemoteException
a remote method that a client can use to tell the server that it is quiting the chat service. It just removes th clients remote interface from the servers list of client.

Specified by:
disconnect in interface ServerInterface
Parameters:
c - ChatObjectInterface of the client who wants to exit ther service
Throws:
java.rmi.RemoteException

stopServer

public void stopServer()
Called by the server to tell all clients that it is shutting down the service. It is not strictly necessary but makes the application stop more gracefully.


main

public static void main(java.lang.String[] args)
The application launch point. It creats an instance of this class, registers itself as RMICHAT and opens a simple control panel containins a switch toshut down this server. It takes no arguments.