Added comment

master
noah metz 2024-01-21 00:24:22 -07:00
parent 5da2fb29c6
commit cb8c57e1b9
1 changed files with 16 additions and 13 deletions

@ -1,5 +1,6 @@
use rumqttc::{MqttOptions, Client, QoS, LastWill}; use rumqttc::{MqttOptions, Client, QoS, LastWill};
use bytes::Bytes; use bytes::Bytes;
use tm::BackendMessageData;
use std::time::Duration; use std::time::Duration;
use std::thread; use std::thread;
use std::collections::hash_map::HashMap; use std::collections::hash_map::HashMap;
@ -140,6 +141,15 @@ struct Event {
divisions: Vec<Division>, divisions: Vec<Division>,
} }
impl Event {
fn from_match_list_response(response: BackendMessage) -> Event {
Event{
name: String::from(""),
divisions: Vec::new(),
}
}
}
struct Division { struct Division {
name: String, name: String,
matches: Vec<Match>, matches: Vec<Match>,
@ -420,6 +430,9 @@ impl TMClient {
fn process(self: &mut TMClient) { fn process(self: &mut TMClient) {
if self.connected == true { if self.connected == true {
// TODO: right now it's halfway to processing multiple requests at once, but currently
// it only processes a single requests/response at a time. This is fine since there's
// only a single callback thread though.
for request in self.requests.try_iter() { for request in self.requests.try_iter() {
let time = SystemTime::now(); let time = SystemTime::now();
let millis = time.duration_since(UNIX_EPOCH).unwrap(); let millis = time.duration_since(UNIX_EPOCH).unwrap();
@ -617,18 +630,6 @@ fn on_match_list_update(notice: tm::Notice, event: Event) -> (Vec<MQTTMessage>,
fn main() { fn main() {
env_logger::init(); env_logger::init();
let mut test = tm::Notice::default();
test.set_id(tm::NoticeId::NoticeRankingsUpdated);
test.set_affected_round(tm::MatchRound::Qual);
let mut div = tm::Division::default();
div.id = Some(1);
test.division = Some(div);
let mut event = Event{
name: String::from(""),
divisions: Vec::new(),
};
let mut callbacks: HashMap<tm::NoticeId, NoticeCallback> = HashMap::new(); let mut callbacks: HashMap<tm::NoticeId, NoticeCallback> = HashMap::new();
callbacks.insert(tm::NoticeId::NoticeRealtimeScoreChanged, on_score_change); callbacks.insert(tm::NoticeId::NoticeRealtimeScoreChanged, on_score_change);
callbacks.insert(tm::NoticeId::NoticeFieldTimerStarted, on_match_start); callbacks.insert(tm::NoticeId::NoticeFieldTimerStarted, on_match_start);
@ -674,7 +675,7 @@ fn main() {
); );
let mut get_match_list_tuple = tm::MatchTuple::default(); let mut get_match_list_tuple = tm::MatchTuple::default();
get_match_list_tuple.division = Some(1); get_match_list_tuple.division = Some(0);
get_match_list_tuple.round = None; get_match_list_tuple.round = None;
get_match_list_tuple.instance = Some(0); get_match_list_tuple.instance = Some(0);
get_match_list_tuple.r#match = Some(0); get_match_list_tuple.r#match = Some(0);
@ -689,6 +690,8 @@ fn main() {
let get_match_list_resp = tm_connection.responses.recv().unwrap(); let get_match_list_resp = tm_connection.responses.recv().unwrap();
println!("Get Match List Response: {:?}", get_match_list_resp); println!("Get Match List Response: {:?}", get_match_list_resp);
let mut event = Event::from_match_list_response(*get_match_list_resp);
while running { while running {
thread::sleep(Duration::from_millis(1000)); thread::sleep(Duration::from_millis(1000));
match tm_connection.notices.recv() { match tm_connection.notices.recv() {