Interface RealtimePresence

Enables the presence set to be entered and subscribed to, and the historic presence set to be retrieved for a channel.

Hierarchy

  • RealtimePresence

Properties

syncComplete: boolean

Indicates whether the presence set synchronization between Ably and the clients on the channel has been completed. Set to true when the sync is complete.

Methods

  • Enters the presence set for the channel, optionally passing a data payload. A clientId is required to be present on a channel.

    Parameters

    • Optional data: any

      The payload associated with the presence member.

    Returns Promise<void>

    A promise which resolves upon success of the operation and rejects with an ErrorInfo object upon its failure.

  • Parameters

    • data: any

      The payload associated with the presence member.

    • callback: ErrorCallback

      v1 Node-style callback (no longer supported).

    Returns never

    Deprecated

    v1 callback signature — no longer supported. Use channel.presence.enter(data) and await the returned promise. See the v2 migration guide.

    Example

    // v1 (no longer supported — IDE shows this with strikethrough):
    channel.presence.enter(data, (err) => {});

    // v2:
    await channel.presence.enter(data);
  • Enters the presence set of the channel for a given clientId. Enables a single client to update presence on behalf of any number of clients using a single connection. The library must have been instantiated with an API key or a token bound to a wildcard clientId.

    Parameters

    • clientId: string

      The ID of the client to enter into the presence set.

    • Optional data: any

      The payload associated with the presence member.

    Returns Promise<void>

    A promise which resolves upon success of the operation and rejects with an ErrorInfo object upon its failure.

  • Leaves the presence set for the channel. A client must have previously entered the presence set before they can leave it.

    Parameters

    • Optional data: any

      The payload associated with the presence member.

    Returns Promise<void>

    A promise which resolves upon success of the operation and rejects with an ErrorInfo object upon its failure.

  • Parameters

    • data: any

      The payload associated with the presence member.

    • callback: ErrorCallback

      v1 Node-style callback (no longer supported).

    Returns never

    Deprecated

    v1 callback signature — no longer supported. Use channel.presence.leave(data) and await the returned promise. See the v2 migration guide.

    Example

    // v1 (no longer supported — IDE shows this with strikethrough):
    channel.presence.leave(data, (err) => {});

    // v2:
    await channel.presence.leave(data);
  • Leaves the presence set of the channel for a given clientId. Enables a single client to update presence on behalf of any number of clients using a single connection. The library must have been instantiated with an API key or a token bound to a wildcard clientId.

    Parameters

    • clientId: string

      The ID of the client to leave the presence set for.

    • Optional data: any

      The payload associated with the presence member.

    Returns Promise<void>

    A promise which resolves upon success of the operation and rejects with an ErrorInfo object upon its failure.

  • Updates the data payload for a presence member. If called before entering the presence set, this is treated as an ENTER event.

    Parameters

    • Optional data: any

      The payload to update for the presence member.

    Returns Promise<void>

    A promise which resolves upon success of the operation and rejects with an ErrorInfo object upon its failure.

  • Parameters

    • data: any

      The payload to update for the presence member.

    • callback: ErrorCallback

      v1 Node-style callback (no longer supported).

    Returns never

    Deprecated

    v1 callback signature — no longer supported. Use channel.presence.update(data) and await the returned promise. See the v2 migration guide.

    Example

    // v1 (no longer supported — IDE shows this with strikethrough):
    channel.presence.update(data, (err) => {});

    // v2:
    await channel.presence.update(data);
  • Updates the data payload for a presence member using a given clientId. Enables a single client to update presence on behalf of any number of clients using a single connection. The library must have been instantiated with an API key or a token bound to a wildcard clientId.

    Parameters

    • clientId: string

      The ID of the client to update in the presence set.

    • Optional data: any

      The payload to update for the presence member.

    Returns Promise<void>

    A promise which resolves upon success of the operation and rejects with an ErrorInfo object upon its failure.

Generated using TypeDoc