Feat/reconnection - #1160
Merged
chinweobtagaz merged 11 commits intoAug 28, 2026
Merged
Conversation
|
@nafsonig Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
chinweobtagaz
merged commit Aug 28, 2026
7b5f1d5
into
OpenKnight-Foundation:main
2 of 3 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Key Implementations:
1. Connection State Tracking
Added in ws.rs:
ConnectionStatusenum: Tracks players asConnected,Reconnecting, orDisconnectedPlayerConnectionState: Manages individual player's connection status, disconnection time, and grace timerGameSessionState: Tracks all players in a game sessionConnectionStateTracker: Central actor that manages all active game sessionscloses #1014
2. Grace Period & Reconnection Logic
OpponentDisconnected { grace_seconds_left: 60 }. When they reconnect, the opponent getsOpponentReconnected.FullStateSyncmessage with current FEN, move history, and clock times.3. WebSocket Session Updates
WsSessionto hold a reference to theConnectionStateTrackerPlayerReconnectedPlayerDisconnected(starts grace timer)closes #1022
4. Server Integration
Updated server.rs:
ConnectionStateTrackeras a shared actor initialized with the database pool5. Tests Added
test_websocket_drop_and_reconnect: Simulates a 10-second disconnect and successful reconnectiontest_grace_period_expiry: Verifies that when grace period expires, player is marked as permanently disconnectedcloses #1023
Acceptance Criteria Met:
✅ Brief disconnects (<60s) reconnect cleanly without forfeiting
✅ Reconnecting players get full state sync (FEN, moves, clocks)
✅ Opponents receive
OpponentDisconnected(grace_seconds_left)notification✅ After 60s, abandonment is triggered, awarding win to connected player
The implementation follows all requirements: game clocks continue running for disconnected players who are on the move, and no infinite stalling is possible - the 60s grace period is strictly enforced.
closes #1018