This project implements a multi-client chat server that supports end-to-end communication between any two clients using WebSockets. It enables users to log in, send direct messages, broadcast messages to all connected users, and manage sessions in real time.
The Client-to-Client Chat Server facilitates real-time communication between multiple clients through a central Tomcat server. The server manages authentication, session tracking, and message routing using efficient in-memory data structures.
Users can:
- Log in securely via authentication implemented using Servlets.
- View a list of online users in real time.
- Send private messages to any connected user.
- Broadcast messages to all users currently online.
- Log out, which automatically updates the list of active users.
- Implemented using Java Servlets.
- On successful login, the user ID is stored in the browser cache for session persistence.
- Server maintains an active users list with session details in a HashMap, updated on login/logout events.
- A client selects a recipient user ID and sends a message.
- The server retrieves the recipient’s session using the HashMap and delivers the message directly.
- A broadcasting feature allows a message to be sent to all connected users simultaneously.
Tested for:
- Login and logout functionality
- One-to-one message delivery
- Broadcasting messages
- Session updates on user connect/disconnect events
| Component | Details |
|---|---|
| Language | Java |
| Frameworks/Tech | Servlets, WebSockets |
| Frontend | HTML, CSS, JavaScript |
| Server | Apache Tomcat v10.0 |
| IDE | Eclipse (Version 2022-03) |