Skip to content

Presence

  • PRESENCE header: channel, kind (0 snapshot, 1 join, 2 leave, 3 update), seq when resumption is enabled. update carries entries whose info changed (e.g. a display name) without leaving.
  • Data section: a codec array of entries, each {session: text, user: text | null, info: <presence info type> | null}.
  • Snapshot: all current members. Join/leave: the entries that joined or left. A subscriber’s own join is reported only in its snapshot. Servers MAY drop a join and a leave of the same session that fall in the same batch (presence is eventually consistent).
  • Clients ignore a leave for an unknown member and treat a join for a present member as an update. An undecodable entry is handled per §8.10.
  • A SUBSCRIBE with presence: true on a channel above the server’s presence cap is answered REQUEST_ERROR RESOURCE_EXHAUSTED; on a namespace without presence, REQUEST_ERROR FAILED_PRECONDITION. The client MAY subscribe again without presence.
  • A session is a member while subscribed with or without presence: true; presence: true only controls whether it receives presence frames. [open] whether to allow “invisible” subscriptions.
  • Presence info is supplied by the server when the subscription is authorized (e.g. display name). Clients cannot set it directly in v1. Presence info that a codec the endpoint offers (§13.8) cannot encode is refused at join or update as §12.3 says. Each entry of a PRESENCE data section sits inside the array and an entry map, so the entry rule checks the nesting of presence info against a depth of 14, and a PRESENCE data section never nests deeper than 16. The array and the entry map hold no tags, so presence info may hold up to 16 tags on a path, counted over the whole data section. Leave events and the presence snapshot are built from admitted info and are never refused by the entry rule.
  • Multiple sessions of the same user appear as separate entries; clients group by user if they want per-user presence.
  • On multi-node deployments, presence is eventually consistent. Implementations MUST ensure that a session that leaves (or whose node dies) eventually produces a leave event.

From the specification: §10.6.