<Put your name here>
<Put your instructor’s name here>
<Put your course name here>
<Put date here>
The report covers the third and final phase of the chat server implementation. This phase includes implementation of functionalities that control the chatting behavior of clients, including private chat, making friends and initiating chat request as well as notifying clients about chat messages from other clients. The above functionalities are implemented by means of several methods as well as data objects. This report discusses each functionality in detail and describes the mode of implementation of each.
- Private Chat - Facilitates a one-to-one chat functionality where one client can chat with another client. Both these clients will not be visible in the chat room list. Thus the communication between these clients will not be relayed into the chat room. The ChatHadler.java class contains a method singleChatHandle(), which implements this functionality. The method accepts Message type as argument and extracts the sender and receiver client from the Message argument and helps the sender communicate with the receiver without being visible in the chat room. Room chats, on the other hand, are handled by the roomChatHandle() method, which also accepts Message type as an argument and relays the message from the sender in the chat room.
- Making Friends and Initiating Chat - Through this functionality, clients can make friends and initiate chat with friends or in a chat room. The checkFriendHandle() method in the MakeFriendsHandler class checks if another client already exists as a friend in the friend list. It does this using the friendExists() method of the FriendListDB class. If the friend does not exist, the clientMkFriendsHandle() method in the MakeFriendsHandler adds the friend. Friends are added using the addFriends() method of the FriendListDB class.
The client can now chat with friends through one-to-one private chat or in a chat room. Messages can be sent to all clients in a chat room using the send() method of ServerThread class. The ServerThread class eventually uses the singleChatHandle() method of ChatHandler class to broadcast messages. The ServerThread class facilitates the communication of private messages in one-on-one chat using its send() method and singleChatHandle() method of the singleChatHandle class.
- Clients receive notifications on receiving messages from other clients – This functionality helps clients receive message notifications when messages arrive from other clients. Thus, clients in a chat room are notified when a message arrives from another client sharing the chat room. This functionality is implemented using the roomChatHandle() method of ChatHandler class. This method iterates over the entire room list and finds clients sending messages in the respective rooms. It then determines the server thread used by the client and uses the send() method of the server thread to relay the message to all clients in the chat room.
The implementation of the above functionalities involves other classes of the controller and the model. The primary classes and their methods used in achieving the functional goal of the requirements in Phase III have been mentioned in the report.