diff --git a/Server.toml b/Server.toml new file mode 100644 index 0000000..08a172e --- /dev/null +++ b/Server.toml @@ -0,0 +1,4 @@ +[server] +address = "0.0.0.0" +port = 1234 +max_clients = 254 diff --git a/kubi-server/Cargo.toml b/kubi-server/Cargo.toml index e9ff2ba..3e4255d 100644 --- a/kubi-server/Cargo.toml +++ b/kubi-server/Cargo.toml @@ -9,3 +9,5 @@ kubi-udp = { path = "../kubi-udp" } kubi-logging = { path = "../kubi-logging" } log = "*" shipyard = "0.6" +serde = "1.0" +toml = "0.7" diff --git a/kubi-server/src/main.rs b/kubi-server/src/main.rs index 0525209..ea6bfc4 100644 --- a/kubi-server/src/main.rs +++ b/kubi-server/src/main.rs @@ -1,7 +1,11 @@ use shipyard::{World, AllStoragesView, Unique, Workload, IntoWorkload, UniqueView, UniqueViewMut}; use kubi_udp::server::{Server, ServerConfig}; use kubi_shared::networking::messages::{ClientToServerMessage, ServerToClientMessage}; -use std::{thread, time::Duration}; +use std::{thread, time::Duration, net::SocketAddr}; + +#[derive(Unique)] +#[repr(transparent)] +pub struct ServerAddr(SocketAddr); #[derive(Unique)] #[repr(transparent)] @@ -10,7 +14,8 @@ pub struct UdpServer(Server); fn bind_server( storages: AllStoragesView, ) { - log::info!("Binding server"); + log::info!("Creating server..."); + let addr = storages.borrow::>().expect("No server addr found"); let server: Server = Server::bind( "0.0.0.0:1234".parse().unwrap(), ServerConfig::default() @@ -44,6 +49,7 @@ fn main() { world.add_workload(initialize); world.add_workload(update); world.run_workload(initialize).unwrap(); + log::info!("The server is now running"); loop { world.run_workload(update).unwrap(); thread::sleep(Duration::from_millis(16));