From 6ec61c1bcc4440ae3ba8b917082ed5ebf6f20289 Mon Sep 17 00:00:00 2001 From: Ivan Li Date: Sun, 29 Jan 2023 04:18:57 +0800 Subject: [PATCH] chore: log mqtt error. --- src-tauri/src/core/core.rs | 2 +- src-tauri/src/rpc/mqtt.rs | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src-tauri/src/core/core.rs b/src-tauri/src/core/core.rs index 4817fea..dc747d2 100644 --- a/src-tauri/src/core/core.rs +++ b/src-tauri/src/core/core.rs @@ -221,7 +221,7 @@ impl CoreManager { if let AmbientLightMode::Follow = *lock { drop(lock); let screenshot = picker.take_screenshot()?; - info!("Take Screenshot Spend: {:?}", start.elapsed()); + // info!("Take Screenshot Spend: {:?}", start.elapsed()); match tx.send(screenshot).await { Ok(_) => {} Err(err) => { diff --git a/src-tauri/src/rpc/mqtt.rs b/src-tauri/src/rpc/mqtt.rs index 6be8f9b..a154a84 100644 --- a/src-tauri/src/rpc/mqtt.rs +++ b/src-tauri/src/rpc/mqtt.rs @@ -1,5 +1,5 @@ use rumqttc::{AsyncClient, MqttOptions, QoS}; -use std::{time::Duration}; +use std::time::Duration; use time::{format_description, OffsetDateTime}; use tokio::task; use tracing::warn; @@ -15,8 +15,13 @@ impl MqttConnection { let (client, mut eventloop) = AsyncClient::new(options, 10); task::spawn(async move { - while let Ok(notification) = eventloop.poll().await { - // println!("Received = {:?}", notification); + loop { + match eventloop.poll().await { + Ok(_) => {} + Err(err) => { + println!("MQTT Error Event = {:?}", err); + } + } } }); Self { client } @@ -29,7 +34,8 @@ impl MqttConnection { async fn subscribe_board(&self) { self.client - .subscribe("display-ambient-light/board/#", QoS::AtMostOnce).await; + .subscribe("display-ambient-light/board/#", QoS::AtMostOnce) + .await; } fn broadcast_desktop_online(&mut self) {