@ably/chat - v0.10.0
    Preparing search index...

    Interface Messages

    This interface is used to interact with messages in a chat room: subscribing to new messages, fetching history, or sending messages.

    Get an instance via Room.messages.

    interface Messages {
        reactions: MessagesReactions;
        delete(
            serial: Serial,
            deleteMessageParams?: DeleteMessageParams,
        ): Promise<Message>;
        history(options: QueryOptions): Promise<PaginatedResult<Message>>;
        send(params: SendMessageParams): Promise<Message>;
        subscribe(listener: MessageListener): MessageSubscriptionResponse;
        update(
            serial: Serial,
            updateParams: UpdateMessageParams,
            details?: OperationDetails,
        ): Promise<Message>;
    }
    Index

    Properties

    Add, delete, and subscribe to message reactions.

    Methods

    • Delete a message in the chat room.

      This method uses the Ably Chat API REST endpoint for deleting messages. It performs a soft delete, meaning the message is marked as deleted.

      Note that the Promise may resolve before OR after the message is deleted from the realtime channel. This means you may see the message that was just deleted in a callback to subscribe before the returned promise resolves.

      NOTE: The Message instance returned by this method is the state of the message as a result of the delete operation. If you have a subscription to message events via subscribe, you should discard the message instance returned by this method and use the event payloads from the subscription instead.

      Should you wish to restore a deleted message, and providing you have the appropriate permissions, you can simply send an update to the original message. Note: This is subject to change in future versions, whereby a new permissions model will be introduced and a deleted message may not be restorable in this way.

      Parameters

      • serial: Serial

        A string or object that conveys the serial of the message to delete.

      • OptionaldeleteMessageParams: DeleteMessageParams

        Optional details to record about the delete action.

      Returns Promise<Message>

      A promise that resolves when the message was deleted.

    • Send a message in the chat room.

      This method uses the Ably Chat API endpoint for sending messages.

      Note that the Promise may resolve before OR after the message is received from the realtime channel. This means you may see the message that was just sent in a callback to subscribe before the returned promise resolves.

      Parameters

      • params: SendMessageParams

        an object containing {text, headers, metadata} for the message to be sent. Text is required, metadata and headers are optional.

      Returns Promise<Message>

      A promise that resolves when the message was published.

    • Update a message in the chat room.

      Note that the Promise may resolve before OR after the updated message is received from the realtime channel. This means you may see the update that was just sent in a callback to subscribe before the returned promise resolves.

      NOTE: The Message instance returned by this method is the state of the message as a result of the update operation. If you have a subscription to message events via subscribe, you should discard the message instance returned by this method and use the event payloads from the subscription instead.

      This method uses PUT-like semantics: if headers and metadata are omitted from the updateParams, then the existing headers and metadata are replaced with the empty objects.

      Parameters

      • serial: Serial

        A string or object that conveys the serial of the message to update.

      • updateParams: UpdateMessageParams

        The parameters for updating the message.

      • Optionaldetails: OperationDetails

        Optional details to record about the update action.

      Returns Promise<Message>

      A promise of the updated message.