Skip to content

Is there a way to share a state/connection ? #99

Answered by Roms1383
Roms1383 asked this question in Q&A
Discussion options

You must be logged in to vote

Well, so big rookie mistakes that costed me hours, here's how it finally compiles:

pub(crate) async fn launch(state: Arc<State>) -> Result<(), anyhow::Error> {
    let uri = "127.0.0.1:8883";
    let state = state.clone();
    let _ = ntex::server::Server::build()
        .bind("mqtt", uri, move |_| {
            let state = state.clone();
            MqttServer::new()
                .v3(
                    v3::MqttServer::new(handshake_v3).publish(fn_factory_with_config(
                        move |_: v3::Session<Session>| {
                            let state = state.clone();
                            ok::<_, crate::error::Error>(fn_service(move |publish: v3::Publish| {

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by Roms1383
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant