refactor(battle-node): tighten Phase setter to private; document sid opacity

This commit is contained in:
gamer147
2026-06-01 11:41:47 -04:00
parent 677b1f1392
commit a364f539ad

View File

@@ -33,7 +33,7 @@ public sealed class BattleSession
public string BattleId { get; }
public long ViewerId { get; }
public BattleSessionPhase Phase { get; internal set; } = BattleSessionPhase.AwaitingInitNetwork;
public BattleSessionPhase Phase { get; private set; } = BattleSessionPhase.AwaitingInitNetwork;
public InboundTracker Inbound { get; } = new();
public OutboundSequencer Outbound { get; } = new();
@@ -378,6 +378,10 @@ public sealed class BattleSession
private async Task SendEioOpenAsync(CancellationToken ct)
{
// SID format is server-internal; the EIO3 spec suggests a 20-char base64-url id,
// but BestHTTP's SocketIO client treats it as an opaque string and never validates
// shape. Hex-truncated Guid is fine in practice; revisit if we ever care about
// matching prod telemetry.
var sid = Guid.NewGuid().ToString("N").Substring(0, 16);
var handshake = new EngineIoHandshake(sid, Array.Empty<string>(), 25000, 60000).ToJson();
await SendTextAsync($"0{handshake}", ct);