CSIS 440 chat client/server project.

SimpleIRC.txt 5.3KB

    CSIS 440's _____ _ _ _____ _____ _____ / ____(_) | | |_ _| __ \ / ____| | (___ _ _ __ ___ _ __ | | ___ | | | |__) | | \___ \| | '_ ` _ \| '_ \| |/ _ \ | | | _ /| | ____) | | | | | | | |_) | | __/_| |_| | \ \| |____ |_____/|_|_| |_| |_| .__/|_|\___|_____|_| \_\\_____| | | |_| -- SimpleIRC Protocol -- * Purpose: Explaination and specification of the SimpleIRC protocol for CSIS 440, Spring 2010. * Constants 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 minus COMMAND_LENGTH, minus MAX_NICK_LENGTH, 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) * Commands 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 ::Command Format:: Client sends == <COMMAND>:<RESULT> Server sends == <NICK> <COMMAND>:<RESULT> -- Full explaination -- Command Name (UI Command Example) Command structure Server reply structure (if needed) -Explaination of what it does - Example of usage MESG (No command given, automatically assumes sending a MESG) MESG :<MESSAGE> <NICK> MESG:<MESSAGE>\n - Represents a message being sent from a client. - C-> MESG:Hi folks! - S-> MyNick MESG:Hi folks!\n NICK (/nick <NewNick>) NICK :<NewNick> <OldNick> NICK:<NewNick>\n - 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. <NICK> JOIN:<NICK>:<IP>:<PORT>\n - Shows a user connecting to the room. This is set at user connect time (post-NICK) - S-> MyNick JOIN:MyNick:1.1.1.1: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 OR - 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 MAX_MESSAGE_LENGTH. * 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. * Example = 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:1.1.1.1:48500 | Server tells client that Bob is connected S -> Fred JOIN:Fred:1.1.2.1: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.