|
|
|
@ -1,5 +1,6 @@
|
|
|
|
|
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;
|
|
|
|
@ -140,6 +141,15 @@ struct Event {
|
|
|
|
|
divisions: Vec<Division>,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl Event {
|
|
|
|
|
fn from_match_list_response(response: BackendMessage) -> Event {
|
|
|
|
|
Event{
|
|
|
|
|
name: String::from(""),
|
|
|
|
|
divisions: Vec::new(),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct Division {
|
|
|
|
|
name: String,
|
|
|
|
|
matches: Vec<Match>,
|
|
|
|
@ -420,6 +430,9 @@ impl TMClient {
|
|
|
|
|
|
|
|
|
|
fn process(self: &mut TMClient) {
|
|
|
|
|
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() {
|
|
|
|
|
let time = SystemTime::now();
|
|
|
|
|
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() {
|
|
|
|
|
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();
|
|
|
|
|
callbacks.insert(tm::NoticeId::NoticeRealtimeScoreChanged, on_score_change);
|
|
|
|
|
callbacks.insert(tm::NoticeId::NoticeFieldTimerStarted, on_match_start);
|
|
|
|
@ -674,7 +675,7 @@ fn main() {
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
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.instance = 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();
|
|
|
|
|
println!("Get Match List Response: {:?}", get_match_list_resp);
|
|
|
|
|
|
|
|
|
|
let mut event = Event::from_match_list_response(*get_match_list_resp);
|
|
|
|
|
|
|
|
|
|
while running {
|
|
|
|
|
thread::sleep(Duration::from_millis(1000));
|
|
|
|
|
match tm_connection.notices.recv() {
|
|
|
|
|