Skip to content

Commit 531980e

Browse files
committed
Address PR review: fix Spaces link and clarify differential token capabilities
- Drop trailing slash on /docs/spaces link in echo channel option page - Rewrite "differential token capabilities on a single channel" example to actually use a single channel, split across publisher/subscriber tokens
1 parent 28eec20 commit 531980e

2 files changed

Lines changed: 16 additions & 5 deletions

File tree

src/pages/docs/channels/options/echo.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Echo
33
meta_description: "The echo channel option enables per-channel control over whether a client receives its own published messages."
44
---
55

6-
By default, clients receive their own messages when subscribed to a channel they publish on. This is useful in many applications because it means every subscriber, including the publisher, renders state from the same stream of messages. For example, in a [chat application](/docs/chat) or [collaborative editor](/docs/spaces/), a client can publish a message and then update its UI only when that message arrives back on the channel, guaranteeing that all participants see the same ordering and state.
6+
By default, clients receive their own messages when subscribed to a channel they publish on. This is useful in many applications because it means every subscriber, including the publisher, renders state from the same stream of messages. For example, in a [chat application](/docs/chat) or [collaborative editor](/docs/spaces), a client can publish a message and then update its UI only when that message arrives back on the channel, guaranteeing that all participants see the same ordering and state.
77

88
However, this is not always desirable. A client streaming pricing updates, publishing telemetry data, or sending tokens via [AI Transport](/docs/ai-transport) does not need to hear its own messages echoed back. Suppressing echo on these channels reduces unnecessary bandwidth and message processing.
99

src/pages/docs/presence-occupancy/presence.mdx

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -661,18 +661,29 @@ For servers:
661661
```
662662
</Code>
663663

664-
Another approach is to use differential token capabilities on a single channel. The following example shows capabilities where clients can enter presence and publish, but only have subscribe access to regular messages:
664+
A second approach is to split capabilities across two tokens for the same channel. A publisher-role token grants only `publish` and `presence`, so clients using it can enter the presence set and publish messages, but receive nothing back because they lack `subscribe`. A subscriber-role token grants `subscribe` (and `history` if needed) so other clients can read the channel.
665+
666+
Publisher token:
667+
668+
<Code>
669+
```json
670+
{
671+
"my-channel": ["publish", "presence"]
672+
}
673+
```
674+
</Code>
675+
676+
Subscriber token:
665677

666678
<Code>
667679
```json
668680
{
669-
"presenceChannel": ["publish", "presence"],
670-
"my-channel": ["presence", "history", "subscribe"]
681+
"my-channel": ["history", "subscribe"]
671682
}
672683
```
673684
</Code>
674685

675-
Alternatively, [channel mode flags](/docs/channels/options#modes) can be used to enable clients to be present on a channel without subscribing to presence events. This also enables clients to still subscribe to regular messages on the channel.
686+
The `subscribe` capability covers both regular messages and presence state-change messages, so it cannot be used to receive one without the other. To let a single client subscribe to regular messages on a channel while still being present without receiving presence events, use [channel mode flags](/docs/channels/options#modes) instead.
676687

677688
## External presence set maintenance <a id="external-maintenance"/>
678689

0 commit comments

Comments
 (0)