docs(dev): websocket wire doc rewritten from source; endpoint doc ping claim fixed
The Feb-era 700-line page documented client->server JSON messages the
server never acted on (handleMessage logs only), a wrong ping/pong
exchange, and missed every message type added since. Rewritten tight
(~100 lines), every claim pinned: dual auth (JWT ?token= or device
Bearer header), initial_state on connect under the connecting
identity's RLS scope, the full 12-type message catalog (including
collection_updated, found per-user-targeted in the collections handler
and defined as a raw string outside the sync constants), WS-frame
keepalive (30s server ping, 90s read deadline — browsers answer
automatically), and the backpressure contract clients must honor:
bounded per-connection queues skip messages when full, so the socket
is a hint and REST refetch + fresh initial_state is the gap-healer.
Fan-out documented precisely: sync/scan events instance-wide,
collection events per-user.
Also corrected the gated endpoint doc (api/websocket/protocol.md):
its 'client sends {type:ping}, server responds pong' section
contradicted the handler; replaced with the true keepalive story.
Route pin untouched — the drift gates stay green.
This commit is contained in:
1 parent
8a40349fa1
commit
e40be80e78
2 files changed
+82
-692
No files matched your search
@@ -24,15 +24,16 @@ All messages are JSON objects with a `type` field.
|
||||
|
||||
### Client → Server Messages
|
||||
|
||||
#### Ping (Heartbeat)
|
||||
None are interpreted. The socket is a one-directional push feed — the
|
||||
server logs (but ignores) anything a client sends. All reads and writes
|
||||
go through the REST API.
|
||||
|
||||
```json
|
||||
{
|
||||
"type": "ping"
|
||||
}
|
||||
```
|
||||
#### Keepalive
|
||||
|
||||
Keep connection alive. Server responds with `pong`.
|
||||
The server sends a WebSocket **ping frame every 30 seconds**; a
|
||||
connection that misses pongs for 90 seconds is removed. Standard
|
||||
WebSocket clients (browsers included) answer pongs automatically —
|
||||
there is nothing to implement.
|
||||
|
||||
### Server → Client Messages
|
||||
|
||||
|
||||
Reference in new issue
Block a user