fix(battle-node): collision-safe battle-id registration + viewer eviction
RegisterPending → TryRegisterPending (TryAdd instead of indexer) so battle-id collisions return false instead of silently evicting a live battle. MatchingBridge retries with fresh IDs on collision (max 5). Before registering, EvictStaleForViewer removes any stale pending battle the viewer left behind, enforcing the one-pending-per-viewer invariant that was previously comment-asserted. Store tests switched to per-test local stores to fix a race under the assembly-wide ParallelScope.All. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -6,8 +6,8 @@ public sealed class InMemoryBattleSessionStore : IBattleSessionStore
|
||||
{
|
||||
private readonly ConcurrentDictionary<string, PendingBattle> _pending = new();
|
||||
|
||||
public void RegisterPending(PendingBattle battle) =>
|
||||
_pending[battle.BattleId] = battle;
|
||||
public bool TryRegisterPending(PendingBattle battle) =>
|
||||
_pending.TryAdd(battle.BattleId, battle);
|
||||
|
||||
public PendingBattle? TryGetPending(string battleId) =>
|
||||
_pending.TryGetValue(battleId, out var b) ? b : null;
|
||||
|
||||
Reference in New Issue
Block a user