Chat Interface
The chat system appears in the room sidebar and includes:Message List
Displays up to 20 most recent messages with sender names and timestamps
Typing Indicators
Shows who’s currently typing in real-time
Message Input
Text input field for composing messages
Auto-Scroll
Automatically scrolls to newest messages
Sending Messages
Sending messages is simple and works for both hosts and guests:Type Message
Click in the chat input field at the bottom of the chat panel and start typing your message.
Typing Indicator Activates
As you type, other participants see “[Your Name] is typing…” below the messages.
The typing indicator disappears after 1 second of inactivity or when you clear the input.
Send Message
Press Enter or click the send button. Your message is instantly broadcast to all participants.
Message Format
Each message includes:- Sender Name: Display name of the user who sent it
- Message Content: The actual text (trimmed of whitespace)
- Timestamp: When the message was sent
- User Identification: Messages you sent are visually distinct
Technical: Message Schema
Technical: Message Schema
Typing Indicators
Typing indicators show real-time awareness of who’s composing messages:How They Work
Start Typing
When you type in the input field, a
typing-start event is broadcast to all other participants.Multiple Typers
When multiple people type simultaneously:- Each person’s indicator is shown separately
- Format: “Alice is typing…”, “Bob is typing…”
- Indicators auto-remove after timeout
Message History
Chat messages are persisted in Redis for continuity:Storage
Redis List Structure
Redis List Structure
Messages are stored in a Redis list with the key pattern:
- Uses
LPUSHto add new messages to the front - Uses
LTRIMto keep only the last 20 messages - Auto-expires after 24 hours (matches room TTL)
Retrieval on Join
Retrieval on Join
When joining a room, the system:
- Fetches the last 20 messages from Redis
- Converts timestamp strings back to Date objects
- Reverses the list to chronological order
- Displays them in the chat panel
Message Limit
Late Joiners
When you join a room that already has conversation history:- Load History: Previous messages (up to 20) load immediately
- Context: You can see what’s been discussed before you arrived
- Real-Time Updates: New messages appear instantly as they’re sent
You cannot retrieve messages older than the last 20, even if they existed before the trim operation.
Chat Persistence
Chat data persists alongside the room:Lifespan
- Duration: 24 hours from last message
- Tied to Room: When room expires, chat history is deleted
- No Export: Chat history cannot be exported or saved
Deletion Scenarios
Room Expires
After 24 hours, the room and all messages auto-delete from Redis.
Room Closes
When all hosts leave, the room closes and chat history is immediately deleted.
Message Delivery
Messages are delivered via WebSocket events:Event Flow
Server Validates
The server validates:
- User is authenticated (has userId and userName)
- Message content exists and is not empty (after trimming)
- Room exists
Technical: Socket Events
Technical: Socket Events
Outgoing (Client → Server):
send-message: Send a new messagetyping-start: Notify others you’re typingtyping-stop: Notify others you stopped typing
new-message: Receive a new messageuser-typing: Someone started typinguser-stopped-typing: Someone stopped typing
Read Status
Messages have a basic read status system:- Your Messages: Automatically marked as read
- Others’ Messages: Initially marked as unread
- Overlay Mode: Unread count shows in minimized chat badge
- Mark as Read: Opening the chat marks all messages as read
Read status is client-side only and not persisted. If you refresh, all messages appear as read.
Auto-Scroll Behavior
The chat panel automatically scrolls to show new content:Scroll Triggers
New Message
Scrolls to bottom when a new message arrives (smooth scroll)
Typing Indicator
Scrolls to show typing indicator when someone starts typing
Manual Scroll
You can manually scroll up to read history
Scroll Restoration
New messages trigger scroll even if you were reading history
Chat Modes
Watch N Chill supports two chat display modes:- Overlay Mode
Best Practices
Keep It Relevant
Chat about the video you’re watching together.
Use Timestamps
Reference video timestamps when discussing specific moments.
Be Respectful
Remember real people are behind each message.
No Spam
Avoid sending too many messages rapidly.
Limitations
Troubleshooting
Messages Not Sending
“Not authenticated” error:- Your session may have expired
- Try refreshing the page
- Ensure you properly joined the room
Not Seeing Messages
Messages from others don’t appear:- Check your internet connection
- WebSocket might be disconnected
- Refresh the page to reconnect
Typing Indicator Stuck
Indicator doesn’t disappear:- Other user’s connection may have dropped
- Indicators auto-clear after timeout
- No action needed on your part
Can’t Scroll Chat
Chat panel won’t scroll:- May be a rendering issue
- Try resizing your browser window
- Refresh the page if problem persists