-
Notifications
You must be signed in to change notification settings - Fork 0
docs: Disconnected event now carries a DisconnectReason #365
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
9439dc0
e788e12
214baf7
fd64032
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -227,17 +227,26 @@ Event::Connected(_) => { | |
|
|
||
| ### Disconnected | ||
|
|
||
| **Emitted:** When connection is lost | ||
| **Emitted:** When the connection ends without the client itself intentionally closing or reconnecting it — covers both a routine server-initiated stream recycle and a genuine transport failure (see `reason` below to tell them apart) | ||
|
|
||
| ```rust | ||
| #[derive(Debug, Clone, Serialize)] | ||
| pub struct Disconnected; | ||
| pub struct Disconnected { | ||
| pub reason: DisconnectReason, | ||
| } | ||
|
|
||
| Event::Disconnected(Disconnected) | ||
| Event::Disconnected(Disconnected { reason }) | ||
| ``` | ||
|
|
||
| **Fields:** | ||
| - `reason: DisconnectReason` — why the transport ended. Check `reason.is_clean_shutdown()` to tell a routine server-initiated stream recycle (WhatsApp's normal reconnect path) apart from a genuine transport failure, without parsing logs. See [`DisconnectReason`](/api/transport#disconnected) for the variants. | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The text directs users to call Prompt To Fix With AIThis is a comment left during a code review.
Path: concepts/events.mdx
Line: 242
Comment:
`is_clean_shutdown()` not documented in the linked `DisconnectReason` reference
The text directs users to call `reason.is_clean_shutdown()`, then links them to `/api/transport#disconnected` for the variants. However, `api/transport.mdx` only documents the four enum variants (`ServerClose`, `StreamEnded`, `ReadError`, `Unknown`) — there is no helper-methods section and no mention of `is_clean_shutdown()` anywhere in the file. A developer following the link will find the variants but no explanation of which variant(s) the method considers a clean shutdown, or that the method exists at all. The helper should be documented in `api/transport.mdx` alongside the enum definition.
How can I resolve this? If you propose a fix, please make it concise. |
||
|
|
||
| **Behavior:** Client automatically attempts reconnection | ||
|
|
||
| <Note> | ||
| Breaking change: `Disconnected` gained the `reason` field (previously a unit struct). Update `Event::Disconnected(Disconnected)` patterns to `Event::Disconnected(Disconnected { reason })` or `Event::Disconnected(_)`. | ||
| </Note> | ||
|
|
||
| ### ConnectFailure | ||
|
|
||
| **Emitted:** When connection fails with a specific reason | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.