Question: In java please In this assignment, you will implement a simple chat room. This will require a serverprogram. 1 Problem Specification The server is multi-threaded.

In java please

In this assignment, you will implement a simple chat room. This will require a serverprogram.

1 Problem Specification

The server is multi-threaded. It maintains a list (a ArrayList will work well) of all the activeconnections. It will listen on a port for a new connection. You have the authority to choosethe port number and design appropriate protocol for client-server communication. Whenone comes in, it spawns a thread to handle the connection, and the main thread resumeslistening. The spawned thread sends out a message asking for an ID name on the socket.When the client replies, the connection information is added to the master list of chat roomoccupants (so there is a shared ArrayList of references). From that point on, anything thatis typed by the client is relayed to all chat room occupants (including the client), withthe ID identifying the client. Of course if null is read from the client, or the special valueLOGOUT then the client has disconnected and you should remove the connection from theshared ArrayList and then exit the thread gracefully (i.e. stop the infinite loop in the runmethod). Dont worry too much about error checking. However, you will need to be carefulto synchronize access to the array list using locks, since otherwise you might delete an entrywhile another thread is trying to broadcast to everyone, potentially resulting in an out-of-bounds ArrayList access or worse. You can test the server by starting it and connecting viaseveral telnet windows. (You can turn the echo on for the telnet windows to see what youare typing.)Broadcast a message when the client first joins the chatroom, and then broadcast a mes-sage when the client leaves the chatroom (in the finally block, after adjusting the ArrayList,but immediately prior to terminating the run method).

Bonus Part

You should be able to have multiple chat rooms simultaneously. Also, the server shouldmake sure that there are no two clients with the same ID name in a chatroom at any giventime. If a client wants to join with an ID acquired by another chatroom occupant, the serverhas to notify the client to choose a different ID.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!