Sending a command and reading the result.
This commit is contained in:
parent
3732f04c36
commit
574a7ee5c1
@ -93,7 +93,7 @@ impl MpvCtl {
|
|||||||
&mut self,
|
&mut self,
|
||||||
cmd: Command,
|
cmd: Command,
|
||||||
) -> Result<oneshot::Receiver<serde_json::Value>, Box<dyn std::error::Error>> {
|
) -> Result<oneshot::Receiver<serde_json::Value>, Box<dyn std::error::Error>> {
|
||||||
let serialized = serde_json::to_string(&cmd)?;
|
let serialized = serde_json::to_string(&cmd)? + "\n";
|
||||||
println!("Sending {}", serialized);
|
println!("Sending {}", serialized);
|
||||||
let (response_tx, response_rx) = oneshot::channel::<serde_json::Value>();
|
let (response_tx, response_rx) = oneshot::channel::<serde_json::Value>();
|
||||||
match cmd.get_request_id() {
|
match cmd.get_request_id() {
|
||||||
@ -114,7 +114,9 @@ impl MpvCtl {
|
|||||||
pub async fn get_client_name(&mut self) -> Result<(), Box<dyn std::error::Error>> {
|
pub async fn get_client_name(&mut self) -> Result<(), Box<dyn std::error::Error>> {
|
||||||
let request_id = self.grab_request_id();
|
let request_id = self.grab_request_id();
|
||||||
let cmd = Command::new(vec!["client_name".to_string()], Some(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(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user