Enables messages to be published and subscribed to. Also enables historic messages to be retrieved and provides access to the RealtimePresencePromise 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 RealtimePresencePromise object for this channel.

    Returns

    A promise which, upon success, if the channel became attached will be fulfilled with a ChannelStateChange object. If the channel was already attached the promise will be fulfilled with null. Upon failure, the promise will be rejected with an ErrorInfo object.

    Returns Promise<null | ChannelStateChange>

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

    Returns

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

    Returns Promise<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.

    Returns

    A promise which, upon success, will be fulfilled with a PaginatedResult object containing an array of Message objects. Upon failure, the promise will be rejected with an ErrorInfo object which explains the error.

    Parameters

    • Optional params: RealtimeHistoryParams

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

    Returns Promise<PaginatedResult<Message>>

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

    Returns

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

    Parameters

    • name: string

      The event name.

    • data: any

      The message payload.

    Returns Promise<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.

    Returns

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

    Parameters

    • messages: any[]

      An array of Message objects.

    Returns Promise<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.

    Returns

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

    Parameters

    Returns Promise<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.

    Returns

    A promise which, upon successful attachment to the channel, will be fulfilled with a ChannelStateChange object. If the channel was already attached the promise will be resolved with null. Upon failure, the promise will be rejected with an ErrorInfo object.

    Parameters

    Returns Promise<null | ChannelStateChange>

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

    Returns

    A promise which, upon successful attachment to the channel, will be fulfilled with a ChannelStateChange object. If the channel was already attached the promise will be resolved with null. Upon failure, the promise will be rejected with an ErrorInfo object.

    Parameters

    • events: string[]

      An array of event names.

    • Optional listener: messageCallback<Message>

      An event listener function.

    Returns Promise<null | ChannelStateChange>

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

    Returns

    A promise which, upon successful attachment to the channel, will be fulfilled with a ChannelStateChange object. If the channel was already attached the promise will be resolved with null. Upon failure, the promise will be rejected with an ErrorInfo object.

    Parameters

    Returns Promise<null | ChannelStateChange>

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

    Returns

    A promise which, upon successful attachment to the channel, will be fulfilled with a ChannelStateChange object. If the channel was already attached the promise will be resolved with null. Upon failure, the promise will be rejected with an ErrorInfo object.

    Parameters

    Returns Promise<null | ChannelStateChange>

Generated using TypeDoc