From 6f4430a725c0577dc5c981503a8ceceabc4548a7 Mon Sep 17 00:00:00 2001 From: Nickiel12 <35903114+Nickiel12@users.noreply.github.com> Date: Sat, 13 Apr 2024 19:13:34 -0700 Subject: [PATCH] added priority to socket messages --- src/camera_socket.rs | 2 +- src/coordinator.rs | 4 ++-- src/ui_code.rs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/camera_socket.rs b/src/camera_socket.rs index 5b89663..d60caf2 100644 --- a/src/camera_socket.rs +++ b/src/camera_socket.rs @@ -23,7 +23,7 @@ async fn socket_listen( while let Some(msg) = reader.next().await { match msg { Ok(val) => { - if let Err(e) = mec.send(ApplicationEvent::SocketMessage(val)).await { + if let Err(e) = mec.send(ApplicationEvent::SocketMessage(val, 0)).await { error!("There was an error sending to Main Event Channel, closing socket recv thread: {e}"); break; } diff --git a/src/coordinator.rs b/src/coordinator.rs index f4fa116..6d482d5 100644 --- a/src/coordinator.rs +++ b/src/coordinator.rs @@ -20,7 +20,7 @@ pub struct MoveEvent { pub enum ApplicationEvent { StartSocket(String), - SocketMessage(Message), + SocketMessage(Message, u32), MoveEvent(MoveEvent), } @@ -151,7 +151,7 @@ pub async fn start_coordinator( ApplicationEvent::StartSocket(conn) => { state.socket_start(conn).await; } - ApplicationEvent::SocketMessage(socket_message) => { + ApplicationEvent::SocketMessage(socket_message, priority) => { if let Err(e) = state.to_gui.send(GuiUpdate::SocketState(true)).await { error!("Could not send to gui thread! Closing coordinator: {e}"); state.close().await; diff --git a/src/ui_code.rs b/src/ui_code.rs index dcdc74b..4b5c276 100644 --- a/src/ui_code.rs +++ b/src/ui_code.rs @@ -114,7 +114,7 @@ pub fn build_ui(app: &Application, runtime: Handle) { })); button2.connect_clicked(glib::clone!(@strong to_mec => move |_button| { - if let Err(e) = to_mec.try_send(ApplicationEvent::SocketMessage(Message::text("U45:L10"))) { + if let Err(e) = to_mec.try_send(ApplicationEvent::SocketMessage(Message::text("U45:L10"), 1)) { panic!("There was an error in connect clicked: {e}"); } }));