Skip to content

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

@mendess

Description

@mendess

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions