Quality pass from the 2026-06-04 BattleNode review (audit in the outer
repo). All changes are behavior-preserving — identical wire bytes,
verified by the full 1008-test suite staying green.
- Name scattered magic numbers: crypto key/IV lengths, outbound-sequencer
base, WS receive buffer / EIO ping / SID length, polite-close timeout,
upgrade-credential keys, battle-id digit math, deterministic-turn spin.
- resultCode = 1 -> (int)ReceiveNodeResultCode.Success across body records.
- Pong "3" -> EngineIoPacketType.Pong; remove dead NoOpBotParticipant.Touch
(replace with #pragma warning disable CS0067).
- Wire-flag enums, serialized as numbers via JsonNumberEnumConverter:
turnState -> TurnState{First,Second}, isSelf -> CardOwner{Opponent,Self},
open -> ChoiceVisibility{Hidden,Open}.
- isOfficial / isInvoke -> bool / bool? via new NumericBoolJsonConverter
(reads/writes 0/1; TDD'd). Scoped to the BattleNode wire boundary only;
MatchContext and the HTTP/AI-start path stay int (AI-start uses -1 as a
sentinel, so it is not boolean).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
23 lines
1.0 KiB
C#
23 lines
1.0 KiB
C#
namespace SVSim.BattleNode.Reliability;
|
|
|
|
/// <summary>
|
|
/// Body builders for the alive channel ("Gungnir" is the client's codename for the
|
|
/// keepalive/connection-status channel — see <see cref="Protocol.Bodies.AlivePushBody"/>).
|
|
/// The timer/loop that drives <see cref="EmitInterval"/> emits lives on
|
|
/// BattleSession; this class is just the pure body-shape factory.
|
|
/// v1 always reports scs/ocs=ONLINE — real disconnect detection is deferred. The push
|
|
/// body itself is constructed inline in BattleSession.HandleAliveEventAsync using
|
|
/// AlivePushBody; only the emit body (sent by us TO the client on the alive channel,
|
|
/// currently unused in v1) remains here.
|
|
/// </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.
|
|
};
|
|
}
|