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

    Interface UsePresenceResponse

    Common status variables for chat features. Most hooks in this library implement this interface.

    interface UsePresenceResponse {
        connectionError?: ErrorInfo;
        connectionStatus: ConnectionStatus;
        enter: (data?: unknown) => Promise<void>;
        leave: (data?: unknown) => Promise<void>;
        myPresenceState: { error?: ErrorInfo; present: boolean };
        presence?: Presence;
        roomError?: ErrorInfo;
        roomStatus: RoomStatus;
        update: (data?: unknown) => Promise<void>;
    }

    Hierarchy (View Summary)

    Index

    Properties

    connectionError?: ErrorInfo

    If there's a connection error it will be available here.

    connectionStatus: ConnectionStatus

    Provides the connection status of the Ably connection.

    enter: (data?: unknown) => Promise<void>

    A shortcut to the Presence.enter method. This is useful to manually control entering presence when autoEnterLeave is false, or to re-enter presence after a persistent error that the SDK could not recover from.

    Type declaration

      • (data?: unknown): Promise<void>
      • 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.

    leave: (data?: unknown) => Promise<void>

    A shortcut to the Presence.leave method. This is useful to manually control leaving presence when autoEnterLeave is false, or to leave presence before unmounting the component.

    Type declaration

      • (data?: unknown): Promise<void>
      • 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.

    myPresenceState: { error?: ErrorInfo; present: boolean }

    The current presence state of this client.

    Type declaration

    • Optionalerror?: ErrorInfo

      Indicates if an error occurred while trying to enter (on mount) or leave presence (on unmount).

    • present: boolean

      Indicates if the user is currently present in the room.

    presence?: Presence

    Provides access to the underlying Presence instance of the room.

    roomError?: ErrorInfo

    If there's an error with the room it will be available here.

    roomStatus: RoomStatus

    Provides the status of the room.

    update: (data?: unknown) => Promise<void>

    A shortcut to the Presence.update method.

    Type declaration

      • (data?: unknown): Promise<void>
      • 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.