_____ _ _ _____ _____ _____
/ ____(_) | | |_ _| __ \ / ____|
| (___ _ _ __ ___ _ __ | | ___ | | | |__) | |
\___ \| | '_ ` _ \| '_ \| |/ _ \ | | | _ /| |
____) | | | | | | | |_) | | __/_| |_| | \ \| |____
|_____/|_|_| |_| |_| .__/|_|\___|_____|_| \_\\_____|
-- SimpleIRC Protocol --
Explaination and specification of the SimpleIRC
protocol for CSIS 440, Spring 2010.
MAX_CLIENTS_CONNECTED = 20 users
MAX_NICK_LENGTH = 8 characters
COMMAND_LENGTH = 4 characters
MAX_MESSAGE_LENGTH = 256 - COMMAND_LENGTH - MAX_NICK_LENGTH - 3
256 as required by Walker
Three more characters off for:
- A space between NICK and COMMAND,
- A colon (:) between RESULT and COMMAND,
- A terminating newline (for when a message sends)
These are the raw commands that the protocol will send, but
not exactly what the client (in the UI) will use.
-- Summary --
MESG -- Sends a message to the server to relay to others
QUIT -- Disconnects the client gracefully
JOIN -- Message sent by the server when a client joins the room
NICK -- Changes the nickname of the client requesting the new nick
Client sends == <COMMAND>:<RESULT>
Server sends == <NICK> <COMMAND>:<RESULT>
-- Full explaination --
Command Name (UI Command Example)
Server reply structure (if needed)
-Explaination of what it does
- Example of usage
MESG (No command given, automatically assumes sending a MESG)
- Represents a message being sent from a client.
- C-> MESG:Hi folks!
- S-> MyNick MESG:Hi folks!\n
NICK (/nick <NewNick>)
- Changes the nick of the user connected
- C-> NICK :NewNick
- S-> MyNick NICK:NewNick\n
JOIN (No command given, sent from server only)
No message is sent by the client, this is a server only message.
- Shows a user connecting to the room. This is set at user connect time (post-NICK)
- S-> MyNick JOIN:MyNick:126.96.36.199:50000\n
QUIT (/quit <QUIT MESSAGE>)
<NICK> QUIT:<QUIT MESSAGE>
<NICK> QUIT:<QUIT MESSAGE>\n
- Represents a client disconnecting from the server.
- C-> MyNick QUIT:
- S-> MyNick QUIT:\n
- C-> MyNick QUIT:Bye!
- S-> MyNick QUIT:Bye!\n
* Comments / Requirements
* All messages sent by a client to the server will be sent back to the client from the server.
- Example, "MESG :<MSG>" command is used, the resulting string "NICK MESSG :<MSG>\n" is sent
back to the client. This is a way to verify that all messages made it to the server, and
allows the server to just send all messages to ALL connected clients.
* All server messages MUST be newline terminated. Still no null terminated.
* No client message must be newline terminated. Is friendly, but not required.
- No null terminator.
- Handle this appropiately (grab until out of characters or max length).
* Any messages overflowing the MAX_MESSAGE_LENGTH will be segmented _by the client._
- If the client sends more than the MAX_MESSAGE_LENGTH, it will be dropped and ignored.
- If the client sends 500 bytes of data, the server takes MAX_LENGTH_LENGTH and will
look at the rest on the next run. If there is no valid command in that segment, the
server will ignore that segment. There _must_ be a valid command _everytime._
- The client must handle fragmentation/segmentation of a message. Server only handles
* The output for any message from a User is only their nickname, and not both their Nick
and IP. For example, "<MyNick> Hi there guys!"
* All messages sent to the server will be responded to by the server to the client.
** What the client prints off of the server's messages **
* A client will print the Nick, the IP, and Port number associated with a user when they
connect, using the server information (JOIN command). (Based off of Walker's requirement)
- Example: Nick:IP:Port connected
* A client will print a Quit message, received from the server, along with quit message.
* If the client connects to a full server, the server will close the connection and the
client will have to close the connection.
= C is the client, S is the server =
C connects (socket, connect)
C -> NICK :Bob | Client requests nick 'Bob'
S -> Bob NICK:Bob\n | Server acknowledges nick 'Bob' as valid and not in use (forcing the nick)
S -> Bob JOIN:Bob:188.8.131.52:48500 | Server tells client that Bob is connected
S -> Fred JOIN:Fred:184.108.40.206:50000 | Server tells client that Fred is connected
--- Chat occurs
C -> MESG :Hi folks! | Client sends message to server (<MESSAGE> = Hi folks!)
S -> Bob MESG:Hi folks!\n | Bob's message is sent to him, and everyone else connected.
S -> Fred NICK:Fred2\n | Fred changed his nick to "Fred2"
C -> NICK:RobertTheBest | Bob requests nick "RobertTheBest"
S -> Bob NICK:RobertT_ | Server forces the nick "RobertT_" due to over MAX_NICK_LENGTH
--- Client is going to disconnect
C -> QUIT :Bye guys! | Bob quits with the quit message, "Bye guys!"
S -> Bob QUIT:Bye guys!\n | Bob's quit is sent to him, and everyone else
S closes connection on its end
C connection is closed. Is disconnected.