BeatKhana Development

Realtime and TournamentAssistant

Socket authentication, snapshot recovery, overlay document events and TA runtime projections.

Transport

Realtime features use Socket.IO and MessagePack where documented. Request ws:read for subscriptions and ws:write for commands; tournament authorization still applies. See the generated socket documentation for current packet payloads.

Connection discipline

  1. Obtain OAuth tokens server-side or through a public-client PKCE flow.
  2. Connect with the supported authentication payload.
  3. Subscribe to the specific tournament/overlay document surface.
  4. Treat the initial full projection as authoritative.
  5. Apply events in order while connected.
  6. After reconnect, discard speculative local state and fetch/resubscribe to a full snapshot.

Overlay document events include document create/update/delete, node create/update/delete, bulk node update and active scene changes. Match overlay state also carries selected match, picks/bans, submitted scores, notifications and timeout-related state according to permission.

Overlay TA runtime

const runtime = bk.tournamentAssistant.createOverlayRuntime();
const unsubscribe = runtime.subscribe((snapshot) => {
  console.log(snapshot.currentMap, snapshot.players, snapshot.realtimeScores);
});
await runtime.connect({ overlay });
await runtime.setOverlay(updatedOverlay); // pass each subsequent overlay snapshot

unsubscribe();
runtime.disconnect();

The runtime loads moons-ta-client lazily and resolves TA participants against the selected BeatKhana match by platform ID.

TA management projection

Operator/setup screens use a separate session and never need protobuf enums or a renderer runtime:

const session = bk.tournamentAssistant.createManagementSession();
const stop = session.subscribe((snapshot) => {
  console.log(snapshot.tournaments, snapshot.matches, snapshot.users);
});
await session.connect({ authToken: taBotToken });
await session.selectTournament(tournamentGuid);

stop();
session.disconnect();

Never confuse realtime scores with accepted/persisted match results. A referee/coordinator decision still controls replay handling and final submission.

On this page