Package 

Class ChannelBase

    • Method Detail

      • attach

         void attach()

        Attach to this channel ensuring the channel is created in the Ably system and all messages publishedon 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 Presence object for this channel.

        Spec: RTL4d

      • attach

         void attach(CompletionListener listener)

        Attach to this channel ensuring the channel is created in the Ably system and all messages publishedon 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 Presence object for this channel.

        Spec: RTL4d

        Parameters:
        listener - A callback may optionally be passed in to this call to be notified of success or failure of the operation.
      • detach

         void detach()

        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.

        Spec: RTL5e

      • markAsReleased

         void markAsReleased()

        Mark channel as released that means we can't perform any operation on this channel anymore

      • detach

         void detach(CompletionListener listener)

        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.

        Spec: RTL5e

        Parameters:
        listener - A callback may optionally be passed in to this call to be notified of success or failure of the operation.
      • setConnectionFailed

         void setConnectionFailed(ErrorInfo reason)

        If the connection state enters the FAILED state, then an ATTACHINGor ATTACHED channel state will transition to FAILED and set theChannel#errorReason

      • setConnectionClosed

         void setConnectionClosed(ErrorInfo reason)

        (RTL3b) If the connection state enters the CLOSED state, then anATTACHING or ATTACHED channel state will transition to DETACHED.

      • setSuspended

         synchronized void setSuspended(ErrorInfo reason, boolean notifyStateChange)

        (RTL3c) If the connection state enters the SUSPENDED state, then anATTACHING or ATTACHED channel state will transition to SUSPENDED.(RTN15c3) The client library should initiate an attach for channelsthat are in the SUSPENDED state. For all channels in the ATTACHINGor ATTACHED state, the client library should fail any previously queuedmessages for that channel and initiate a new attach.This also gets called when a connection enters CONNECTED but with anon-fatal error for a failed reconnect (RTN16e).

      • setReinitialized

         synchronized void setReinitialized()

        Internal

        (RTN11d) Resets channels back to initialized and clears error reason

      • unsubscribe

         synchronized void unsubscribe()

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

        Spec: RTL8a, RTE5

      • subscribe

         synchronized void subscribe(ChannelBase.MessageListener listener)

        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.

        Spec: RTL7a

        Parameters:
        listener - A listener may optionally be passed in to this call to be notified of success or failureof the channel attach operation.
      • unsubscribe

         synchronized void unsubscribe(ChannelBase.MessageListener listener)

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

        Spec: RTL8a

        Parameters:
        listener - An event listener function.
      • subscribe

         synchronized void subscribe(String name, ChannelBase.MessageListener listener)

        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.

        Spec: RTL7b

        Parameters:
        name - The event name.
        listener - A listener may optionally be passed in to this call to be notified of success or failureof the channel attach operation.
      • unsubscribe

         synchronized void unsubscribe(String name, ChannelBase.MessageListener listener)

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

        Spec: RTL8a

        Parameters:
        name - The event name.
        listener - An event listener function.
      • subscribe

         synchronized void subscribe(Array<String> names, ChannelBase.MessageListener listener)

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

        Spec: RTL7a

        Parameters:
        names - An array of event names.
        listener - A listener may optionally be passed in to this call to be notified of success or failureof the channel attach operation.
      • unsubscribe

         synchronized void unsubscribe(Array<String> names, ChannelBase.MessageListener listener)

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

        Spec: RTL8a

        Parameters:
        names - An array of event names.
        listener - An event listener function.
      • publish

        @NonBlocking() void publish(String name, Object data)

        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.

        Spec: RTL6i

        Parameters:
        name - the event name
        data - the message payload
      • publish

        @NonBlocking() void publish(Message message)

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

        Spec: RTL6i

        Parameters:
        message - A Message object.
      • publish

        @NonBlocking() void publish(Array<Message> messages)

        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.

        Spec: RTL6i

        Parameters:
        messages - An array of Message objects.
      • publish

        @Deprecated()@NonBlocking() void publish(String name, Object data, CompletionListener listener)

        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.

        Spec: RTL6i

        Parameters:
        name - the event name
        data - the message payload
        listener - A listener may optionally be passed in to this call to be notified of success or failure of the operation.
      • publish

        @NonBlocking() void publish(String name, Object data, Callback<PublishResult> callback)

        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.

        Spec: RTL6i

        Parameters:
        name - the event name
        data - the message payload
        callback - A callback may optionally be passed in to this call to be notified of success or failure of the operation,receiving a PublishResult with message serial(s) on success.
      • publish

        @Deprecated()@NonBlocking() void publish(Message message, CompletionListener listener)

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

        Spec: RTL6i

        Parameters:
        message - A Message object.
        listener - A listener may optionally be passed in to this call to be notified of success or failure of the operation.
      • publish

        @NonBlocking() void publish(Message message, Callback<PublishResult> callback)

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

        Spec: RTL6i

        Parameters:
        message - A Message object.
        callback - A callback may optionally be passed in to this call to be notified of success or failure of the operation,receiving a PublishResult with message serial(s) on success.
      • publish

        @Deprecated()@NonBlocking() synchronized void publish(Array<Message> messages, CompletionListener listener)

        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.

        Spec: RTL6i

        Parameters:
        messages - An array of Message objects.
        listener - A listener may optionally be passed in to this call to be notified of success or failure of the operation.
      • getMessage

        @Blocking() Message getMessage(String serial)

        Retrieves the latest version of a specific message by its serial identifier.

        This method allows you to fetch the current state of a message, including any updatesor deletions that have been applied since its creation.

        Parameters:
        serial - The unique serial identifier of the message to retrieve.
      • getMessageAsync

        @NonBlocking() void getMessageAsync(String serial, Callback<Message> callback)

        Asynchronously retrieves the latest version of a specific message by its serial identifier.

        Parameters:
        serial - The unique serial identifier of the message to retrieve.
        callback - A callback to handle the result asynchronously.
      • updateMessage

        @NonBlocking() void updateMessage(Message message)

        Asynchronously updates an existing message.

        Parameters:
        message - A Message object containing the fields to update and the serial identifier.
      • updateMessage

        @NonBlocking() void updateMessage(Message message, MessageOperation operation)

        Asynchronously updates an existing message.

        Parameters:
        message - A Message object containing the fields to update and the serial identifier.
        operation - operation metadata such as clientId, description, or metadata in the version fieldThis callback is invoked on a background thread.
      • updateMessage

        @NonBlocking() void updateMessage(Message message, MessageOperation operation, Callback<UpdateDeleteResult> listener)

        Asynchronously updates an existing message.

        Parameters:
        message - A Message object containing the fields to update and the serial identifier.
        operation - operation metadata such as clientId, description, or metadata in the version field
        listener - A callback to be notified of the outcome of this operation.
      • updateMessage

        @NonBlocking() void updateMessage(Message message, Callback<UpdateDeleteResult> listener)

        Asynchronously updates an existing message.

        Parameters:
        message - A Message object containing the fields to update and the serial identifier.
        listener - A callback to be notified of the outcome of this operation.
      • deleteMessage

        @NonBlocking() void deleteMessage(Message message)

        Asynchronously marks a message as deleted.

        Parameters:
        message - A Message object containing the serial identifier and operation metadata.
      • deleteMessage

        @NonBlocking() void deleteMessage(Message message, MessageOperation operation)

        Asynchronously marks a message as deleted.

        Parameters:
        message - A Message object containing the serial identifier and operation metadata.
        operation - operation metadata such as clientId, description, or metadata in the version fieldThis callback is invoked on a background thread.
      • deleteMessage

        @NonBlocking() void deleteMessage(Message message, MessageOperation operation, Callback<UpdateDeleteResult> listener)

        Asynchronously marks a message as deleted.

        Parameters:
        message - A Message object containing the serial identifier and operation metadata.
        operation - operation metadata such as clientId, description, or metadata in the version field
        listener - A callback to be notified of the outcome of this operation.
      • deleteMessage

        @NonBlocking() void deleteMessage(Message message, Callback<UpdateDeleteResult> callback)

        Asynchronously marks a message as deleted.

        Parameters:
        message - A Message object containing the serial identifier and operation metadata.
        callback - A callback to be notified of the outcome of this operation.
      • appendMessage

        @NonBlocking() void appendMessage(Message message)

        Asynchronously appends message text to the end of the message data.

        Parameters:
        message - A Message object containing the serial identifier and data to append.
      • appendMessage

        @NonBlocking() void appendMessage(Message message, MessageOperation operation)

        Asynchronously appends message text to the end of the message.

        Parameters:
        message - A Message object containing the serial identifier and data to append.
        operation - operation details such as clientId, description, or metadataThis callback is invoked on a background thread.
      • appendMessage

        @NonBlocking() void appendMessage(Message message, MessageOperation operation, Callback<UpdateDeleteResult> listener)

        Asynchronously appends message text to the end of the message.

        Parameters:
        message - A Message object containing the serial identifier and data to append.
        operation - operation details such as clientId, description, or metadata
        listener - A callback to be notified of the outcome of this operation.
      • appendMessage

        @NonBlocking() void appendMessage(Message message, Callback<UpdateDeleteResult> callback)

        Asynchronously appends message text to the end of the message.

        Parameters:
        message - A Message object containing the serial identifier and data to append.
        callback - A callback to be notified of the outcome of this operation.
      • getMessageVersions

        @Blocking() PaginatedResult<Message> getMessageVersions(String serial, Array<Param> params)

        Retrieves all historical versions of a specific message.

        This method returns a paginated result containing all versions of the message,ordered chronologically. Each version includes metadata about when and by whomthe message was modified.

        Parameters:
        serial - The unique serial identifier of the message.
        params - Query parameters for filtering or pagination (e.g., limit, start, end).
      • getMessageVersionsAsync

        @NonBlocking() void getMessageVersionsAsync(String serial, Array<Param> params, Callback<AsyncPaginatedResult<Message>> callback)

        Asynchronously retrieves all historical versions of a specific message.

        Parameters:
        serial - The unique serial identifier of the message.
        params - Query parameters for filtering or pagination.
        callback - A callback to handle the result asynchronously.
      • history

         PaginatedResult<Message> history(Array<Param> params)

        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.

        Spec: RSL2a

        Parameters:
        params - the request params:start (RTL10a) - The time from which messages are retrieved, specified as milliseconds since the Unix epoch.
      • historyAsync

         void historyAsync(Array<Param> params, Callback<AsyncPaginatedResult<Message>> callback)

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

        Spec: RSL2a

        Parameters:
        params - the request params:start (RTL10a) - The time from which messages are retrieved, specified as milliseconds since the Unix epoch.
        callback - Callback with AsyncPaginatedResult object containing an array of Message objects.
      • sendProtocolMessage

         void sendProtocolMessage(ProtocolMessage protocolMessage, CompletionListener listener)

        (Internal) Sends a protocol message and provides a callback for completion.

        Parameters:
        protocolMessage - the protocol message to be sent
        listener - the listener to be notified upon completion of the message delivery