From 82f2d49dc67b225ba9207a51f91ef34d858986f1 Mon Sep 17 00:00:00 2001 From: Tobias Reisinger Date: Thu, 25 Apr 2024 02:12:25 +0200 Subject: [PATCH] Replace the send() with do_send() method the prevent being stuck --- emgauwa-core/src/app_state.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/emgauwa-core/src/app_state.rs b/emgauwa-core/src/app_state.rs index 4fd2765..2441c01 100644 --- a/emgauwa-core/src/app_state.rs +++ b/emgauwa-core/src/app_state.rs @@ -60,7 +60,9 @@ impl Handler for AppState { err ); } - block_on(address.send(ControllerWsAction::Disconnect))??; + // TODO: why does the block_on(send()) version not return? The AppState will be stuck. + //block_on(address.send(ControllerWsAction::Disconnect))??; + address.do_send(ControllerWsAction::Disconnect); } Ok(()) } @@ -84,7 +86,10 @@ impl Handler for AppState { fn handle(&mut self, msg: Action, _ctx: &mut Self::Context) -> Self::Result { log::debug!("Forwarding action: {:?}", msg.action); if let Some((_, address)) = self.connected_controllers.get(&msg.controller_uid) { - block_on(address.send(msg.action))? + // TODO: why does the block_on(send()) version not return? The AppState will be stuck. + //block_on(address.send(msg.action))? + address.do_send(msg.action); + Ok(()) } else { Err(EmgauwaError::Connection(msg.controller_uid)) }