Presence Object
Access presence through a channel’spresence property:
Properties
Indicates whether the presence set is synchronized with the server. Returns
true when sync is complete.Methods
enter
enter(data?, callback?): Promise<void>
Enter the presence set with optional data.
Optional data to associate with this member. Supported types: string, JSON object, binary data.
Optional callback called on completion.
- Client must have a
clientIdconfigured - Client must have presence capability on the channel
- Channel will be implicitly attached if not already
update
update(data?, callback?): Promise<void>
Update the data for this member without leaving and re-entering.
New data to associate with this member.
leave
leave(data?, callback?): Promise<void>
Leave the presence set.
Optional data emitted with the leave event.
get
get(options?): Promise<PresenceMessage[]>
Get the current presence set.
Filter by specific client ID.
Filter by specific connection ID.
Wait for presence sync to complete before returning.
subscribe
subscribe(action?, listener): Promise<void>
Subscribe to presence events.
Optional action(s) to filter events:
enter, leave, update, or present.Callback function called for each presence event.
unsubscribe
unsubscribe(action?, listener?): void
Unsubscribe from presence events.
history
history(options?): Promise<PaginatedResult<PresenceMessage>>
Retrieve presence event history.
Start time in milliseconds since epoch.
End time in milliseconds since epoch.
Maximum number of events to return (max 1000).
Query direction:
forwards or backwards.PresenceMessage
Presence messages contain:Presence action:
enter, leave, update, or present.Client ID of the member.
Connection ID of the member.
Data associated with this member.
Timestamp of the presence event.
Unique event ID.
Presence Actions
Member entered the presence set.
Member left the presence set.
Member updated their data.
Member was already present (sent during sync).
