Presence enables clients to be aware of other clients that are currently present on a channel. Each member present on a channel has a unique self-assigned client identifier and system-assigned connection identifier, along with an optional payload that can be used to describe the member’s status or attributes. Presence enables you to quickly build apps such as chat rooms and multiplayer games by automatically keeping track of who is present in realtime across any device.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/ably/docs/llms.txt
Use this file to discover all available pages before exploring further.
Enter the presence set
To enter the presence set of a channel, use theenter() method:
Subscribe to presence events
Subscribe to presence events to be notified when members enter, leave, or update their status:Subscribe to specific presence events
You can subscribe to specific presence event types:Presence events
The following presence events are emitted:| Event | Description |
|---|---|
| enter | A new member has entered the channel |
| leave | A member who was present has now left the channel |
| update | An already present member has updated their member data |
| present | When subscribing to presence events on a channel that already has members present, this event is emitted for every member already present on the channel |
Update presence data
Members can update their presence data at any time:Leave the presence set
To explicitly leave the presence set:Get the current presence set
Retrieve the current members of the presence set:Presence with multiple devices
A singleclientId can be present multiple times on the same channel via different connections. For example, if a user is connected on both mobile and desktop:
Presence history
You can retrieve historical presence events:Best practices
Keep presence data small
Presence data is transmitted to all subscribers, so keep it minimal:Use presence.get() efficiently
Instead of maintaining your own list of members, callpresence.get() when needed:
Next steps
- Learn about occupancy for high-level metrics
- Explore presence history
- Understand identified clients
