Interface RealtimeChannel

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

Hierarchy

Properties

errorReason: ErrorInfo

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

modes: ChannelMode[]

An array of ChannelMode objects.

name: string

The channel name.

params: ChannelParams

Optional channel parameters that configure the behavior of the channel.

presence: RealtimePresence

A RealtimePresence object.

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 RealtimePresence object for this channel.

    Returns Promise<null | ChannelStateChange>

    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.

  • 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 Promise<void>

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

  • Retrieves a PaginatedResult object, containing an array of historical InboundMessage 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.

    Returns Promise<PaginatedResult<InboundMessage>>

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

  • Removes all registrations that match both the specified listener and the specified event.

    Parameters

    Returns void

  • Deregisters the specified listener. Removes all registrations matching the given listener, regardless of whether they are associated with an event or not.

    Parameters

    Returns void

  • Deregisters all registrations, for all events and listeners.

    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.

    Parameters

    Returns Promise<ChannelStateChange>

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

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

    Returns Promise<ChannelStateChange>

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

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

    Returns Promise<void>

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

  • 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

    Returns Promise<void>

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

  • 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

    Returns Promise<void>

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

  • 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

    Returns Promise<null | ChannelStateChange>

    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.

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

    Parameters

    Returns Promise<null | ChannelStateChange>

    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.

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

    Parameters

    Returns Promise<null | ChannelStateChange>

    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.

  • 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

    Returns Promise<null | ChannelStateChange>

    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.

  • Deregisters the given listener for the specified event name. This removes an earlier event-specific subscription.

    Parameters

    Returns void

  • Deregisters the given listener from all event names in the array.

    Parameters

    Returns void

  • Deregisters all listeners for the given event name.

    Parameters

    • event: string

      The event name.

    Returns void

  • Deregisters all listeners for all event names in the array.

    Parameters

    • events: string[]

      An array of event names.

    Returns void

  • Deregisters all listeners to messages on this channel that match the supplied filter.

    Parameters

    Returns void

  • Deregisters the given listener (for any/all event names). This removes an earlier subscription.

    Parameters

    Returns void

  • Deregisters all listeners to messages on this channel. This removes all earlier subscriptions.

    Returns void

  • If the channel is already in the given state, returns a promise which immediately resolves to null. Else, calls once() to return a promise which resolves the next time the channel transitions to the given state.

    Parameters

    Returns Promise<null | ChannelStateChange>

Generated using TypeDoc