I need someone to develop a simple multi-client chat room using Java (require socket programming and threads). There must be at least two classes: [login to view URL] and [login to view URL], possibly a third class to manage which messages should be forwarded to which users ([login to view URL]). Other classes that the developer find necessary could be implemented but those three should be enough. The multiclient chat must have the following functionalities:
- When connecting, the cllient chooses a nickname. If the nickname is already being used, the server should send a message to the client: "ERROR, CHOOSE ANOTHER NICKNAME:" and then the user can keep trying until finding an appropriate nickname. If the nickname is valid, the server answers to this specific client "OK" and also sends a message to all other clients "<NICKNAME> connected to the chat.".
- There are three kinds of messages that can be sent: 1) Text messages. 2) File transfer. 3) Posts. Text messages can be either public or private. Transferring files is always done from one client to another (privately). Posts are always public and can be either text messages or posts with files (so if you want to share a file with everyone in the chat, you do it as a post). The identification of each kind of message is done through a prefix:
--> To send a public message (all clients should receive it), you type: 'MSG GLOBAL <MESSAGE>'. The first three letters identify that this is a text message. the tag "GLOBAL']' specifies that everyone should receive it and after that comes the text.
--> To send a private text message, you type: 'MSG NICKNAME <MESSAGE>'. MSG specifies that this is a text message, NICKNAME is the nickname of the recipient and after that comes the text message...
--> To send a post, you should type 'POST TOPIC <MESSAGE>''. This will be sent to everyone. The tag TOPIC is used because there is a command through which every client can read all posts concerning a specific TOPIC.
--> To read all posts concerning a specific TOPIC, type 'READ TOPIC'.
--> To send a file, the command is:' FILE NICKNAME <filename> <bytes>\n'. FILE specifies that a file will be sent, NICKNAME refers to the recipient of the file transferring, <filename> is the name of the file, which should be in the same folder as the [login to view URL] class, and bytes is an integer with the number of the bytes of the file. The maximum size of the file is 256 bytes.
--> Posting files: to share a file with everyone in the chat you should do it through a post. The command is: 'POST-FILE TOPIC <filename> <bytes>'. Everyone will receive the post immediately but the file could also be retrieved by the same 'READ TOPIC' command explained before.
'OK MSG' - notifies the client that the message was accepted and will be sent.
'ERR MSG' - the message couldn't be sent (recipient doesn't exist, wrong prefix format, etc)
''OK POST' - the server accepted the post
'ERR POST' - the server rejected the post
'OK ALLPOSTS TOPIC <count>\n
POST 1 <message>\n
. . .'
- this is the server answer when you use the READ TOPIC command
'ERR ALLPOSTS TOPIC' - when the READ TOPIC command fails for some reason (topic doesn't exist, for instance)
'OK FILE' - the file was accepted and was sent to the recipient
'ERR FILE' - the file was rejected and was not sent
'TEXT SENDER RECIPIENT(or GLOBAL) <message>' - The user SENDER sent a message to RECIPIENT (or to everyone, which should be specified by the word 'GLOBAL', and then the message is described.
'FILEFROM SENDER RECIPIENT <filename> <bytes>' - The server notifies about the transferring of a file from SENDER to RECIPIENT.
This should be all.