feat(battle-node): Gungnir alive-body builders (scs/ocs ONLINE placeholders)

This commit is contained in:
gamer147
2026-05-31 22:07:31 -04:00
parent 82b7d1e940
commit 22a4825265
2 changed files with 51 additions and 0 deletions

View 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",
};
}

View 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
}
}