feat: update spec for GAME:TERMINATE

This commit is contained in:
2025-12-04 21:53:13 -05:00
Unverified
parent cdf90ee2cb
commit bd1f2d414d

View File

@@ -639,18 +639,21 @@ async fn handle_connection(
continue; continue;
} }
let match_id_request = get_current_watching_match(&matches, addr).await; let match_id_parse = text.split(":").collect::<Vec<&str>>()[2].parse::<u32>();
if match_id_parse.is_err() { let _ = send(&tx, "ERROR:INVALID:TERMINATE"); continue; }
match match_id_request {
Some(match_id) => {
let match_guard = matches.read().await; let match_guard = matches.read().await;
let the_match = match_guard.get(&match_id).unwrap().read().await; let match_id_request = match_guard.get(&match_id_parse.clone()?).unwrap();
let the_match = match_id_request.read().await;
if let Some(wait_thread) = &the_match.wait_thread { if let Some(wait_thread) = &the_match.wait_thread {
wait_thread.abort(); wait_thread.abort();
} }
let player1_addr = the_match.player1; let player1_addr = the_match.player1;
let player2_addr = the_match.player2; let player2_addr = the_match.player2;
broadcast_message(&the_match.viewers, &observers, "GAME:TERMINATED").await; broadcast_message(&the_match.viewers, &observers, "GAME:TERMINATED").await;
drop(the_match); drop(the_match);
drop(match_guard); drop(match_guard);
@@ -670,12 +673,7 @@ async fn handle_connection(
drop(clients_guard); drop(clients_guard);
matches.write().await.remove(&match_id); matches.write().await.remove(&match_id_parse?);
},
None => {
let _ = send(&tx, "ERROR:INVALID:TERMINATE");
}
}
} }
else if text == "TOURNAMENT:START" { else if text == "TOURNAMENT:START" {