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

Receiving a message from the server that requires an ack #461

Open
mendess opened this issue Sep 15, 2024 · 0 comments · May be fixed by #463
Open

Receiving a message from the server that requires an ack #461

mendess opened this issue Sep 15, 2024 · 0 comments · May be fixed by #463

Comments

@mendess
Copy link

mendess commented Sep 15, 2024

I want to send from the socket io server an emit_with_ack event. But I don't see how I can ack from the client

async fn handler(payload: Payload, socket: Client) {
    let values = match payload {
        Payload::Text(values) => values,
        Payload::Binary(_) => panic!("unexpected bytes"),
        #[allow(deprecated)]
        Payload::String(_) => panic!("Payload::String panicked"),
    };

    tracing::info!("got values: {values:?}");
    // how do I ack here?
}

async fn run(config: &Config, hostname: &Hostname) -> anyhow::Result<()> {
    let socket = ClientBuilder::new(format!("{}?h={}", config.backend_domain, hostname))
        .namespace(ws::NS)
        .on(ws::COMMAND, |payload, socket| {
            handler(payload, socket).boxed()
        })
        .on("error", |err, _| {
            async move { tracing::error!(error = ?err, "socket io error") }.boxed()
        })
        .connect()
        .await?;

    std::future::pending::<()>().await;
    socket.disconnect().await?;
    drop(socket);
    Ok(())
}

I've tested and I do get a value in here but I can't ack. Is this just not implemented yet or am I missing something?

@mendess mendess linked a pull request Sep 16, 2024 that will close this issue
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 a pull request may close this issue.

1 participant