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, }