@ably/chat - v0.10.0
    Preparing search index...

    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.

    interface Presence {
        enter(data?: unknown): Promise<void>;
        get(params?: RealtimePresenceParams): Promise<PresenceMember[]>;
        isUserPresent(clientId: string): Promise<boolean>;
        leave(data?: unknown): Promise<void>;
        subscribe(
            eventOrEvents: PresenceEventType | PresenceEventType[],
            listener?: PresenceListener,
        ): Subscription;
        subscribe(listener?: PresenceListener): Subscription;
        update(data?: unknown): Promise<void>;
    }
    Index

    Methods

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

      Parameters

      • Optionaldata: unknown

        The users data, a JSON serializable object that will be sent to all subscribers.

      Returns Promise<void>

      or upon failure, the promise will be rejected with an Ably.ErrorInfo object which explains the error.

      If the room is not in the attached or attaching state.

    • Method to check if user with supplied clientId is online

      Parameters

      • clientId: string

        The client ID to check if it is present in the room.

      Returns Promise<boolean>

      or upon failure, the promise will be rejected with an Ably.ErrorInfo object which explains the error.

      If the room is not in the attached or attaching state.

    • 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.

      Parameters

      • Optionaldata: unknown

        The users data, a JSON serializable object that will be sent to all subscribers.

      Returns Promise<void>

      or upon failure, the promise will be rejected with an Ably.ErrorInfo object which explains the error.

      If the room is not in the attached or attaching state.

    • 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.

      Parameters

      • Optionaldata: unknown

        The users data, a JSON serializable object that will be sent to all subscribers.

      Returns Promise<void>

      or upon failure, the promise will be rejected with an Ably.ErrorInfo object which explains the error.

      If the room is not in the attached or attaching state.