edu.trinity.cs.bmassing.rmi
Class ChatServerImpl

java.lang.Object
  extended by java.rmi.server.RemoteObject
      extended by java.rmi.server.RemoteServer
          extended by java.rmi.server.UnicastRemoteObject
              extended by edu.trinity.cs.bmassing.rmi.ChatPartyImpl
                  extended by edu.trinity.cs.bmassing.rmi.ChatServerImpl
All Implemented Interfaces:
ChatParty, ChatServer, java.io.Serializable, java.rmi.Remote

public class ChatServerImpl
extends ChatPartyImpl
implements ChatServer

Class for server for simple chat program (with instructions for running the application). An object of this class functions as a server for the application.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class edu.trinity.cs.bmassing.rmi.ChatPartyImpl
clients, errorPrefix, serverPrefix
 
Fields inherited from class java.rmi.server.RemoteObject
ref
 
Constructor Summary
ChatServerImpl()
          Constructs server object.
 
Method Summary
 void addClient(ChatClient c)
          Adds client, printing some info to standard output and telling all previous clients to add this one.
 void broadcast(java.lang.String message)
          Sends message to all clients.
 void display(java.lang.String message)
          Displays message.
 java.util.List<ChatClient> getClients()
          Gets a list of clients.
 java.lang.String getMessagePrefix()
          Gets prefix for messages broadcast by this object.
static void main(java.lang.String[] args)
          Main program -- creates a server object and registers it.
 void removeClient(ChatClient c)
          Removes client, printing some info to standard output and telling all other clients to remove this one.
 
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

ChatServerImpl

public ChatServerImpl()
               throws java.rmi.RemoteException
Constructs server object.

Throws:
java.rmi.RemoteException
Method Detail

addClient

public void addClient(ChatClient c)
               throws java.rmi.RemoteException
Adds client, printing some info to standard output and telling all previous clients to add this one.

Specified by:
addClient in interface ChatParty
Overrides:
addClient in class ChatPartyImpl
Parameters:
c - client to add
Throws:
java.rmi.RemoteException

removeClient

public void removeClient(ChatClient c)
                  throws java.rmi.RemoteException
Removes client, printing some info to standard output and telling all other clients to remove this one.

Specified by:
removeClient in interface ChatParty
Overrides:
removeClient in class ChatPartyImpl
Parameters:
c - client to remove
Throws:
java.rmi.RemoteException

broadcast

public void broadcast(java.lang.String message)
               throws java.rmi.RemoteException
Sends message to all clients.

Specified by:
broadcast in interface ChatParty
Overrides:
broadcast in class ChatPartyImpl
Parameters:
message - message to send to all
Throws:
java.rmi.RemoteException

display

public void display(java.lang.String message)
             throws java.rmi.RemoteException
Displays message. Prints to standard output.

Specified by:
display in interface ChatParty
Parameters:
message - message to display
Throws:
java.rmi.RemoteException

getClients

public java.util.List<ChatClient> getClients()
                                      throws java.rmi.RemoteException
Gets a list of clients.

Specified by:
getClients in interface ChatServer
Returns:
list of clients currently participating
Throws:
java.rmi.RemoteException

getMessagePrefix

public java.lang.String getMessagePrefix()
Gets prefix for messages broadcast by this object.

Specified by:
getMessagePrefix in class ChatPartyImpl
Returns:
prefix for messages (server's prefix)

main

public static void main(java.lang.String[] args)
Main program -- creates a server object and registers it.

Parameters:
args - command-line arguments -- not used