aboutsummaryrefslogtreecommitdiffstats
path: root/mumd/src/command.rs
diff options
context:
space:
mode:
authorEskil Queseth <eskilq@kth.se>2020-10-15 22:09:57 +0200
committerEskil Queseth <eskilq@kth.se>2020-10-15 22:09:57 +0200
commitcfc0ab78a893d6a16d2eedfef290c9e1496a23e1 (patch)
tree0ed06065cb937af22ad48a14d49dd1b0035a90b2 /mumd/src/command.rs
parent01b3c75420ec5bf9083dbcf643d3c6087d4f2ce7 (diff)
downloadmum-cfc0ab78a893d6a16d2eedfef290c9e1496a23e1.tar.gz
add basic error messaging on mumd
Diffstat (limited to 'mumd/src/command.rs')
-rw-r--r--mumd/src/command.rs6
1 files changed, 5 insertions, 1 deletions
diff --git a/mumd/src/command.rs b/mumd/src/command.rs
index 9adf7d8..6314870 100644
--- a/mumd/src/command.rs
+++ b/mumd/src/command.rs
@@ -8,7 +8,7 @@ use tokio::sync::mpsc;
pub async fn handle(
state: Arc<Mutex<State>>,
- mut command_receiver: mpsc::UnboundedReceiver<(Command, IpcSender<Result<Option<CommandResponse>, ()>>)>,
+ mut command_receiver: mpsc::UnboundedReceiver<(Command, IpcSender<mumlib::error::Result<Option<CommandResponse>>>)>,
) {
debug!("Begin listening for commands");
loop {
@@ -16,13 +16,17 @@ pub async fn handle(
let command = command_receiver.recv().await.unwrap();
debug!("Received command {:?}", command.0);
let mut state = state.lock().unwrap();
+ debug!("Got mutex lock");
let (wait_for_connected, command_response) = state.handle_command(command.0).await;
if wait_for_connected {
let mut watcher = state.phase_receiver();
drop(state);
+ debug!("Waiting to be connected");
while !matches!(watcher.recv().await.unwrap(), StatePhase::Connected) {}
}
+ debug!("Sending response");
command.1.send(command_response).unwrap();
+ debug!("Sent response");
}
//TODO err if not connected
//while let Some(command) = command_receiver.recv().await {