fix compile errors
This commit is contained in:
@@ -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,
|
||||||
|
|||||||
22
src/main.rs
22
src/main.rs
@@ -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());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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() {
|
||||||
|
|||||||
@@ -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};
|
||||||
|
|||||||
Reference in New Issue
Block a user