Skip to content
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

fix(client): support notifications with no params #1436

Merged
merged 1 commit into from
Aug 1, 2024
Merged

Conversation

niklasad1
Copy link
Member

@niklasad1 niklasad1 commented Aug 1, 2024

Close #1435

Technically notifications can omit the params field according to JSON-RPC spec which this fixes.
However, it's quite weird to emit notifications without data in them in such scenarios we just push null to the notification handler.

In contrary, subscriptions requires params field where the subscription ID is sent in every message and that's why I didn't change the notification type i.e, just a type alias Notification<'a, Option<serde_json::Value>>

@niklasad1 niklasad1 requested a review from a team as a code owner August 1, 2024 12:17
Copy link

@Jomik Jomik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great.
Use case for me is listening to state on my 3d printer.
https://moonraker.readthedocs.io/en/latest/web_api/#klippy-disconnected

It could have been implemented as a single method with a state enum, but they chose to implement multiple notifications, one for each state.

@niklasad1
Copy link
Member Author

Aight, I see thanks for the explanation

@niklasad1 niklasad1 changed the title fix(client): parse notification without params fix(client): support notification no params Aug 1, 2024
@niklasad1 niklasad1 changed the title fix(client): support notification no params fix(client): support notifications with no params Aug 1, 2024
@niklasad1 niklasad1 merged commit 6c29395 into master Aug 1, 2024
11 checks passed
@niklasad1 niklasad1 deleted the na-fix-1435 branch August 1, 2024 15:33
@Jomik
Copy link

Jomik commented Aug 2, 2024

Do you have an estimate of when you will create a release with this fix? It is currently interferring with my progress 😅

@niklasad1
Copy link
Member Author

I'll release it today

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unparseable notification
4 participants