feat(battle-node): wire WS handler's case BattleType.Bot to real (Real, NoOp) session

Replaces the Phase-2 log-and-return stub with a real session
construction. P2 is always null for Bot (bridge contract), so no
WaitingRoom flow needed — single real WS, Phase-1 WhenAll-everything
RunAsync semantics work because NoOp.RunAsync completes immediately.
Integration test follows in the next task.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
gamer147
2026-06-02 01:29:11 -04:00
parent a4685a9188
commit fee84cca24

View File

@@ -193,9 +193,19 @@ public sealed class BattleNodeWebSocketHandler
}
case BattleType.Bot:
// Phase 3 deliverable.
_log.LogWarning("BattleType.Bot not yet supported (Phase 3); BattleId={Bid}", battleId);
return;
{
// Phase 3: real (Real, NoOp) session. Bot's pending always has P2 == null
// (per IMatchingBridge contract validation), so isP1 must be true here. The
// earlier isP1/isP2 check has already rejected viewer mismatches.
_store.RemovePending(battleId);
var botReal = new RealParticipant(ws, viewerId, pending.P1.Context,
_loggerFactory.CreateLogger<RealParticipant>());
var noopBot = new NoOpBotParticipant();
var botSession = new BattleSession(battleId, BattleType.Bot, botReal, noopBot,
_loggerFactory.CreateLogger<BattleSession>());
await botSession.RunAsync(ctx.RequestAborted);
break;
}
default:
_log.LogError("Unknown BattleType={Type} for BattleId={Bid}; closing WS", pending.Type, battleId);