Replace the send() with do_send() method the prevent being stuck

This commit is contained in:
Tobias Reisinger 2024-04-25 02:12:25 +02:00
parent b2e9c6b27a
commit 82f2d49dc6
Signed by: serguzim
GPG key ID: 13AD60C237A28DFE

View file

@ -60,7 +60,9 @@ impl Handler<DisconnectController> 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<Action> 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))
}