Overview
The Horse Trust platform uses Socket.io for real-time bidirectional communication, primarily for the chat system and live notifications.Socket.io Setup
Configured inindex.ts with CORS and authentication:
Authentication Middleware
Socket connections require JWT authentication:Connection Handler
When a user connects, they automatically join their personal room:Event Handlers
join_conversation
Join a conversation room to receive messages:send_message
Send a message in a conversation:typing
Indicates the user is typing:stop_typing
Indicates the user stopped typing:Room Structure
The socket implementation uses two types of rooms:User Rooms
Format:user:{userId}
- Users automatically join their personal room on connection
- Used for personal notifications and badges
- Example:
user:507f1f77bcf86cd799439011
Conversation Rooms
Format:conv:{conversationId}
- Users join when opening a conversation
- Used for broadcasting messages to all participants
- Example:
conv:507f191e810c19729de860ea

