aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Holskil <andreas.holskil@telenor.com>2023-12-12 13:20:21 +0100
committerAndreas Holskil <andreas.holskil@telenor.com>2023-12-12 13:20:21 +0100
commit20d26c3c9d0de263dd1403e392b312e5584d29f3 (patch)
tree655b847e145382470551dd9ef2e9445c3f5ea682
parent6ab19a356d5b90dcd5bab336d1b39953480173b3 (diff)
fix: make sure to start mqtt eventloop before returning
-rw-r--r--src/lib.rs5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 70cf1c2..7445ba5 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -4,7 +4,10 @@ mod eventloop;
mod mqtt;
mod stridulus_event;
mod util;
+use std::time::Duration;
+
use log::{debug, error};
+use tokio::time::sleep;
use tokio::{sync::mpsc, task};
pub use crate::client::StridulusClient;
@@ -43,6 +46,8 @@ pub async fn create(
}
});
+ sleep(Duration::from_millis(10)).await; // to make sure the mqtt eventloop is running
+
Ok((
StridulusClient {
client: mqtt_client,