CMSC691D Design Patterns In Java
Fall 1999
Project 2
RMI Chat Server
Additional Requirements For CMSC691D Students
Due Date: December 8, 1999
Additional Project Requirements
Your project must allow the chat server to support multiple chat
sessions, each associated with a different topic. The topic is
identified by a simple String.
To allow clients to register for specific chat topics, the ChatServer
interface is modified as follows:
public interface ChatServer extends Remote {
public void registerClient(ChatClient client, String topic)
throws RemoteException;
public void unregisterClient(ChatClient client, String topic)
throws RemoteException;
public void broadcast(String msg, String topic)
throws RemoteException;
public String[] getHistory(int n, String topic)
throws RemoteException;
}
These methods do the following:
- public void registerClient(ChatClient client, String topic) - registers
the client with the chat server for the specified topic. If the
chat topic does not yet exist, it is created. Note that the object
registered is a remote reference to a ChatClient object on the client
host.
- public void unregisterClient(ChatClient client, String topic) -
unregisters the client with the chat server for the specified topic.
- public void broadcast(String msg, String topic) - add the String msg
to the history of the chat session for the specified topic and
notifies all registered clients of that topic of the new message.
Notification is done by invoking the update() method of the remote
ChatClient objects.
- public String[] getHistory(int n, String topic) - returns the n most
recent mesages added to the chat session for the specified topic.
Test your application with at least three clients, a server and two
different topics as chat sessions. Have a least one client register
for both topics.