metadata field when you send a message.
Send a reply
Use themetadata field of a message to store the reply when you send a message.
You need to at least include the serial of the parent message that you’re replying to. Other information can be included such as a preview of the text:
Ably achieves a global median message delivery latency of 37ms, ensuring replies appear instantly across all participants.
Subscribe to message replies
Message replies will be received as normal messages in the room using thesubscribe() method.
You just need to handle storing and displaying the reply.
Store reply information
When a user replies to a message, extract and store the parent message details:serial:
Display replies
Check incoming messages for replymetadata and display accordingly:
Considerations
Consider the following when implementing message replies:- Older messages may not be available depending on message persistence settings.
- Messages can be updated, potentially removing references to replies.
- The
metadatafield is not server-validated. - Nested replies can be complex and expensive to implement, so consider limiting reply depth.
