From 156afe9545b9673cb3563fe267ffe2c0d4c1ed4f Mon Sep 17 00:00:00 2001 From: Nickiel12 Date: Thu, 22 Dec 2022 13:22:15 -0800 Subject: [PATCH] fix: No response on play and pause commands --- src/main.rs | 29 +++++++++++++++++++++++++++-- src/message_types.rs | 3 ++- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/src/main.rs b/src/main.rs index 39608be..c9d389b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -122,8 +122,32 @@ fn main() { println!("There was an error decoding the message: {:?}", error) } Ok(req) => match req { - UIRequest::Play => sink.play(), - UIRequest::Pause => sink.pause(), + UIRequest::Play => { + sink.play(); + sockets[i] + .write_message( + serde_json::to_string(&ServerResponse { + message: "Player Resumed".into(), + search_results: vec![], + }) + .unwrap() + .into(), + ) + .unwrap(); + } + UIRequest::Pause => { + sink.pause(); + sockets[i] + .write_message( + serde_json::to_string(&ServerResponse { + message: "Player Paused".into(), + search_results: vec![], + }) + .unwrap() + .into(), + ) + .unwrap(); + } UIRequest::Skip(skip_direction) => todo!(), UIRequest::Search(request) => { println!("got a: {:?}", request); @@ -140,6 +164,7 @@ fn main() { sockets[i] .write_message( serde_json::to_string(&ServerResponse { + message: "Here are the results:".to_string(), search_results: items, }) .unwrap() diff --git a/src/message_types.rs b/src/message_types.rs index d68cb8c..a9d7d9c 100644 --- a/src/message_types.rs +++ b/src/message_types.rs @@ -18,7 +18,7 @@ impl Default for ItemTag { artist: String::new(), album: String::new(), album_artist: String::new(), - } + } } } @@ -75,6 +75,7 @@ impl PartialTag { #[derive(Serialize, Deserialize)] pub struct ServerResponse { + pub message: String, pub search_results: Vec, }