bazzar/crates/payment_manager/src/mqtt.rs

31 lines
914 B
Rust

use config::SharedAppConfig;
use rumqttc::{Event, Incoming};
use crate::Modules;
pub async fn start(config: SharedAppConfig, _modules: Modules) -> channels::AsyncClient {
let (client, mut event_loop) = channels::payments::mqtt::create_client(config);
let spawn_client = client.clone();
tokio::spawn(async move {
let _client = spawn_client.clone();
loop {
let notification = event_loop.poll().await;
match notification {
Ok(Event::Incoming(Incoming::Publish(publish))) => match publish.topic.as_str() {
_ => {}
},
Ok(Event::Incoming(_incoming)) => {}
Ok(Event::Outgoing(_outgoing)) => {}
Err(e) => {
tracing::warn!("{}", e);
}
}
}
// tracing::info!("Mqtt channel closed");
});
client
}