D AGENTS.md: channel membership, client events, refused connections
New section 10 for consumers that override Websocket\Handler or write a client: a socket joins only through a (signed) subscribe, the auth step cannot add members, client events need membership and stop there, refused connections close with 4001/4009/1011, and AppManager::findByKey() must return a settled promise. The source map moves to section 11. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
95d6af38cc
commit
0ce00227a4
27
AGENTS.md
27
AGENTS.md
|
|
@ -326,7 +326,32 @@ migrated to real queued **Jobs** (which also get retry semantics + show up in to
|
|||
|
||||
---
|
||||
|
||||
## 10. Source map (read these, not your memory)
|
||||
## 10. Channel membership, client events, refused connections
|
||||
|
||||
Rules for anyone overriding `Websocket\Handler` (a consumer's `App\Websocket\Handler`) or
|
||||
writing a client. All in `src/Websocket/Handler.php`.
|
||||
|
||||
- **A socket joins a channel only through a subscribe.** `private-*` (incl.
|
||||
`private-encrypted-*`) and `presence-*` need a valid `auth` signature; a bad one gets
|
||||
`<event>:error` `{message: "Invalid Signature", code: 4009}` and the socket stays off the
|
||||
channel. A Success reply names the channel: `{event: "<event>:response", channel, data}`.
|
||||
- **`authenticateConnection()` cannot add members.** `processFullMessage()` takes the socket
|
||||
off the channel again if the auth step (or your override calling `saveConnection()`) put it
|
||||
on a channel it was not on. Your override still receives the frame's channel, so
|
||||
`$channel->saveConnection()` stays safe to call; it only refreshes an existing member. On
|
||||
`onClose()` the channel is `null`: null-check it.
|
||||
- **Client events (`client-*`)** need `enable_client_messages` and a sender that is on the
|
||||
channel. A non-member gets `<event>:error` "Subscription not established". Either way the
|
||||
frame ends there and never reaches a controller.
|
||||
- **Refused connections are closed** with the code from the `websocket.error` frame: 4001
|
||||
unknown app key, 4009 origin not allowed, 1011 anything else that failed in `onOpen`.
|
||||
Clients should not reconnect on 4000-4099.
|
||||
- **A custom `AppManager::findByKey()` must return an already settled promise.** The handler
|
||||
reads it inside `onOpen` on the event loop; a pending promise refuses the connection (1011).
|
||||
|
||||
---
|
||||
|
||||
## 11. Source map (read these, not your memory)
|
||||
|
||||
| Concern | File |
|
||||
|---------|------|
|
||||
|
|
|
|||
Loading…
Reference in New Issue