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

Add ability to handle events that expect an ack #463

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

mendess
Copy link

@mendess mendess commented Sep 16, 2024

This adds three new methods to the API surface

  • [Raw]Client::ack(AckId, D)
  • ClientBuilder::on_with_ack(Event, callback)
  • ClientBuilder::on_any_with_ack(Event, callback)

using these it's possible to receive messages that require ack and acknowledge them

Fixes #461

@mendess
Copy link
Author

mendess commented Sep 16, 2024

I didn't add any tests because I didn't have the time to do it yet. But I've tested locally with my usecase and it seems to work

Copy link
Collaborator

@ctrlaltf24 ctrlaltf24 left a comment

Choose a reason for hiding this comment

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

suggestion: rename added internal functions to ..._with_awk (rather than having _no_awk variants)

suggestion: add tests so the feature continues to be tested and working

after that it looks good

///
/// let client = ClientBuilder::new("http://localhost:4200/")
/// .namespace("/admin")
/// .on_any(|event, payload, client, ack_id| {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
/// .on_any(|event, payload, client, ack_id| {
/// .on_any_with_ack(|event, payload, client, ack_id| {

@@ -25,7 +25,7 @@ pub struct Packet {
pub packet_type: PacketId,
pub nsp: String,
pub data: Option<String>,
pub id: Option<i32>,
pub id: Option<AckId>,
Copy link
Collaborator

Choose a reason for hiding this comment

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

While I'm generally a fan of wrapper types, it's not worth the breaking API change.

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.

Receiving a message from the server that requires an ack
2 participants