• Mahmoud Aglan's avatar
    feat: match-session.js — comprehensive multiplayer edge case handler · 412ee8f6
    Mahmoud Aglan authored
    New core module handles ALL connection edge cases:
    
    TAB REFRESH RECOVERY:
    - Active match stored in localStorage with timestamp
    - On app boot, checks for recoverable match (< 5 min old)
    - Automatically re-enters the game scene with recovered state
    - Fetches latest state from server immediately
    
    TAB VISIBILITY (switch/minimize):
    - Pauses polling when tab is hidden (saves bandwidth)
    - Resumes and immediately fetches latest state on return
    - Resets disconnect timers on tab return
    
    OPPONENT DISCONNECT DETECTION:
    - Tracks lastOpponentActivity timestamp
    - After 30s: fires onOpponentDisconnect (show warning UI)
    - After 60s: fires onOpponentAbandon (auto-claim win)
    - If opponent comes back: fires onOpponentReconnect
    
    NETWORK LOSS HANDLING:
    - If server unreachable for 10s: fires onConnectionLost
    - On recovery: fires onConnectionRestored
    - Polling continues with error tolerance
    
    SERVER PING (keep-alive):
    - Every 10s, pings server with player ID + timestamp
    - Stored in game_state.ping field
    - Opponent's polling reads this to know sender is alive
    
    API:
    - create(matchId, gameType, callbacks) — start session
    - destroy() — clean up timers + localStorage
    - getRecoverableMatch() — check for resume on boot
    - markOpponentActive() — call when opponent data received
    - isConnected() / isOpponentConnected() — status checks
    
    Engine updated:
    - Imports match-session on boot
    - Checks for recoverable match after auth
    - Auto-resumes game if found
    Co-Authored-By: 's avatarClaude Opus 4.6 <noreply@anthropic.com>
    412ee8f6
Name
Last commit
Last update
.claude Loading commit data...
ChessPieces Loading commit data...
Connections and docs Loading commit data...
Logo El3ab Loading commit data...
admin Loading commit data...
api Loading commit data...
app icons Loading commit data...
config Loading commit data...
docs Loading commit data...
includes Loading commit data...
public Loading commit data...
screenshots Loading commit data...
.gitignore Loading commit data...
.htaccess Loading commit data...
ARCHITECTURE.md Loading commit data...
ASSET_REGISTRY.json Loading commit data...
ASSET_REGISTRY.md Loading commit data...
BUILD_ORDER.md Loading commit data...
DATABASE_REFERENCE.md Loading commit data...
DESIGN.md Loading commit data...
Dockerfile Loading commit data...
PLAN.md Loading commit data...
Stockfishbotsapi.txt Loading commit data...
bell.png Loading commit data...
captain-definition Loading commit data...
index.php Loading commit data...