ErlChatML1 Protocol This protocol is designed for the Erlang Chat Server v0.2. Server and client communicate by sending lines of text. Lines are terminated with CRLF. Line terms are separated by the space character. Hexadecimal terms may contain the characters 0..9 or A..F and must be of length divisible by two. The protocol has two phases: initial and authenticated. Initial Stage The initial stage begins as soon as the TCP connection is established. During this phase, the client and server communicate synchronously. This means that they take turns sending a message and then waiting for the reply. The server starts by sending a greeting: ERLCHATML1 SR Name... - ERLCHATML1 is the protocol identifier - SR is a hexidecimal term of length 16, randomly generated by the server - the rest of the line is the server name After sending the greeting, the server waits to receive one of the following requests: NEW Nickname Passcode - Nickname consists of ASCII characters in the range 33..254 - Passcode is a hexidecimal passcode AUTHENTICATE Nickname CR Hash - Nickname is a currently registered nickname - CR is a hexidecimal term of length 16, randomly generated by the client - Hash is a hexidecimal MD5 sum of [CR SR Passcode] Upon receiving the request, the server will respond with one of: WELCOME Nick1 Nick2 Nick3 ... - nicknames of currently joined clients are listed - The nickname "Server" is always listed as the first name - indicates that the login was successful and beings the authenticated stage FAILURE - indicates that the NEW or AUTHENTICATE command failed - in response to a NEW command, FAILURE means that the nickname is in use - in response to AUTHENTICATE, it means that the nickname does not exist or the passcode is incorrect. - after sending FAILURE, the server again waits for NEW or AUTHENTICATE. Authenticated Stage The authenticated stage is where the actual chatting occurs. In this stage the server and client communicate asynchronously. The server may send any of these messages in this stage: JOINED Nick - indicates that a user, with nickname Nick, has joined the chat QUIT Nick - indicates that the user has left the chat - if Nick is the user's own nickname then the user has been kicked and will be disconnected momentarily TEXT Nick Text... - represents a text message originating from the user named Nick - the client can expect to receive only messages that originate from users who are currently "present" in the chat. That is, users whose arrivals have been announced by a JOINED message, and have not left with a QUIT message. - The message text extends to the end of the line Messages that the user may send: TEXT Text... - the user wishes to send the text message to the chat When the user wishes to leave the chat room, the client should close the TCP connection. The server will inform the other clients of the departure.