Lobby join/leave handlers + broadcast lobby state #36
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Context
When players join or leave a lobby via WebSocket, all other players need to see the updated player list in real time.
What to do
Implement handlers for
lobby:joinandlobby:leave, plus a broadcast mechanism.Files to create/change
apps/api/src/ws/handlers/lobbyHandlers.ts— join/leave handlers.apps/api/src/ws/connections.ts— new file. Track which WebSocket connections belong to which lobby (Map from lobbyId to Set of connections).Behavior
lobby:join { code }— validate joinable, add player to DB, register connection, broadcast updated state.lobby:leave { lobbyId }— remove player, remove connection, broadcast. If host leaves, handle transfer or closure.Broadcast format
Acceptance criteria