The Event Chat feature provides real-time communication for attendees of active events. When an event starts, registered users can chat with each other through a sidebar interface.
- If you're registered for an event (Workshop, Trip, Conference, or Bazaar)
- When the event's start time arrives, a chat becomes available
- You'll see a minimized chat tab on the right side of your screen showing: 💬 Event Name
- Click on the minimized chat tab
- The chat sidebar slides in from the right (350px width)
- You can view all messages and send new ones
- Chat remains available throughout the event duration
- Messages appear in real-time for all registered attendees
- You can minimize the chat to collapse it back to a tab
- The chat persists across page navigation
- Chat automatically closes when the event end time is reached
- Messages are preserved in the database for historical purposes
- The chat tab disappears from your screen
- Instant message delivery using Socket.io WebSockets
- No page refresh needed
- Messages show sender name and timestamp
- Clean, modern design
- Smooth animations for opening/closing
- Scrollable message history
- Character limit: 1000 characters per message
- Chats automatically activate when events start
- Chats automatically deactivate when events end
- System checks every 5 minutes for event status changes
- EventChat Model (
server/models/EventChat.js)- Stores chat rooms linked to events
- Contains message history with user info
- Tracks active/inactive status
- Chat Controller (
server/controllers/chatController.js)- Handles REST API endpoints for chat data
- Manages Socket.io connections
- Verifies user registration before allowing access
- Chat Service (
server/services/chatService.js)- Automatically activates chats for starting events
- Deactivates chats for ended events
- Runs every 5 minutes via scheduler
POST /api/chat- Get or create a chat roomGET /api/chat/:eventType/:eventId/messages- Fetch messagesGET /api/active-chats- Get all active chats for current userPOST /api/chat/:eventType/:eventId/close- Close a chat (admin only)
join-chat- Join an event's chat roomsend-message- Send a message to the roomnew-message- Receive new messages (broadcast)leave-chat- Leave the chat roomerror- Receive error notifications
-
EventChatSidebar (
client/src/components/EventChatSidebar.js)- Main chat UI component
- Handles message display and input
- Can be minimized or closed
-
ChatManager (
client/src/components/ChatManager.js)- Manages multiple active chats
- Shows minimized tabs for all active chats
- Polls for new active chats every 30 seconds
- Socket Service (
client/src/services/socketService.js)- Manages WebSocket connection
- Provides methods for joining/leaving chats
- Handles message sending and receiving
- EventChatSidebar.css (
client/src/styles/EventChatSidebar.css)- Modern, responsive design
- Smooth animations
- Mobile-friendly
Backend:
cd server
npm install socket.ioClient:
cd client
npm install socket.io-clientThe Socket.io server is automatically configured in server/server.js with CORS support for the client application.
Default configuration:
- Server URL:
http://localhost:5001 - Client URL:
http://localhost:3000
- All chat endpoints require authentication
- Users must be registered for an event to access its chat
- Message validation (max 1000 characters)
- Socket connections verify user registration status
The server logs chat activities:
- User connections/disconnections
- Room joins/leaves
- Message sends
- Chat activations/deactivations
Check server console for real-time chat activity.
- Verify you're registered for an event
- Check that the event has started
- Ensure the event status is 'published'
- Check Socket.io connection (look for connection logs in browser console)
- Verify authentication token is valid
- Ensure chat is still active
- Check network connectivity
- Verify server is running on port 5001
- Check browser console for WebSocket errors
Potential improvements:
- Read receipts and unread message counts
- Typing indicators
- Message reactions (emoji)
- File/image sharing
- @mentions and notifications
- Chat moderation tools
- Message search
- User presence indicators (online/offline)
- Message editing/deletion