fix(room): enforce single membership and explicit room closure (#2) #26
No reviewers
Labels
No labels
Compat/Breaking
Kind/Bug
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Security
Kind/Testing
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Reviewed
Confirmed
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
Status
Abandoned
Status
Blocked
Status
Need More Info
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: jeux/le-grand-concours#26
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/2-room-lifecycle"
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?
Implements ticket #2 — secure the room lifecycle and closure.
Problem
A socket could create/join several rooms, leaving old rooms, players and timers dangling; returning home never closed the game explicitly.
Changes
room.store.leaveRoom(socketId)closes the room when the host leaves and removes the candidate immediately otherwise (cancelling any pending grace).room:create/room:joinfirst detach the socket from any previous room, so no orphan room or timer survives.room:leaveevent (distinct from the grace-delayed disconnection). Host leave → others getroom:closed; player leave → host sees the candidate gone.closeRoomstops the game timer and all of the room's grace timers.useSocket.leave()emitsroom:leave, clears the stored session and resets state; a reusableQuitButton("Quitter" / "Fermer la salle") is wired into the host, player and spectator views and returns home.room:leave).Verification (local, all green)
node:test89 pass / 1 skip (new lifecycle + leaveRoom + single-membership tests)Docs updated:
docs/Implémentation.md(events, lifecycle, tests, limits) anddocs/Regles.md.Refs #2
A socket could create or join several rooms, leaving old rooms, players and timers dangling, and returning to the home screen never closed the game. Add an intentional, immediate departure path distinct from the grace-delayed disconnection. - room.store: leaveRoom(socketId) closes the room when the host leaves and removes the candidate immediately otherwise (cancelling any pending grace), guaranteeing a socket holds at most one active membership. - room.handler: new room:leave event; room:create and room:join first detach the socket from any previous room, so no orphan room or timer survives. closeRoom stops the game timer and all of the room's grace timers. - client: useSocket.leave() emits room:leave, clears the stored session and resets state; a reusable QuitButton ("Quitter" / "Fermer la salle") wired into the host, player and spectator views returns home. Covered by room.store unit tests (leave + single membership), Socket.IO integration scenarios (explicit close, candidate leave, successive create cleanup), a useSocket leave test, a QuitButton component test and a Playwright close-room journey. Docs updated. Refs #2 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>