fix compile errors

This commit is contained in:
2026-03-15 04:57:03 +00:00
Unverified
parent adc013db18
commit 511a104e12
4 changed files with 23 additions and 7 deletions

View File

@@ -1,6 +1,6 @@
use std::{collections::HashMap, net::SocketAddr, sync::Arc}; use std::{collections::HashMap, net::SocketAddr, sync::Arc};
use rand::Rng; use rand::RngExt;
use tokio::sync::{ use tokio::sync::{
mpsc::{error::SendError, UnboundedSender}, mpsc::{error::SendError, UnboundedSender},
RwLock, RwLock,

View File

@@ -49,7 +49,7 @@ async fn handle_connection(
let ws_stream = accept_async(stream).await?; let ws_stream = accept_async(stream).await?;
let (mut ws_sender, mut ws_receiver) = ws_stream.split(); let (mut ws_sender, mut ws_receiver) = ws_stream.split();
let (tx, mut rx) = tokio::sync::mpsc::unbounded_channel(); let (tx, mut rx) = tokio::sync::mpsc::unbounded_channel::<Message>();
// Spawn task to handle outgoing messages // Spawn task to handle outgoing messages
let send_task = tokio::spawn(async move { let send_task = tokio::spawn(async move {
@@ -262,7 +262,15 @@ async fn handle_connection(
let player1_username = usernames[0].to_string(); let player1_username = usernames[0].to_string();
let player2_username = usernames[1].to_string(); let player2_username = usernames[1].to_string();
if let Err(e) = sd.handle_reservation_add(tx.clone(), addr, player1_username, player2_username).await { if let Err(e) = sd
.handle_reservation_add(
tx.clone(),
addr,
player1_username,
player2_username,
)
.await
{
error!("handle_reservation_add: {}", e); error!("handle_reservation_add: {}", e);
let _ = send(&tx, e.to_string().as_str()); let _ = send(&tx, e.to_string().as_str());
} }
@@ -277,7 +285,15 @@ async fn handle_connection(
let player1_username = usernames[0].to_string(); let player1_username = usernames[0].to_string();
let player2_username = usernames[1].to_string(); let player2_username = usernames[1].to_string();
if let Err(e) = sd.handle_reservation_delete(tx.clone(), addr, player1_username, player2_username).await { if let Err(e) = sd
.handle_reservation_delete(
tx.clone(),
addr,
player1_username,
player2_username,
)
.await
{
error!("handle_reservation_delete: {}", e); error!("handle_reservation_delete: {}", e);
let _ = send(&tx, e.to_string().as_str()); let _ = send(&tx, e.to_string().as_str());
} }

View File

@@ -1,4 +1,5 @@
use anyhow::anyhow; use anyhow::anyhow;
use rand::RngExt;
use std::time::Instant; use std::time::Instant;
use crate::{tournaments::*, types::*, *}; use crate::{tournaments::*, types::*, *};
@@ -1227,8 +1228,7 @@ impl Server {
timeout_thread.abort(); timeout_thread.abort();
} }
self.broadcast_message_all_observers(&format!("GAME:{}:TERMINATED", match_id)) self.broadcast_message_all_observers(&format!("GAME:{}:TERMINATED", match_id)).await;
.await;
let clients_guard = self.clients.read().await; let clients_guard = self.clients.read().await;
if the_match.player1 != SERVER_PLAYER_ADDR.to_string().parse().unwrap() { if the_match.player1 != SERVER_PLAYER_ADDR.to_string().parse().unwrap() {

View File

@@ -1,4 +1,4 @@
use rand::Rng; use rand::RngExt;
use std::net::SocketAddr; use std::net::SocketAddr;
use std::time::Instant; use std::time::Instant;
use std::{ops, vec}; use std::{ops, vec};