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
docs: Add notification inband mode for LiveObjects
Document the new `notification` inband mode for LiveObjects which
notifies clients when objects operations are received without sending
the full state data.
Copy file name to clipboardExpand all lines: src/pages/docs/liveobjects/inband-objects.mdx
+146-9Lines changed: 146 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -37,16 +37,27 @@ If you're using LiveObjects from one of the the following languages, then use th
37
37
38
38
Inband objects works by delivering changes to channel objects as regular channel messages, similar to [inband occupancy](/docs/channels/options#occupancy).
39
39
40
+
There are two inband modes available:
41
+
42
+
| Mode | Description |
43
+
| --- | --- |
44
+
|`objects`| Sends the full state of all objects on the channel. Delivers an initial state snapshot on attach and sends updates whenever an object operation is applied. |
45
+
|`notification`| Sends a notification when an object operation has been received, without the full state data. Clients can then fetch the current state via the REST API. Does not send an initial state on attach. |
To enable inband objects, use the `objects`[channel parameter](/docs/channels/options#objects) when getting a channel:
49
+
To enable inband objects, use the `objects`[channel parameter](/docs/channels/options#objects) when getting a channel. Set the value to either `objects` or `notification` depending on which mode you want to use:
@@ -58,10 +69,10 @@ Clients require the `channel-metadata` [capability](/docs/auth/capabilities) to
58
69
59
70
## Subscribe to updates <aid="inband-objects-subscribe"/>
60
71
61
-
When using inband objects, the client will receive special `[meta]objects` messages whenever the objects on the channel are updated. These messages provide a snapshot of the current set of objects on the channel.
72
+
When using inband objects, the client will receive special `[meta]objects` messages whenever the objects on the channel are updated.
62
73
63
74
<Asidedata-type='note'>
64
-
If there is a high rate of updates to the channel objects the inband messages are throttled. However, the client is guaranteed to receive a sequence of inband messages after the last change occurs so that the latest data is always available.
75
+
If there is a high rate of updates to the channel objects the inband messages are throttled. However in the case of `inband:objects`, the client is guaranteed to receive a sequence of inband messages after the last change occurs so that the latest data is always available.
65
76
</Aside>
66
77
67
78
[Subscribe](/docs/api/realtime-sdk/channels#subscribe) to `[meta]objects` messages like you would any other message on the channel. For convenience, use a message name filter to only receive messages with the name `[meta]objects` in your listener:
@@ -70,15 +81,18 @@ If there is a high rate of updates to the channel objects the inband messages ar
## Message Format <aid="inband-objects-message-format"/>
89
+
## Objects mode <aid="inband-objects-mode"/>
90
+
91
+
The `objects` mode sends the full state of all objects on the channel. When a client attaches to the channel, it immediately receives the current state. Subsequent updates are sent whenever the objects change.
80
92
81
-
Inband objects messages are sent as a sequence of messages, where each message contains a snapshot of a single object on the channel. Taken together, a set of messages belonging to the same sequence describes the complete set of objects on the channel.
93
+
### Message format
94
+
95
+
Inband objects messages in `objects` mode are sent as a sequence of messages, where each message contains a snapshot of a single object on the channel. Taken together, a set of messages belonging to the same sequence describes the complete set of objects on the channel.
82
96
83
97
Each inband objects message has a message `name` of `[meta]objects`.
84
98
@@ -90,4 +104,127 @@ The message `data` is a JSON object with the following top-level properties:
90
104
|`nextCursor`| A cursor for the next message in the sequence, or `undefined` if this is the last message in the sequence. |
91
105
|`object`| A JSON representation of the object included in the message. |
92
106
93
-
The shape of the `object` is the same as the response format of an object when listing them via the [REST API](/docs/liveobjects/rest-api-usage#fetching-objects-list-values).
107
+
The shape of the `object` is the following format:
The `notification` mode notifies clients when an objects operation is received, without sending the full state data. This reduces bandwidth for use cases where clients only need to know that an operation occurred and can fetch the state on demand.
187
+
188
+
Unlike `objects` mode, `notification` mode does not send an initial state when the client attaches to the channel. The first notification is sent immediately when the first object operation is received.
189
+
190
+
### Message format
191
+
192
+
Each notification message has a message `name` of `[meta]objects`.
193
+
194
+
The message `data` is a JSON object with the following property:
195
+
196
+
| Property | Description |
197
+
| --- | --- |
198
+
|`link`| A relative URL path to fetch the current state of the channel object on the channel via the [REST API](/docs/liveobjects/rest-api-usage#fetch-channel-object). This can be used directly with the Ably REST client's [request](/docs/api/rest-sdk#request) method. |
199
+
200
+
### Example
201
+
202
+
<Code>
203
+
```javascript
204
+
// Subscribe to [meta]objects messages in notification mode
0 commit comments