odyssey-server/src/main.rs

34 lines
692 B
Rust

mod components;
mod config;
mod game;
mod network;
mod systems;
use crate::config::Settings;
use crate::game::Game;
use crate::network::listen;
use async_std::sync::Arc;
use async_std::{sync::channel, task};
use env_logger::Env;
async fn run() {
let env = Env::default().filter_or("LOG_LEVEL", "info");
env_logger::init_from_env(env);
let settings = Settings::new().unwrap();
let (in_s, in_r) = channel(10);
let (out_s, out_r) = channel(10);
let game = Arc::new(Game::new(out_s));
task::spawn(async move {
game.clone().read_loop(in_r).await;
});
task::block_on(listen(settings.bind, in_s, out_r));
}
fn main() {
task::block_on(run());
}