This commit is contained in:
史悦
2025-12-16 08:57:19 +08:00
parent b8d081bd8a
commit dafb706202
46 changed files with 2610 additions and 0 deletions

11
tasks/task_018.txt Normal file
View File

@@ -0,0 +1,11 @@
# Task ID: 18
# Title: Disconnect & Reconnect Mechanism (Client & Server)
# Status: pending
# Dependencies: 9, 10, 13
# Priority: high
# Description: Implement a robust mechanism for handling client disconnections during a game, allowing players to automatically reconnect and resume their game session.
# Details:
Frontend: Implement exponential backoff for WebSocket reconnection attempts (1s, 2s, 4s...). Display a 'Reconnecting...' UI. Backend: Store a snapshot of the current game state in Redis. When a client reconnects, verify their identity and send the latest game state snapshot. Implement a 30-minute room retention policy for disconnected players to rejoin.
# Test Strategy:
During a live game, forcibly disconnect the client (e.g., turn off Wi-Fi, close and reopen app quickly). Verify automatic reconnection and game state restoration. Test behavior when reconnection fails after multiple attempts (return to lobby). Test if the room persists for 30 mins.