This project is a client-server application for exchanging messages with support for chats and rooms. The server and client communicate via the TCP protocol.
-
User Authentication:
- Connecting new users with registration.
- Login of registered users with password verification.
- Storing passwords as SHA-1 hashes.
-
General Chat and Rooms:
- Maintaining a general chat.
- Creating rooms and connecting to them.
- Exchanging messages within rooms.
- Switching between rooms and the general chat.
-
Commands:
/create <name>
— creating a new room with password generation./join <name> <password>
— connecting to a room using a password./exit
— exiting a room and returning to the general chat.
-
Data Persistence:
- Saving user and room data upon server shutdown.
- Restoring data upon server restart.
- Connection to the Server:
- Entering a login and password for authentication.
- Sending and receiving messages in real-time.
- Handling system commands and messages.
- Ensure you have Python 3.8 or higher installed.
- Install the necessary dependencies:
pip install requirements.txt
- Run the server:
python Server.py
- Ensure you have Python 3.8 or higher installed.
- Install the necessary dependencies:
pip install requirements.txt
- Run the client application:
python client.py
This file contains the implementation of the server-side of the application. Key functions include:
- Handling client connections.
- User authentication.
- Managing the general chat and supporting rooms.
- Saving and restoring data upon server shutdown and restart.
Key functions and variables:
save_data()
,load_data()
— functions for saving and loading data.handle_client()
— function for handling messages from the client.broadcast()
— function for sending messages to all clients.shutdown_server()
— signal handler for gracefully shutting down the server.
This file contains the implementation of the client-side of the application. Key functions include:
- Connecting to the server.
- Authenticating with login and password input.
- Sending messages to and receiving messages from the server.
- Handling chat commands and system messages.
Key functions and variables:
keyboard_input()
— function for sending messages inputted by the user.receive_messages()
— function for receiving and displaying messages from the server.
- Start the server-side as described above.
- Launch the client application, specifying the server's IP address and port.
- After successful connection, enter your login and password. If it's a new login, you'll need to enter the password twice for registration.
- After authentication, you can use chat commands or simply communicate with other users.
- Create a room:
/create myroom
- Join a room:
/join myroom 1234
- Exit a room and return to the general chat:
/exit
The server saves user and room data upon normal shutdown (Ctrl+C). This data will be loaded upon the next server restart.
- Python 3.8 or higher
- Libraries:
socket
,threading
,datetime
,functools
,sys
,colorama
,hashlib
,signal
,pickle
,os
.
This project is licensed under the Apache 2.0 license.