Chat Server
This assignment has automated tests! Make sure to read the Automated Testing page and to download the framework from GitHub before starting.
Description
In the chat client assignment, you used a server hosted by the teaching team. This server connects multiple clients and forwards messages between them. In this assignment, you implement your chat server using the same protocol.
Unlike the client, the server is likely to have multiple open connections at the same time—one for each client that is connected to it. Because it is impossible to predict when a client will send a request or message, your server needs to keep checking all connections for incoming data. Both polling and multi-threading are allowed as solutions to this problem.
Important: tests will expect a server to start at address 127.0.0.1 and port 5378 (even though you can develop your server using another address and port). The address and port will be, as well, supplied via test script when starting your server script using the --address and --port . Thus tests will start your server script as python3 server.py --address "127.0.0.1" --port 5378 . After the server has started and is ready to accept incoming connection the tests will expect a server to output Server is on .
Requirements
Protocol Requirements:
PR1: Your server must support the full protocol specified in the Chat Application Protocol. This is the same protocol as the one used in the Chat Client assignment.
PR2: Receiving a
HELLO-FROMmessage from a user that is not authenticated should trigger an attempt to log the user in with their provided username.PR3: If a user logs in with a valid username that is not in use, the server must send a
HELLOmessage in response.PR4: If a user logs in with an invalid username, the server must send a
BAD-RQST-BODYmessage in response and close the connection.PR5: If a user logs in with a username that is in use, the server must send an
IN-USEmessage as a reply and close the connection.PR6: If a user that has already logged in attempts to send a
HELLO-FROMlog-in request, the server must respond with aBAD-RQST-HDRmessage.PR7: If a user who has not already logged in attempts to send anything other than a
HELLO-FROMlog-in request, the server must respond with aBAD-RQST-HDRmessage and close the connection.PR8: If a logged-in user sends a
LISTmessage, the server must reply with aLIST-OKmessage.PR9: The body of the
LIST-OKmessage must be a comma-separated list, containing only exactly the usernames of all currently logged-in users.PR10: If a logged-in user sends a
SENDmessage to the server with a valid recipient, the server must send aDELIVERYmessage to the target recipient.PR11: If a logged-in user sends a
SENDmessage to the server with a valid recipient, and the server forwards it successfully, the server must send aSEND-OKmessage to the original sender.PR12: The
SEND-OKmessage must not be sent before the correspondingDELIVERYa message has been successfully sent.PR13: If a logged-in user sends a
SENDmessage to the server, where the target recipient is not logged in, the server must respond with aBAD-DEST-USERmessage.PR14: If a
SENDmessage cannot be forwarded to the specified recipient for any reason, noSEND-OKthe message must be sent.PR15: If a user sends a
HELLO-FROMmessage when the server is full, the server must respond with aBUSYmessage.PR16: If any error stemming from an invalid message header occurs during operation, other than specified above, the server must send a
BAD-RQST-HDRmessage in response.PR17: If any error stemming from an invalid message body occurs during an operation, other than specified above, the server must send a
BAD-RQST-BODYmessage in response
Username Requirements
UR1: Usernames must not contain spaces.
UR2: Usernames must not contain commas.
Technical Requirements:
TR1: The server must support 16 concurrent users
TR2: The server must use Threading or Polling to support concurrent connections.
TR3: The server must detect when users disconnect and remove them from the logged-in user list.
TR4: The server must not use sendall() function
TR5: The server must print
Server is onon startup when ready to start accepting client conenctions.
Last updated