feat(battle-node): Gungnir alive-body builders (scs/ocs ONLINE placeholders)
This commit is contained in:
23
SVSim.BattleNode/Reliability/Gungnir.cs
Normal file
23
SVSim.BattleNode/Reliability/Gungnir.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
namespace SVSim.BattleNode.Reliability;
|
||||
|
||||
/// <summary>
|
||||
/// Body builders for the alive channel. The timer/loop that drives 5s emits lives on
|
||||
/// BattleSession; this class is just the pure body-shape factory.
|
||||
/// v1 always reports scs/ocs=ONLINE — real disconnect detection is deferred.
|
||||
/// </summary>
|
||||
public static class Gungnir
|
||||
{
|
||||
public static readonly TimeSpan EmitInterval = TimeSpan.FromSeconds(5);
|
||||
|
||||
public static Dictionary<string, object?> BuildAliveEmitBody(InboundTracker tracker) => new()
|
||||
{
|
||||
["currentSeq"] = tracker.HighWaterMark,
|
||||
// actionSeq omitted in v1 — no turn-transition flag yet.
|
||||
};
|
||||
|
||||
public static Dictionary<string, object?> BuildAlivePushBody() => new()
|
||||
{
|
||||
["scs"] = "ONLINE",
|
||||
["ocs"] = "ONLINE",
|
||||
};
|
||||
}
|
||||
28
SVSim.UnitTests/BattleNode/Reliability/GungnirTests.cs
Normal file
28
SVSim.UnitTests/BattleNode/Reliability/GungnirTests.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using NUnit.Framework;
|
||||
using SVSim.BattleNode.Reliability;
|
||||
|
||||
namespace SVSim.UnitTests.BattleNode.Reliability;
|
||||
|
||||
[TestFixture]
|
||||
public class GungnirTests
|
||||
{
|
||||
[Test]
|
||||
public void BuildAlivePush_AlwaysReturnsScsOnlineOcsOnline()
|
||||
{
|
||||
var body = Gungnir.BuildAlivePushBody();
|
||||
Assert.That(body["scs"], Is.EqualTo("ONLINE"));
|
||||
Assert.That(body["ocs"], Is.EqualTo("ONLINE"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void BuildAliveEmit_CarriesCurrentSeqFromTracker()
|
||||
{
|
||||
var tracker = new InboundTracker();
|
||||
tracker.Observe(7);
|
||||
|
||||
var body = Gungnir.BuildAliveEmitBody(tracker);
|
||||
|
||||
Assert.That(body["currentSeq"], Is.EqualTo(7L));
|
||||
Assert.That(body.ContainsKey("actionSeq"), Is.False); // omitted in v1
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user