feat(battle-node): InboundTracker dedupes client pubSeq + tracks high-water
This commit is contained in:
20
SVSim.BattleNode/Reliability/InboundTracker.cs
Normal file
20
SVSim.BattleNode/Reliability/InboundTracker.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user