-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Labels
backendbackend stuffbackend stuff
Description
Summary
Implement Socket.IO event handlers for users joining/leaving session rooms with proper authentication and authorization checks.
[Estimated hours: 9-10]
Objectives
- Create
session:joinevent handler - Create
session:leaveevent handler - Verify user enrollment before joining session
- Send current session state to newly joined users
- Clean up rooms on disconnect
- Track active users per session
Description
This is the foundation for all real-time features. When a user joins a session, they enter a Socket.IO room specific to that session. All future events (questions, answers, upvotes) are broadcast only to users in that room.
User Flow
- User authenticates and connects to WebSocket
- User emits
session:joinwithsessionId - Server verifies user is enrolled in course
- User joins Socket.IO room
session:{sessionId} - Server sends current session state (all questions, settings)
- User sees live updates from other participants
Technical Details
File Structure
src/socket/handlers/
└── sessionHandlers.ts
Functions to implement:
- handleSessionJoin(socket, io)
- handleSessionLeave(socket, io)
- sendSessionState(socket, sessionId)
- cleanupDisconnect(socket)
Acceptance Criteria
- User can join session they're enrolled in
- User cannot join session they're not enrolled in (error emitted)
- After joining, user receives
session:statewith all current questions - Active user count increments when user joins
- Active user count decrements when user leaves
- When user disconnects, they're removed from all rooms
- Professor can see list of active users (by role)
- Rejoining session doesn't create duplicate in active users lis
Resources
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
backendbackend stuffbackend stuff