Chat Application with Real-time Features
Build a real-time chat application with user authentication and message history.
Problem Statement
Create a real-time chat application with the following features:
**Core Features:**
1. **User Authentication**: Register, login, logout functionality
2. **Real-time Messaging**: Send and receive messages instantly
3. **Chat Rooms**: Support multiple chat rooms/channels
4. **Message History**: Persist and display message history
5. **Online Status**: Show user online/offline status
6. **Typing Indicators**: Show when users are typing
**Technical Requirements:**
- Implement WebSocket connections for real-time communication
- Store messages in a database with proper indexing
- Handle user sessions and authentication
- Implement message broadcasting to room participants
- Add proper error handling and reconnection logic
**Bonus Features:**
- File sharing capabilities
- Message reactions (emojis)
- User mentions (@username)
- Message search functionality
- Mobile-responsive design
Examples
Input:
send_message({"room_id": "general", "user_id": 123, "message": "Hello everyone!"})
Output:
{"success": true, "message_id": "msg_456", "timestamp": "2024-01-01T10:30:00Z", "broadcast": true}
Explanation:
Send message to room and broadcast to all participants