Your job is to develop, document, and evaluate a Peer-to-Peer based chat application in the Java language. Rather than routing messages through a centralised server, our chat server will be based loosely on a Gnutella design. Specifically messages will be sent through the peer network, but a ChatServer will be required to provide a newly started client with a list of known clients on the Chat Network.
More detailed functionality for the application is as follows:
A registration server (ChatServer) must store information on which chat instances are connected to the chat system at any given point of time. Individual clients must register with the server when they are initialised. The ChatServer must also be able to supply clients with a randomly sampled lists of 4 known chat clients when requested. In addition to purposefully leaving the chat system, clients may 'die' at any given time. Therefore, the ChatServer should periodically verify whether clients are still reachable.
Each client should be initialised with a username and a location of the ChatServer. When initialised, clients should first register themselves with the server (found at the given location), and then request a list of 4 known chat clients. When a user types a message into the GUI (code supplied), the ChatClient code should send that message on to all known chat clients.
ChatClient instances must be able to receive messages from other ChatClient instances. The message should contain information on:
The source of the message (just a username / handle)
The content of the message (just a string of text)
The list of clients which have already seen the message
On receiving a new Message, the ChatClient should process this instance only if it has never been seen before. If it has already processed this Message before, it should be discarded.
The received Message should be displayed to the user, and then passed on. Before being passed on, the client should alter the message to indicate that the Message has now passed through this client. (You may implement how a client knows whether to pass on and display a message using your own explained logic) The message should then be passed on to any known ChatClient instances that have not seen the message before. Whether or not the message has been seen before by a given client should be indicated by the Message body.
The Deliverables for the assignment include both the well documented Java code with instruction on how to run the code, and a design document / report. The document should describe your design under the following headings: