GameServer.Lobbies.SpectatorTracker (GameServer v1.0.637)

Copy Markdown

Lightweight ETS-based tracker for lobby spectators.

Spectators are users connected to a lobby channel who are not members. This module tracks them in-memory (no persistence) so we can show spectator counts in admin panels and API responses.

Summary

Functions

Returns a specification to start this module under a supervisor.

Count spectators in a lobby.

Count spectators for multiple lobbies at once. Returns %{lobby_id => count}.

List spectator user IDs for a lobby.

Track a spectator joining a lobby.

Remove a spectator from a lobby.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

count(lobby_id)

@spec count(integer()) :: non_neg_integer()

Count spectators in a lobby.

counts(lobby_ids)

@spec counts([integer()]) :: %{required(integer()) => non_neg_integer()}

Count spectators for multiple lobbies at once. Returns %{lobby_id => count}.

list(lobby_id)

@spec list(integer()) :: [integer()]

List spectator user IDs for a lobby.

start_link(opts)

track(lobby_id, user_id)

@spec track(integer(), integer()) :: true

Track a spectator joining a lobby.

untrack(lobby_id, user_id)

@spec untrack(integer(), integer()) :: true

Remove a spectator from a lobby.