Every book in ReadRealm has its own chat room. When you open a book, you can join the conversation, see what other readers are saying, and send messages that appear instantly for everyone in the room. The last 50 messages are loaded automatically when you join, so you never start with an empty conversation.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/aliammari1/readrealm/llms.txt
Use this file to discover all available pages before exploring further.
Per-book rooms
Each book has a dedicated chat room —
book_{bookId}.Instant delivery
Messages are broadcast to all room members in milliseconds via Socket.IO.
Message history
The 50 most recent messages load automatically when you join.
User presence
Readers are notified when someone joins or leaves the room.
Connecting
The chat system uses Socket.IO. Connect to the ReadRealm WebSocket server before sending any events:Joining a room
Send ajoinRoom event with your book ID, user ID, and username. The server adds you to the room, sends you the message history, and announces your arrival to the other readers already in the room.
Event: joinRoom
- A
previousMessagesevent containing the last 50 messages in the room - All other members in the room receive a
userJoinedevent
Sending messages
Send achatMessage event to post a message to the room. The server saves the message and broadcasts it to all members including the sender.
Event: chatMessage
newMessage event with the saved message object.
Leaving a room
Send aleaveRoom event when you close the book or navigate away. The server removes you from the room and notifies the remaining members.
Event: leaveRoom
userLeft event.
Message history
The last 50 messages for a room are returned in reverse chronological order (newest first) as apreviousMessages event immediately after you join. This gives you immediate context for the ongoing conversation.
User presence
ReadRealm notifies everyone in a room when the membership changes:userJoined— emitted to all room members when a new reader joinsuserLeft— emitted to all remaining members when a reader leaves
username and a timestamp:
Event reference
Events you send
| Event | Payload | Description |
|---|---|---|
joinRoom | { bookId, userId, username } | Join a book’s chat room |
leaveRoom | { bookId, username } | Leave a book’s chat room |
chatMessage | { bookId, userId, username, content } | Send a message to the room |
Events you receive
| Event | Payload | Description |
|---|---|---|
previousMessages | Message[] | Last 50 messages, sent on join |
newMessage | Message | A new message posted to the room |
userJoined | { username, timestamp } | A reader joined the room |
userLeft | { username, timestamp } | A reader left the room |
Event flow diagram
Room IDs are derived from the book ID using the pattern
book_{bookId}. For example, book 2701 uses room book_2701. You do not need to construct this manually — just pass bookId in your events.