Skip to content

Commit

Permalink
mqtt: subscribe
Browse files Browse the repository at this point in the history
  • Loading branch information
fooker committed Mar 16, 2024
1 parent d681fa3 commit 28e17a5
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions interface-mqtt/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,18 @@ impl Interface for MQTT<'_> {

for input in introspection.inputs.values() {
let topic = realm.topic(format!("input/{}/set", input.name));
topics.insert(topic, input);

client.subscribe(topic.to_owned(), QoS::AtLeastOnce).await?;
client.subscribe(topic.clone(), QoS::AtLeastOnce).await?;
eprintln!("⇄ Subscribed to '{}' for input '{}' with type {}", topic, input.name, input.value_type);

topics.insert(topic, input);
}

while let Ok(event) = event_loop.poll().await {
match event {
Event::Incoming(Incoming::Connect(_)) => {
for (topic, input) in &topics {
client.subscribe(topic.to_owned(), QoS::AtLeastOnce).await?;
client.subscribe(topic.clone(), QoS::AtLeastOnce).await?;
eprintln!("⇄ Subscribed to '{}' for input '{}' with type {}", topic, input.name, input.value_type);
}
}
Expand Down

0 comments on commit 28e17a5

Please sign in to comment.