From 574a7ee5c1977d1a8c7bca324fcbd9085433c3eb Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Sun, 20 Feb 2022 20:43:27 -0500 Subject: [PATCH] Sending a command and reading the result. --- src/mpvctl/mpvctl.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/mpvctl/mpvctl.rs b/src/mpvctl/mpvctl.rs index 6671221..cdd165e 100644 --- a/src/mpvctl/mpvctl.rs +++ b/src/mpvctl/mpvctl.rs @@ -93,7 +93,7 @@ impl MpvCtl { &mut self, cmd: Command, ) -> Result, Box> { - let serialized = serde_json::to_string(&cmd)?; + let serialized = serde_json::to_string(&cmd)? + "\n"; println!("Sending {}", serialized); let (response_tx, response_rx) = oneshot::channel::(); match cmd.get_request_id() { @@ -114,7 +114,9 @@ impl MpvCtl { pub async fn get_client_name(&mut self) -> Result<(), Box> { let request_id = self.grab_request_id(); let cmd = Command::new(vec!["client_name".to_string()], Some(request_id)); - self.send_command(cmd).await?; + let cmd_result = self.send_command(cmd).await?; + let result = cmd_result.await?; + println!("Read the following result: {}", result); Ok(()) } }