Fix invite join being blocked for password-protected rooms#142
Open
nadav78 wants to merge 3 commits intoSoWeBegin:toybattles_mvsurgefrom
Open
Fix invite join being blocked for password-protected rooms#142nadav78 wants to merge 3 commits intoSoWeBegin:toybattles_mvsurgefrom
nadav78 wants to merge 3 commits intoSoWeBegin:toybattles_mvsurgefrom
Conversation
The SoWeBegin#102 fix added a check blocking joins when no password was submitted (getDataSize() != 20). Clients accepting an invite send only the room number (not 20 bytes), so they were incorrectly rejected with JOIN_INVALID_PASSWORD even though the server already authorized them via the invite. Fix: track pending invites on the Room object. When an invite is sent, the invitee's account ID is added to a pending set. The password check skips players in that set, and the entry is cleared once they join. Closes SoWeBegin#113 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… rooms When a player's TCP connection dropped mid-game, removeSession only erased them from the sessions map but left their weak_ptr in the room's m_playersVec. On reconnect (common after a wrong-password delay within the 10s heartbeat window), the new session joined alongside the ghost. Position broadcasts went to both. The ghost's still-open TCP socket caused ASIO completion handler backlog on the event loop, delaying pong (order 72) responses — high ping while alive, recovering while dead. Fixes: - CastServer SessionsManager::removeSession now calls removePlayerFromRoom so players are evicted from rooms immediately on disconnect - Room::addPlayer lambda also removes expired weak_ptrs (was returning false for them, causing stale entries to accumulate forever) - Session::setSessionId releases the old pool ID before setting the new one, preventing CastServer session ID pool exhaustion after 500 connections - Session destructor no longer calls releaseSessionID explicitly; closeSocket already handles this (was a triple-release) - Removed static from PlayerPositionHandler response packet; std::move on a static left it in moved-from state on every subsequent call Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…stServer rooms" This reverts commit d59c687.
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.
Fixes #113.
Root cause
The fix for #102 added a check that rejects room joins when no password is submitted (
getDataSize() != 20). When a client accepts an invite, it sends only the room number (not a 20-byte packet with a password), sohasInputtedPasswordwasfalseand the join was rejected withJOIN_INVALID_PASSWORD— even though the server had already authorized the player via the invite.Fix
Track pending invites on the
Roomobject using anunordered_set<uint32_t>. When an invite is sent, the invitee's account ID is added to the set. The password check inRoomJoinHandlerskips players with a pending invite, and the entry is cleared once they successfully join.The #102 fix remains fully intact for non-invited players.