diff --git a/src/main.rs b/src/main.rs index be49e84..a9b968a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,5 @@ use rumqttc::{MqttOptions, Client, QoS, LastWill}; use bytes::Bytes; -use tm::BackendMessageData; use std::time::Duration; use std::thread; use std::collections::hash_map::HashMap; @@ -157,19 +156,18 @@ struct MQTTMessage { #[derive(Debug)] struct Event { - name: String, divisions: HashMap, } impl Event { - fn new(name: String) -> Event { + fn new() -> Event { Event{ - name, divisions: HashMap::new(), } } - fn parse_match_list(self: &mut Event, msg: BackendMessage) { + fn recreate_match_list(self: &mut Event, msg: BackendMessage) { + self.divisions = HashMap::new(); match msg.data.match_list { Some(matches) => { for m in matches.matches.iter() { @@ -725,11 +723,6 @@ fn main() { } ); - let get_event_name_req = BackendMessage::new(101, tm::BackendMessageData::default()); - tm_connection.requests.send(Box::new(get_event_name_req)).unwrap(); - let get_event_name_resp = tm_connection.responses.recv().unwrap(); - - let mut event = Event::new(String::from(get_event_name_resp.data.event_config.unwrap().event_name.unwrap())); let mut get_match_list_tuple = tm::MatchTuple::default(); get_match_list_tuple.division = Some(0); get_match_list_tuple.round = None; @@ -745,7 +738,8 @@ fn main() { let get_match_list_resp = tm_connection.responses.recv().unwrap(); - event.parse_match_list(*get_match_list_resp); + let mut event = Event::new(); + event.recreate_match_list(*get_match_list_resp); println!("Event after parse: {:?}", event); while running {