From b0d075bbfd7c992a3a028775ab2f3a42a2c0caef Mon Sep 17 00:00:00 2001 From: Youwen Wu Date: Thu, 7 Mar 2024 12:31:18 -0800 Subject: [PATCH] fix: refactor telemetry to use new method --- client/src-tauri/src/telemetry/mod.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/client/src-tauri/src/telemetry/mod.rs b/client/src-tauri/src/telemetry/mod.rs index 98a597c..c65a87e 100644 --- a/client/src-tauri/src/telemetry/mod.rs +++ b/client/src-tauri/src/telemetry/mod.rs @@ -1,4 +1,4 @@ -use network_tables::v4::MessageData; +use network_tables::v4::{MessageData, Subscription}; use serde_json::to_string; use tauri::{AppHandle, Manager}; mod create_client; @@ -23,7 +23,15 @@ pub async fn subscribe_topics( // I hope this doesn't lead to a catastrophic infinite loop failure let client = create_client(&app_handle, &ntable_ip, &ntable_port).await; - let mut subscription = create_subscription(&client).await; + let mut subscription: Subscription = match create_subscription(&client).await { + Ok(subscription) => subscription, + Err(_) => { + app_handle + .emit_all("telemetry_status", "disconnected") + .expect("Failed to emit telemetry_disconnected event"); + continue; + } + }; while let Some(mut message) = subscription.next().await { process_message(&mut message);