Optional
Readonly
connectionIf there's a connection error it will be available here.
Readonly
connectionProvides the connection status of the Ably connection.
Readonly
deleteA shortcut to the Messages.delete method.
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.
A string or object that conveys the serial of the message to delete.
Optional
deleteMessageParams: DeleteMessageParamsOptional details to record about the delete action.
A promise that resolves when the message was deleted.
Readonly
deleteA shortcut to the MessagesReactions.delete method.
Delete a message reaction
The serial of the message to remove the reaction from.
Optional
params: DeleteMessageReactionParamsThe type of reaction annotation and the specific reaction to remove. The reaction to remove is required for all types except MessageReactionType.Unique.
A promise that resolves when the reaction is deleted.
Readonly
historyA shortcut to the Messages.history method.
Get messages that have been previously sent to the chat room, based on the provided options.
Options for the query.
A promise that resolves with the paginated result of messages. This paginated result can be used to fetch more messages if available.
Optional
Readonly
historyRetrieves the previous messages in the room.
This method is available only if a MessageListener has been provided in the UseMessagesParams. Calling will return a promise that resolves to a paginated response of the previous messages received in the room, up until the listener was attached, in newest-to-oldest order.
It is advised to call this method after any discontinuity event; to retrieve messages that may have been missed before the listener was re-attached.
This is removed when the component unmounts or when the previously provided listener is removed.
Get the previous messages that were sent to the room before the listener was subscribed.
If the client experiences a discontinuity event (i.e. the connection was lost and could not be resumed), the starting point of historyBeforeSubscribe will be reset.
Calls to historyBeforeSubscribe will wait for continuity to be restored before resolving.
Once continuity is restored, the subscription point will be set to the beginning of this new period of continuity. To ensure that no messages are missed, you should call historyBeforeSubscribe after any period of discontinuity to fill any gaps in the message history.
const { historyBeforeSubscribe } = room.messages.subscribe(listener);
await historyBeforeSubscribe({ limit: 10 });
Options for the history query.
A promise that resolves with the paginated result of messages, in newest-to-oldest order.
Optional
Readonly
messagesProvides access to the underlying Messages instance of the room.
Optional
Readonly
roomIf there's an error with the room it will be available here.
Readonly
roomProvides the status of the room.
Readonly
sendA shortcut to the Messages.send method.
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.
an object containing {text, headers, metadata} for the message to be sent. Text is required, metadata and headers are optional.
A promise that resolves when the message was published.
Readonly
sendA shortcut to the MessagesReactions.send method.
Add a message reactions
The serial of the message to react to
Describe the reaction to add.
A promise that resolves when the reaction is added.
Readonly
updateA shortcut to the Messages.update method.
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.
A string or object that conveys the serial of the message to update.
The parameters for updating the message.
Optional
details: OperationDetailsOptional details to record about the update action.
A promise of the updated message.
The response from the useMessages hook.