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

    Interface Occupancy

    This interface is used to interact with occupancy in a chat room: subscribing to occupancy updates and fetching the current room occupancy metrics.

    Get an instance via Room.occupancy.

    interface Occupancy {
        current(): undefined | OccupancyData;
        get(): Promise<OccupancyData>;
        subscribe(listener: OccupancyListener): Subscription;
    }
    Index

    Methods

    • Get the latest occupancy data received from realtime events.

      Returns undefined | OccupancyData

      The latest occupancy data, or undefined if no realtime events have been received yet.

      If occupancy events are not enabled for this room.

    • Subscribe a given listener to occupancy updates of the chat room.

      Note: This requires occupancy events to be enabled via the enableEvents option in the OccupancyOptions options provided to the room. If this is not enabled, an error will be thrown.

      Parameters

      • listener: OccupancyListener

        A listener to be called when the occupancy of the room changes.

      Returns Subscription

      A subscription object that can be used to unsubscribe the listener.

      If occupancy events are not enabled for this room.