This project is a hybrid instant messaging application that combines Client-Server and Peer-to-Peer (P2P) communication models. The application enables users to engage in one-to-one chats or group conversations, offering flexibility and efficient resource utilization.
-
One-to-One Chat:
Users can start private chats. Device information (ID and port) is fetched from the server, and a direct P2P connection is established, offloading communication from the server. -
Group Chat:
Users in a one-to-one chat can seamlessly add others to form a group. Each participant creates direct P2P sockets with every other participant, ensuring decentralized communication. -
Offline Messaging:
Messages sent to offline or busy users are stored on the server in a dedicated "pending messages" directory. These are delivered when the recipient becomes available. -
Crash Handling:
Devices detect crashes based on communication errors and update their connections accordingly to maintain an uninterrupted experience for active users. -
Chat History:
Maintains message history for one-to-one chats for reference and continuity. -
File Sharing:
Files can be shared using the/scommand. Received files are saved locally for easy access. -
User Directory and Contact List:
A built-in directory system stores usernames and contact details, while a dynamicchatDevicesvariable tracks active chats. -
Server Recovery:
Server states are saved upon disconnection in aserver_info.txtfile for smooth recovery during restarts. -
Timestamps:
User activity is tracked with timestamps formatted asHH:MM:SS, dynamically updated with atempo_attuale()function.
- Socket Programming: Ensures real-time communication.
- Hybrid Architecture: Combines the benefits of Client-Server and Peer-to-Peer models.
- File Management: For offline message storage, contact directory, and server persistence.
- Clone this repository.
- Start the server to manage user data and offline messages.
- Launch the client application to initiate one-to-one or group chats, or share files using the
/scommand.
To test file sharing:
- Share a file named
fileprova.txt. - Check the received file in
recv.txt.
Developer: Francesco Moretti
University: University of Pisa, Computer Networks (2022/2023)