28 lines
878 B
C#
28 lines
878 B
C#
using SVSim.BattleNode.Protocol;
|
|
|
|
namespace SVSim.BattleNode.Reliability;
|
|
|
|
/// <summary>
|
|
/// Per-session outbound ledger. Assigns monotonic playSeq to ordered pushes and archives
|
|
/// them for future Resume retransmit (v2). No-stock control pushes (BattleFinish/JudgeResult/Resume)
|
|
/// are wrapped with no playSeq and skip the archive.
|
|
/// </summary>
|
|
public sealed class OutboundSequencer
|
|
{
|
|
private long _next = 1;
|
|
private readonly Dictionary<long, MsgEnvelope> _archive = new();
|
|
|
|
public IReadOnlyDictionary<long, MsgEnvelope> Archive => _archive;
|
|
|
|
public MsgEnvelope AssignAndArchive(MsgEnvelope envelope)
|
|
{
|
|
var seq = _next++;
|
|
var stamped = envelope with { PlaySeq = seq };
|
|
_archive[seq] = stamped;
|
|
return stamped;
|
|
}
|
|
|
|
public MsgEnvelope WrapNoStock(MsgEnvelope envelope) =>
|
|
envelope with { PlaySeq = null };
|
|
}
|