diff options
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..368f439 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,31 @@ +#![feature(iterator_try_collect)] +use config::Config; +use game::{server::game_server, Game}; +use spectate::server::spectate_server; +use std::sync::Arc; +use tokio::{ + spawn, + sync::{broadcast, RwLock}, +}; + +pub mod config; +pub mod game; +pub mod spectate; + +pub struct State { + tick: broadcast::Sender<bool>, // true for new game + game: RwLock<Game>, +} + +#[tokio::main] +async fn main() -> anyhow::Result<()> { + env_logger::init_from_env("LOG"); + let config = Config::load()?; + let state = Arc::new(State { + tick: broadcast::channel(16).0, + game: Game::new(vec![]).into(), + }); + spawn(spectate_server(config.spectate, state.clone())); + game_server(config.game, state.clone()).await?; + Ok(()) +} |