mirror of
https://github.com/griffi-gh/kubi.git
synced 2024-12-22 11:58:21 -06:00
wip
This commit is contained in:
parent
6b65497263
commit
5307ba0c9f
4
Server.toml
Normal file
4
Server.toml
Normal file
|
@ -0,0 +1,4 @@
|
|||
[server]
|
||||
address = "0.0.0.0"
|
||||
port = 1234
|
||||
max_clients = 254
|
|
@ -9,3 +9,5 @@ kubi-udp = { path = "../kubi-udp" }
|
|||
kubi-logging = { path = "../kubi-logging" }
|
||||
log = "*"
|
||||
shipyard = "0.6"
|
||||
serde = "1.0"
|
||||
toml = "0.7"
|
||||
|
|
|
@ -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<ServerToClientMessage, ClientToServerMessage>);
|
|||
fn bind_server(
|
||||
storages: AllStoragesView,
|
||||
) {
|
||||
log::info!("Binding server");
|
||||
log::info!("Creating server...");
|
||||
let addr = storages.borrow::<UniqueView<SocketAddr>>().expect("No server addr found");
|
||||
let server: Server<ServerToClientMessage, ClientToServerMessage> = 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));
|
||||
|
|
Loading…
Reference in a new issue