feat(battle-node): InboundTracker dedupes client pubSeq + tracks high-water

This commit is contained in:
gamer147
2026-05-31 22:02:56 -04:00
parent 3ade8ff4f5
commit 87051737da
2 changed files with 61 additions and 0 deletions

View File

@@ -0,0 +1,20 @@
namespace SVSim.BattleNode.Reliability;
/// <summary>
/// Per-session inbound-emit ledger. Dedupes the client's pubSeq so we never dispatch
/// a retransmitted emit twice; ack-echo (via SIO callback) is the caller's job.
/// </summary>
public sealed class InboundTracker
{
private readonly HashSet<long> _seen = new();
/// <summary>Highest pubSeq observed so far. Reported via Gungnir for diagnostics.</summary>
public long HighWaterMark { get; private set; }
/// <summary>Record an incoming pubSeq. Returns true if the caller should dispatch the envelope, false on duplicate.</summary>
public bool Observe(long pubSeq)
{
if (pubSeq > HighWaterMark) HighWaterMark = pubSeq;
return _seen.Add(pubSeq);
}
}