Presence

interface Presence

This interface is used to interact with presence in a chat room: subscribing to presence events, fetching presence members, or sending presence events (join,update,leave).

Get an instance via Room.presence.

Types

Link copied to clipboard
fun interface Listener

An interface for listening to new presence event

Properties

Link copied to clipboard
abstract val channel: Channel

Get the underlying Ably realtime channel used for presence in this chat room.

Functions

Link copied to clipboard
Link copied to clipboard
abstract suspend fun enter(data: PresenceData? = null)

Method to join room presence, will emit an enter event to all subscribers. Repeat calls will trigger more enter events.

Link copied to clipboard
abstract suspend fun get(waitForSync: Boolean = true, clientId: String? = null, connectionId: String? = null): List<PresenceMember>

Method to get list of the current online users and returns the latest presence messages associated to it.

Link copied to clipboard
abstract suspend fun isUserPresent(clientId: String): Boolean

Method to check if user with supplied clientId is online

Link copied to clipboard
abstract suspend fun leave(data: PresenceData? = null)

Method to leave room presence, will emit a leave event to all subscribers. If the user is not present, it will be treated as a no-op.

Link copied to clipboard
abstract fun subscribe(listener: Presence.Listener): Subscription

Subscribe the given listener to all presence events.

Link copied to clipboard
abstract suspend fun update(data: PresenceData? = null)

Method to update room presence, will emit an update event to all subscribers. If the user is not present, it will be treated as a join event.