Update mqtt to use asyncio

This commit is contained in:
QuantumEntangledAndy committed 2023-04-18 20:27:53 +07:00
1 parent 3f4bc510a7
commit 45fec7cfc2
10 files changed
+217 -166

No files matched your search

@@ -101,6 +101,7 @@ impl Discoverer {
let thread_subscriber = subsribers.clone();
set.spawn(async move {
loop {
tokio::task::yield_now().await;
match reader.next().await {
Some(Ok((BcUdp::Discovery(bcudp), addr))) => {
let mut tid = bcudp.tid;
@@ -852,6 +853,7 @@ impl Discoverer {
let mut interval = interval(Duration::from_secs(1));
self.handle.write().await.spawn(async move {
loop {
tokio::task::yield_now().await;
interval.tick().await;
let msg = BcUdp::Discovery(UdpDiscovery {
tid,
@@ -880,6 +882,7 @@ impl Discoverer {
let mut interval = interval(Duration::from_secs(1));
self.handle.write().await.spawn(async move {
loop {
tokio::task::yield_now().await;
interval.tick().await;
let msg = BcUdp::Discovery(UdpDiscovery {
tid,
+1
View File
@@ -216,6 +216,7 @@ impl BcCamera {
let mut sub = connection.subscribe(msg_num).await?;
loop {
tokio::task::yield_now().await;
let msg = sub.recv().await;
let status = match msg {
Ok(motion_msg) => {
+1
View File
@@ -105,6 +105,7 @@ impl BcCamera {
let channel_id = self.channel_id;
let handle = task::spawn(async move {
tokio::task::yield_now().await;
let mut sub_video = connection.subscribe(msg_num).await?;
// On an E1 and swann cameras: