triggair
Guides

Realtime rooms

WebSocket rooms with presence, broadcast, in-transit chat moderation, private rooms, typing indicators, self-healing reconnect, and history.

A realtime room is a broadcast channel with presence, backed by a live server. Join a room to get a live connection; messages you send fan out to everyone else, and presence updates as players come and go. Live server-backed rooms are an Indie-plan-and-up feature: on the Free and Dev tiers join() returns payment_required (402).

const room = await tg.realtime.join('lobby');
room.on('presence', ({ members }) => renderRoster(members));
room.on('message', ({ from, data }) => renderChat(from, data));
room.send({ text: 'gg' });

Chat is moderated in transit

Any text in a message (a string, or an object's text field) is moderated before it reaches the room: masked or blocked per the game's policy. Non-text payloads (game state, moves) pass through untouched.

Private rooms

A room name can carry a scope: join('team:<teamId>') requires active team membership, join('match:<matchId>') requires being a participant. Non-members are refused at connect (403). Any other name is a public room.

Typing indicators

Signal typing (or any transient presence-detail) with room.typing(true/false); it fans out to everyone else as a typing event and is never stored or moderated (it carries no text).

input.oninput = () => room.typing(input.value.length > 0);
room.on('typing', ({ player, state }) => showTyping(player, state));

Self-healing reconnect

The connection survives dropped links: an unexpected close triggers an automatic reconnect with capped backoff, re-joins the room, and re-welcomes (roster + history replay). A silent keep-alive heartbeat holds the socket open through idle periods. Listen for reconnecting/reconnected to reflect status in the UI.

room.on('reconnecting', ({ attempt }) => setStatus(`reconnecting… (${attempt})`));
room.on('reconnected', () => setStatus('live'));

History

Recent chat is replayed on join: room.history holds the last messages so a joiner has context immediately. Configure how many (0-200) in the dashboard or via triggair_configure_realtime; set 0 to opt out entirely for a high-frequency state room that doesn't want a chat buffer.

More in Multiplayer and social

← All guides · Recipes · API reference