use game::{Game, GameImpl}; use tokio::sync::{broadcast, mpsc}; pub mod user; pub mod table; pub mod api; pub mod game; pub mod pathfinder2r_impl; pub struct GameServer { game: Game } impl GameServer { pub fn new() -> Self { Self { game: Game::new(), } } pub async fn server_loop(mut self, mut msgs: mpsc::Receiver<(String, api::Request)>, mut broadcast: broadcast::Sender) { while let Some(req) = msgs.recv().await { // TODO: do stuff yo! let (id, req) = req; match req { api::Request::Error => {}, api::Request::Login(_) => {}, api::Request::Message(msg) => { _ = broadcast.send(api::Response::Message(msg)); }, api::Request::Quit => { _ = broadcast.send(api::Response::Quit { id })}, api::Request::Shutdown => todo!(), } } _ = broadcast.send(api::Response::Shutdown); } }