This project implements a simple messaging system with a server and client in Python. The system allows users to create accounts, send messages, and manage their inbox.
- Python 3
server.py
: Contains the implementation of the messaging server.client.py
: Implements a client to interact with the messaging server.
Represents a user account with a username and authentication token.
Implements the messaging server, allowing account creation, message sending, and inbox management.
A client interface to interact with the messaging server. Provides methods to create accounts, send messages, and manage the inbox.
- Open a terminal.
- Navigate to the directory containing
Server.py
. - To run the server, use the following command:
python server.py <port_number>
Replace <port_number> with the desired port.
- Open a new terminal.
- Navigate to the directory containing
Client.py
. - Run the following commands
- Create Account (Function ID: 1)
python client.py <server_ip> <server_port> 1 <username>
Creates an account for the user with the specified username and returns a unique authentication token.
- Show Accounts (Function ID: 2)
python client.py <server_ip> <server_port> 2 <authToken>
Displays a list of all accounts in the system.
- Send Message (Function ID: 3)
python client.py <server_ip> <server_port> 3 <authToken> <recipient> <message_body>
Sends a message to the specified recipient.
- Show Inbox (Function ID: 4)
python client.py <server_ip> <server_port> 4 <authToken>
Displays a list of all messages in the user's inbox.
- Read Message (Function ID: 5)
python client.py <server_ip> <server_port> 5 <authToken> <message_id>
Displays the content of a specific message and marks it as read.
- Delete Message (Function ID: 6)
python client.py <server_ip> <server_port> 6 <authToken> <message_id>
Deletes a specific message from the user's inbox.
python server.py 5000
Create Account
python client.py localhost 5000 1 demouser
Show Accounts
python client.py localhost 5000 2 <authToken>
Send Message
python client.py localhost 5000 3 <authToken> friend "Hello, friend!"
Show Inbox
python client.py localhost 5000 4 <authToken>
Read Message
python client.py localhost 5000 5 <authToken> 1
Delete Message
python client.py localhost 5000 6 <authToken> 1
Make sure to replace <server_ip>
, <server_port>
, <authToken>
, <username>
, <recipient>
, <message_body>
, and <message_id>
with the appropriate values.
- Ensure that the server is running before attempting to use the client.
- The provided examples assume the server is running on localhost and port 5000. Adjust the parameters accordingly based on your setup.