Clone the repository
git clone https://github.com/jared-ni/cs262-design-exercise1.gitThen, cd into the repository, and run either the socket or the gRPC server
python server.py
python grpc/chat_gserver.py
Then, run the corresponding client:
python client.py
python grpc/chat_gclient.py
Give the host server address as the command line argument (or leave blank to run on localhost).
pip install -r requirements.txt Open a terminal, nagivate to the directory with server.py and client.py, and run the server by typing
python server.pyThen, open another terminal in the same directory. If the server is running on the same machine, type
python client.pyElse, if the server is running on a different machine as the client, run
python client.py <host>where is the address of the machine the server is currently running on.
If multiple clients want to connect, repeat the above step in another terminal.
Open a terminal, nagivate to the grpc directory with chat_gserver.py and chat_gclient.py, and run the server by typing
python chat_gserver.pyThen, open another terminal in the same directory. If the server is running on the same machine, type
python chat_gclient.pyElse, if the server is running on a different machine as the client, run
python chat_gclient.py <host>where <host> is the address of the machine the server is currently running on.
If multiple clients want to connect, repeat the above step in another terminal.
For both sockets and GRPC implementations, once the client connects to the server, the chat app prompts you to register for a user. If the client already is a registered user, then it can simply type "no". Then, chat app then prompts you to log in. Once logged in, the user receives any unseen messages sent to them while they were logged out.
Now, the user has access to various functionalities by typing:
<username>: <message>: sends <message> to <username> if <username> exists; sends immediately if <username> is logged on, else queues the message on the server.
./register: registers another user
./login: logs in another user
./list *: lists all users registered in the server; * is the text wildcard
./delete <username>: deletes <username> from server (prompts for <username> password)
./disconnect: logs user out (if logged in) and disconnects client, ending session
./help: lists these above commands in case user forgets
If the user receives a message from another user, it will show up on the user's terminal in the format ([<username>] <message>).
For testing socket implementation (part 1), open up a terminal and nagivate to the directory containing server.py and client.py. Start the server by typing
python server.pyNow, open up another terminal and nagivate to the same directory and type
python -m unittest test_client.pyThis will run all unit tests, testing individual functions of client.py and making sure that messages are sent correctly from client to server to client.
For testing grpc implementation (part 2), open up a terminal and nagivate to the directory containing chat_gserver.py and chat_gclient.py. Start the server by typing
python chat_gserver.pyNow, open up another terminal and nagivate to the same directory and type
python -m unittest test_chat_gclient.pyThis will run all unit tests, testing individual functions of chat_gclient.py and making sure that messages are sent correctly from client to server to client.