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(radar): subscribe to spokes only while displaying the radar (#3019)
* docs(radar): subscribe to spokes only while displaying the radar
A provider treats spoke subscribers as the measure of whether anyone is
watching a radar and may let an unwatched one stand down. Spell out that
clients open the stream only while showing the radar, and that a relaying
provider holds its upstream subscription only while it has subscribers of
its own, using binaryStreamManager.getClientCount.
Co-Authored-By: Claude Code <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015VvpP3eXB2WhgD8bwyDWoU
* docs(radar): show the spoke socket being closed, name the stream id
* docs(radar): fix the connection example introduction
---------
Co-authored-by: Claude Code <noreply@anthropic.com>
2.**Controls** — schema for each control (type, valid values, modes, read-only status)
85
85
86
+
A provider also treats the spoke stream's subscribers as the measure of whether anyone is
87
+
watching a radar, and may let an unwatched radar stand down. A plugin that relays spokes from
88
+
another provider — a proxy in front of mayara-server, say — must therefore hold its own
89
+
upstream subscription only while it has subscribers of its own; see
90
+
[Subscribe only while displaying](#subscribe-only-while-displaying).
91
+
86
92
## Control Categories
87
93
88
94
| Category | Description | Examples |
@@ -994,7 +1000,9 @@ The URL is constructed by convention from the host serving the radar list:
994
1000
995
1001
### Connection Logic
996
1002
997
-
This a Javascript example how to set up the connection to receive spokes:
1003
+
This is a JavaScript example of how to set up the connection to receive spokes. It returns the
1004
+
socket so the caller can close it when the radar is no longer displayed (see
1005
+
[Subscribe only while displaying](#subscribe-only-while-displaying)):
998
1006
999
1007
```javascript
1000
1008
asyncfunctionconnectToSpokes() {
@@ -1019,9 +1027,35 @@ async function connectToSpokes() {
1019
1027
constspokeData=newUint8Array(event.data)
1020
1028
// Process binary spoke data...
1021
1029
}
1030
+
return socket
1022
1031
}
1032
+
1033
+
// When the radar view is hidden or unmounted:
1034
+
// socket.close()
1023
1035
```
1024
1036
1037
+
### Subscribe only while displaying
1038
+
1039
+
An open spoke stream tells the provider that someone is watching the radar. A provider may
1040
+
use that to stop holding an unwatched radar up: mayara-server, for instance, lets a radar
1041
+
stand down once nobody has subscribed to its spokes for the period set by its `autoStandby`
1042
+
control (a minute by default), so that a headless installation does not keep the magnetron
1043
+
transmitting for nobody. Control PUTs and REST reads do not count as watching — only the
1044
+
spoke stream does.
1045
+
1046
+
So a client must open the spoke stream only while it is actually displaying the radar, and
1047
+
close it as soon as it stops — when the radar view is hidden, not merely when the page is
1048
+
closed. A subscription held open "just in case" keeps the radar transmitting.
1049
+
1050
+
The same rule applies one level up. A provider plugin that relays spokes from another
1051
+
source (the mayara-server plugin, or an app-specific bridge such as an ORCA emulator)
1052
+
must hold its upstream subscription only while it has subscribers itself, and close it
1053
+
when the last one leaves. On the server side `app.binaryStreamManager.getClientCount(streamId)`,
1054
+
with `streamId` being `` `radars/${radarId}` ``, gives the number of clients currently
1055
+
subscribed to that radar's spoke stream, so a relay can connect on the first subscriber and
1056
+
disconnect after the last. A relay that stays subscribed around the clock hides every
1057
+
downstream client from the provider, and the radar never stands down.
1058
+
1025
1059
### Spoke content and the legend
1026
1060
1027
1061
Every spoke contains `spoke_len` bytes. The radar API always uses one byte per pixel, with every byte representing a value explained by the `legend` contained in the capabilities.
0 commit comments