feat(battle-node): EchoHandler consumes Echo instead of relaying
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -50,7 +50,7 @@ public sealed class BattleSession
|
|||||||
[NetworkBattleUri.TurnStart] = new TurnStartHandler(),
|
[NetworkBattleUri.TurnStart] = new TurnStartHandler(),
|
||||||
[NetworkBattleUri.Judge] = new JudgeHandler(),
|
[NetworkBattleUri.Judge] = new JudgeHandler(),
|
||||||
[NetworkBattleUri.PlayActions] = new PlayActionsHandler(),
|
[NetworkBattleUri.PlayActions] = new PlayActionsHandler(),
|
||||||
[NetworkBattleUri.Echo] = forwardWhenReady,
|
[NetworkBattleUri.Echo] = new EchoHandler(),
|
||||||
[NetworkBattleUri.TurnEndActions] = forwardWhenReady,
|
[NetworkBattleUri.TurnEndActions] = forwardWhenReady,
|
||||||
[NetworkBattleUri.JudgeResult] = forwardWhenReady,
|
[NetworkBattleUri.JudgeResult] = forwardWhenReady,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
namespace SVSim.BattleNode.Sessions.Dispatch.Handlers;
|
||||||
|
|
||||||
|
/// <summary>Echo is the receiver's per-frame ack; the client has no inbound Echo handler, so the
|
||||||
|
/// node consumes it (bullet-2 audit). Relaying would risk an echo->echo storm.</summary>
|
||||||
|
internal sealed class EchoHandler : IFrameHandler
|
||||||
|
{
|
||||||
|
public IReadOnlyList<DispatchRoute> Handle(FrameDispatchContext ctx) => Array.Empty<DispatchRoute>();
|
||||||
|
}
|
||||||
@@ -478,7 +478,7 @@ public class BattleSessionDispatchTests
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void Pvp_Echo_from_A_in_BothAfterReady_forwards_to_B()
|
public void Pvp_Echo_from_A_in_BothAfterReady_is_consumed_not_relayed()
|
||||||
{
|
{
|
||||||
var (s, a, b) = NewPvpSession();
|
var (s, a, b) = NewPvpSession();
|
||||||
DriveToAfterReady(s, a);
|
DriveToAfterReady(s, a);
|
||||||
@@ -486,8 +486,7 @@ public class BattleSessionDispatchTests
|
|||||||
|
|
||||||
var routes = s.ComputeFrames(a, NewEnvelope(NetworkBattleUri.Echo));
|
var routes = s.ComputeFrames(a, NewEnvelope(NetworkBattleUri.Echo));
|
||||||
|
|
||||||
Assert.That(routes.Count, Is.EqualTo(1));
|
Assert.That(routes, Is.Empty, "Echo has no inbound handler on the client; relaying risks an echo storm.");
|
||||||
Assert.That(routes[0].Target, Is.SameAs(b));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
|||||||
Reference in New Issue
Block a user