rsocket / rsocket-rust

RSocket Rust Implementation using Tokio
Apache License 2.0
209 stars 19 forks source link

How to handle the client actively closing the connection ? #58

Closed panicfrog closed 2 years ago

panicfrog commented 2 years ago

How to handle the client actively closing the connection ?

jjeffcaii commented 2 years ago

You can call on_close when building the client.

panicfrog commented 2 years ago

You can call on_close when building the client.

Thank you for your answer, what I want to know is how does the server know that the client is disconnected. And I still have some questions. First, how does the server actively disconnect from a specific client? Second, how to use authorization?

jjeffcaii commented 2 years ago

Currently, we have no method to handle client disconnection or actively disconnect from an established client, and these features will be added into my to-do list. For the second, you can use SetupPayload to verify incoming client connections, for example:

    RSocketFactory::receive()
        .transport(transport)
        .acceptor(Box::new(|setup, _socket| {
            info!("accept setup: {:?}", setup);
            Ok(Box::new(EchoRSocket))
            // Or you can check the setup, and reject setup
            // Err(From::from("NOT_AUTHORIZATION"))
        }))
        .serve()
        .await