This is a real-time group chat application built using WebSockets for communication. The backend is powered by Spring Boot, while the frontend uses HTML, CSS, and JavaScript for the user interface.
- Real-time Messaging: Messages are delivered instantly to all connected users using WebSocket technology.
- Group Chat: Multiple users can join the chat room and communicate in real time.
- User Notifications: Users are notified when someone joins or leaves the chat.
- Simple and Responsive UI: The frontend is designed using HTML and CSS for a clean and responsive user experience.
- Spring Boot: Java-based framework to handle WebSocket connections and manage the chat server.
- WebSocket: Protocol for real-time communication between client and server.
- HTML: Markup language for structuring the chat interface.
- CSS: Styling for a responsive and visually appealing UI.
- JavaScript: Handles WebSocket connections and dynamic updates to the chat interface.
-
Java 17+ installed on your machine.
-
Maven to manage project dependencies.
-
Web browser for running the frontend.
The backend server will start on
http://localhost:8080
.
- The WebSocket connection is established at the following endpoint:
ws://localhost:8080/chat
- Open multiple instances of the
index.html
file in different browser tabs to simulate multiple users. - Enter your messages in the input box and click the send button or press "Enter" to broadcast the message.
- You will see real-time updates from all connected users.
group-chat-websocket/
├── src/
│ ├── main/
│ │ ├── java/
│ │ │ └── com/example/chat/
│ │ │ ├── config/ # WebSocket configuration
│ │ │ ├── controller/ # WebSocket message handling
│ │ │ └── model/ # Chat message model
│ └── resources/
│ └── application.properties # Spring Boot properties
└── frontend/
├── index.html # Chat UI
├── style.css # Chat UI styles
└── chat.js # WebSocket client logic
- When a user sends a message, the WebSocket connection sends the message to the Spring Boot server.
- The Spring Boot server broadcasts the message to all connected clients.
- The client (JavaScript) listens for incoming messages and updates the chat UI in real-time.
- User Authentication: Add authentication for users to join the chat room.
- Private Messaging: Allow users to send private messages to specific users.
- Chat History: Store and display previous messages when users join the chat.
- File Sharing: Enable users to share files in the chat.