Class RealtimeChannelCallbacks

Enables messages to be published and subscribed to. Also enables historic messages to be retrieved and provides access to the RealtimePresenceCallbacks object of a channel.

Hierarchy

Constructors

Properties

errorReason: Types.ErrorInfo

An ErrorInfo object describing the last error which occurred on the channel, if any.

modes: ChannelModes

An array of ChannelMode objects.

name: string

The channel name.

params: ChannelParams

Optional channel parameters that configure the behavior of the channel.

state: ChannelState

The current ChannelState of the channel.

Methods

  • Attach to this channel ensuring the channel is created in the Ably system and all messages published on the channel are received by any channel listeners registered using subscribe(). Any resulting channel state change will be emitted to any listeners registered using the on() or once() methods. As a convenience, attach() is called implicitly if subscribe() for the channel is called, or enter() or subscribe() are called on the RealtimePresenceCallbacks object for this channel.

    Parameters

    • Optional callback: StandardCallback<null | ChannelStateChange>

      A function which will be called upon completion of the operation. If the operation succeeded and the channel became attached, then the function will be called with a ChannelStateChange object. If the channel was already attached the function will be called with null. If it failed, the function will be called with information about the error.

    Returns void

  • Detach from this channel. Any resulting channel state change is emitted to any listeners registered using the on() or once() methods. Once all clients globally have detached from the channel, the channel will be released in the Ably service within two minutes.

    Parameters

    • Optional callback: errorCallback

      A function which will be called upon completion of the operation. If the operation succeeded, then the function will be called with null. If it failed, the function will be called with information about the error.

    Returns void

  • Retrieves a PaginatedResult object, containing an array of historical Message objects for the channel. If the channel is configured to persist messages, then messages can be retrieved from history for up to 72 hours in the past. If not, messages can only be retrieved from history for up to two minutes in the past.

    Parameters

    • Optional params: RealtimeHistoryParams

      A set of parameters which are used to specify which presence members should be retrieved.

    • Optional callback: paginatedResultCallback<Message>

      A function which, upon success, will be called with a PaginatedResult object containing an array of Message objects. Upon failure, the function will be called with information about the error.

    Returns void

  • Retrieves a PaginatedResult object, containing an array of historical Message objects for the channel. If the channel is configured to persist messages, then messages can be retrieved from history for up to 72 hours in the past. If not, messages can only be retrieved from history for up to two minutes in the past.

    Parameters

    Returns void

  • Registers the provided listener for the specified event. If on() is called more than once with the same listener and event, the listener is added multiple times to its listener registry. Therefore, as an example, assuming the same listener is registered twice using on(), and an event is emitted once, the listener would be invoked twice.

    Parameters

    Returns void

  • Registers the provided listener for the specified events. If on() is called more than once with the same listener and event, the listener is added multiple times to its listener registry. Therefore, as an example, assuming the same listener is registered twice using on(), and an event is emitted once, the listener would be invoked twice.

    Parameters

    Returns void

  • Registers the provided listener all events. If on() is called more than once with the same listener and event, the listener is added multiple times to its listener registry. Therefore, as an example, assuming the same listener is registered twice using on(), and an event is emitted once, the listener would be invoked twice.

    Parameters

    Returns void

  • Registers the provided listener for the first occurrence of a single named event specified as the Event argument. If once is called more than once with the same listener, the listener is added multiple times to its listener registry. Therefore, as an example, assuming the same listener is registered twice using once, and an event is emitted once, the listener would be invoked twice. However, all subsequent events emitted would not invoke the listener as once ensures that each registration is only invoked once.

    Parameters

    Returns void

  • Registers the provided listener for the first event that is emitted. If once() is called more than once with the same listener, the listener is added multiple times to its listener registry. Therefore, as an example, assuming the same listener is registered twice using once(), and an event is emitted once, the listener would be invoked twice. However, all subsequent events emitted would not invoke the listener as once() ensures that each registration is only invoked once.

    Parameters

    Returns void

  • Returns a promise which resolves upon the first occurrence of a single named event specified as the Event argument.

    Returns

    A promise which resolves upon the first occurrence of the named event.

    Parameters

    Returns Promise<ChannelStateChange>

  • Returns a promise which resolves upon the first occurrence of an event.

    Returns

    A promise which resolves upon the first occurrence of an event.

    Returns Promise<ChannelStateChange>

  • Publishes a single message to the channel with the given event name and payload. When publish is called with this client library, it won't attempt to implicitly attach to the channel, so long as transient publishing is available in the library. Otherwise, the client will implicitly attach.

    Parameters

    • name: string

      The event name.

    • data: any

      The message payload.

    • Optional callback: errorCallback

      A function which will be called upon completion of the operation. If the operation succeeded, then the function will be called with null. If it failed, the function will be called with information about the error.

    Returns void

  • Publishes an array of messages to the channel. When publish is called with this client library, it won't attempt to implicitly attach to the channel.

    Parameters

    • messages: any[]

      An array of Message objects.

    • Optional callback: errorCallback

      A function which will be called upon completion of the operation. If the operation succeeded, then the function will be called with null. If it failed, the function will be called with information about the error.

    Returns void

  • Publish a message to the channel. When publish is called with this client library, it won't attempt to implicitly attach to the channel.

    Parameters

    • message: any

      A Message object.

    • Optional callback: errorCallback

      A function which will be called upon completion of the operation. If the operation succeeded, then the function will be called with null. If it failed, the function will be called with information about the error.

    Returns void

  • Publishes a single message to the channel with the given event name and payload. When publish is called with this client library, it won't attempt to implicitly attach to the channel, so long as transient publishing is available in the library. Otherwise, the client will implicitly attach.

    Parameters

    • name: string

      The event name.

    • data: any

      The message payload.

    • Optional callback: errorCallback

      A function which will be called upon completion of the operation. If the operation succeeded, then the function will be called with null. If it failed, the function will be called with information about the error.

    Returns void

  • Registers a listener for messages with a given event name on this channel. The caller supplies a listener function, which is called each time one or more matching messages arrives on the channel.

    Parameters

    • event: string

      The event name.

    • Optional listener: messageCallback<Message>

      An event listener function.

    • Optional callbackWhenAttached: StandardCallback<null | ChannelStateChange>

      A function which will be called upon completion of the channel attach() operation. If the operation succeeded and the channel became attached, then the function will be called with a ChannelStateChange object. If the channel was already attached the function will be called with null. If it failed, the function will be called with information about the error.

    Returns void

  • Registers a listener for messages on this channel for multiple event name values.

    Parameters

    • events: string[]

      An array of event names.

    • Optional listener: messageCallback<Message>

      An event listener function.

    • Optional callbackWhenAttached: StandardCallback<null | ChannelStateChange>

      A function which will be called upon completion of the channel attach() operation. If the operation succeeded and the channel became attached, then the function will be called with a ChannelStateChange object. If the channel was already attached the function will be called with null. If it failed, the function will be called with information about the error.

    Returns void

  • Registers a listener for messages on this channel that match the supplied filter.

    Parameters

    • filter: MessageFilter
    • Optional listener: messageCallback<Message>

      An event listener function.

    • Optional callbackWhenAttached: StandardCallback<null | ChannelStateChange>

      A function which will be called upon completion of the channel attach() operation. If the operation succeeded and the channel became attached, then the function will be called with a ChannelStateChange object. If the channel was already attached the function will be called with null. If it failed, the function will be called with information about the error.

    Returns void

  • Registers a listener for messages on this channel. The caller supplies a listener function, which is called each time one or more messages arrives on the channel.

    Parameters

    • listener: messageCallback<Message>

      An event listener function.

    • Optional callbackWhenAttached: StandardCallback<ChannelStateChange>

      A function which will be called upon completion of the channel attach() operation. If the operation succeeded and the channel became attached, then the function will be called with a ChannelStateChange object. If the channel was already attached the function will be called with null. If it failed, the function will be called with information about the error.

    Returns void

Generated using TypeDoc