diff --git a/server/src/game_handler.rs b/server/src/game_handler.rs index c6b2b5e..2673b29 100644 --- a/server/src/game_handler.rs +++ b/server/src/game_handler.rs @@ -393,6 +393,10 @@ impl GameHandler { let tx = self.state.broadcast_tx.clone(); let active_games = self.games.len(); let msg = to_string(&ServerActiveGames { active_games }).unwrap(); - tokio::spawn(async move { tx.send(msg) }); + tokio::spawn(async move { + if let Err(e) = tx.send(msg) { + tracing::error!("Error broadcasting game count: {}", e); + } + }); } } diff --git a/server/src/main.rs b/server/src/main.rs index e674bd3..ff764ab 100644 --- a/server/src/main.rs +++ b/server/src/main.rs @@ -18,8 +18,8 @@ use tower_http::{compression::CompressionLayer, services::ServeDir}; use tracing_subscriber::prelude::*; use user_handler::UserHandler; -#[tokio::main(flavor = "current_thread")] -// #[tokio::main] +// #[tokio::main(flavor = "current_thread")] +#[tokio::main] async fn main() -> Result<()> { // stuff for logging tracing_subscriber::registry() @@ -29,7 +29,7 @@ async fn main() -> Result<()> { // "server=trace,tower_http=trace,lib=trace,tokio=trace,runtime=trace".into() }), ) - // .with(console_subscriber::ConsoleLayer::builder().spawn()) + .with(console_subscriber::ConsoleLayer::builder().spawn()) .with(tracing_subscriber::fmt::layer()) .init(); @@ -68,10 +68,10 @@ async fn main() -> Result<()> { }); // Set up state - let (broadcast_tx, _rx) = broadcast::channel(1000000); - let (users_tx, mut users_rx) = mpsc::channel(1000000); - let (messages_tx, mut messages_rx) = mpsc::channel(1000000); - let (games_tx, mut games_rx) = mpsc::channel(1000000); + let (broadcast_tx, _rx) = broadcast::channel(1000); + let (users_tx, mut users_rx) = mpsc::channel(1000); + let (messages_tx, mut messages_rx) = mpsc::channel(1000); + let (games_tx, mut games_rx) = mpsc::channel(1000); let first_names = load_names("data/first.txt")?; let last_names = load_names("data/last.txt")?; let reserved_names = RwLock::new(HashSet::::new()); diff --git a/server/src/message_handler.rs b/server/src/message_handler.rs index 99d3cb8..97fb970 100644 --- a/server/src/message_handler.rs +++ b/server/src/message_handler.rs @@ -150,7 +150,6 @@ impl MessageHandler { /// This runs when a connection closes fn handle_close(&self, close_frame: Option, addr: SocketAddr) { - // TODO: this is user handler's job let msg = UserHandlerMessage::Cleanup(addr); let tx = self.state.users_tx.clone(); tokio::spawn(async move { tx.send(msg).await });