-
Mahmoud Aglan authored
Player reconnection: - On app boot, checks localStorage for active match - Verifies match is still 'in_progress' on server before rejoining - If match ended/aborted → clears recovery, goes to homepage - If server unreachable → tries to rejoin anyway (optimistic) Match auto-close: - handleGet() checks updated_at timestamp on every poll - If match hasn't been updated in 30+ seconds → both players inactive - Server marks match as 'completed' with result 'aborted' - Next player who polls sees status='completed' → game ends cleanly - Prevents zombie matches lingering forever Flow: 1. Both players disconnect → no pings → updated_at goes stale 2. After 30s, if either player comes back and polls → server closes match 3. Match shows as 'aborted' → player sees 'game ended' UI 4. If only one player comes back within 30s → they keep playing (match alive) Co-Authored-By:Claude Opus 4.6 <noreply@anthropic.com>
c6478774