You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/chat/rooms/messages.textile
+76-2
Original file line number
Diff line number
Diff line change
@@ -80,14 +80,14 @@ The following are the properties of a message:
80
80
81
81
|_. Property |_. Description |_. Type |
82
82
| serial | An Ably-generated ID used to uniquely identify the message. By comparing it to others it provides a deterministic global ordering of messages. | String |
83
+
| version | An Ably-generated ID used to uniquely identify the version of the message. It provides a deterministic global ordering of message versions. The @version@ is identical to @serial@ if the action is @message.create@. | String |
84
+
| action | The latest action performed on this message, such as @message.create@, @message.update@ or @message.delete@. | String |
83
85
| clientId | The client identifier of the user that created the message. | String |
84
86
| roomId | The name of the room the message was created in. | String |
85
87
| text | The message contents. | String |
86
88
| headers | Optional headers for adding additional information to a message, such as the relative timestamp of a livestream video, or flagging a message as important. Do not use the headers for authoritative information. There is no server-side validation. When reading headers treat them like user input. | Object |
87
89
| metadata | Optional additional metadata about the message, such as animations, effects or links to other resources such as images. This information is not read by Ably. Do not use metadata for authoritative information. There is no server-side validation. When reading metadata treat it like user input. | Object |
88
90
| createdAt | The time the message was created. | Date |
89
-
| action | The latest action performed on this message, such as @message.create@, @message.update@ or @message.delete@. | String |
90
-
| version | An Ably-generated ID used to uniquely identify the version of the message. It provides a deterministic global ordering of message versions. The @version@ is identical to @serial@ if the action is @message.create@. | String |
91
91
| timestamp | The time the action was performed. It will be identical to @createdAt@ if the action is a @message.create@. | Date |
92
92
| operation | For updates and deletions, this provides additional details about the action. It may contain the following properties: | Object or undefined |
93
93
| | clientId: The client identifier of the user associated with the action. | String or undefined |
@@ -570,3 +570,77 @@ Applying an action to a message produces a new version, which is uniquely identi
570
570
The @Message@ object also has convenience methods "@isOlderVersionOf@":https://sdk.ably.com/builds/ably/ably-chat-js/main/typedoc/interfaces/chat-js.Message.html#isolderversionof, "@isNewerVersionOf@":https://sdk.ably.com/builds/ably/ably-chat-js/main/typedoc/interfaces/chat-js.Message.html#isnewerversionof and "@isSameVersionAs@":https://sdk.ably.com/builds/ably/ably-chat-js/main/typedoc/interfaces/chat-js.Message.html#issameversionas which provide the same comparison.
571
571
572
572
Update and Delete events provide the full message payload, so may be used to replace the entire earlier version of the message.
573
+
574
+
h2(#keep-messages-updated). Keep messages updated using @with()@
575
+
576
+
The "@Message@":https://sdk.ably.com/builds/ably/ably-chat-js/main/typedoc/interfaces/chat-js.Message.html object has a convenience method "@with@":https://sdk.ably.com/builds/ably/ably-chat-js/main/typedoc/interfaces/chat-js.Message.html#with that takes a "@MessageEvent@":https://sdk.ably.com/builds/ably/ably-chat-js/main/typedoc/interfaces/chat-js.MessageEvent.html, automatically compares versions, and returns the newest @Message@ instance. If @with@ is called with an event that is older than the message, the message is returned. If it is called with a newer event, the message from the event is returned. This can be used to ensure that the latest version of a message is always obtained without manually comparing versions.
577
+
578
+
579
+
Example usage to keep a list of messages updated:
580
+
581
+
```[javascript]
582
+
import { MessageEvents, Message } from '@ably/chat';
0 commit comments