1.2 KiB
1.2 KiB
Host Disconnect Pause Logic
Objective
Ensure the game pauses for all players when the Host disconnects, preventing auto-pick logic from advancing the game state. enable players to leave cleanly.
Changes
-
Server (
src/server/index.ts):- Refactored socket handlers.
- Implemented
startAutoPickTimer/stopAllRoomTimershelpers. - Updated
disconnecthandler: Checks if disconnected player is passed host. If true, pauses game (stops all timers). - Updated
join_room/rejoin_room: Resumes game (restarts timers) if Host reconnects. - Added
leave_roomevent handler to properly remove players from room state.
-
Frontend (
src/client/src/modules/lobby/LobbyManager.tsx):- Updated
handleExitRoomto emitleave_roomevent, preventing "ghost" connections.
- Updated
-
Frontend (
src/client/src/modules/lobby/GameRoom.tsx):- Fixed build error (unused variable
setGameState) by addinggame_updatelistener. - Verified "Game Paused" overlay logic exists and works with the new server state (
isHostOffline).
- Fixed build error (unused variable
Result
Host disconnection now effectively pauses the draft flow. Reconnection resumes it. Players can leave safely.