mirror of
https://github.com/griffi-gh/kubi.git
synced 2024-11-10 01:28:41 -06:00
server
This commit is contained in:
parent
3f47be435d
commit
6b65497263
|
@ -1,6 +1,7 @@
|
||||||
use shipyard::{World, AllStoragesView, Unique, Workload, IntoWorkload, UniqueView, UniqueViewMut};
|
use shipyard::{World, AllStoragesView, Unique, Workload, IntoWorkload, UniqueView, UniqueViewMut};
|
||||||
use kubi_udp::server::{Server, ServerConfig};
|
use kubi_udp::server::{Server, ServerConfig};
|
||||||
use kubi_shared::networking::messages::{ClientToServerMessage, ServerToClientMessage};
|
use kubi_shared::networking::messages::{ClientToServerMessage, ServerToClientMessage};
|
||||||
|
use std::{thread, time::Duration};
|
||||||
|
|
||||||
#[derive(Unique)]
|
#[derive(Unique)]
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
|
@ -9,6 +10,7 @@ pub struct UdpServer(Server<ServerToClientMessage, ClientToServerMessage>);
|
||||||
fn bind_server(
|
fn bind_server(
|
||||||
storages: AllStoragesView,
|
storages: AllStoragesView,
|
||||||
) {
|
) {
|
||||||
|
log::info!("Binding server");
|
||||||
let server: Server<ServerToClientMessage, ClientToServerMessage> = Server::bind(
|
let server: Server<ServerToClientMessage, ClientToServerMessage> = Server::bind(
|
||||||
"0.0.0.0:1234".parse().unwrap(),
|
"0.0.0.0:1234".parse().unwrap(),
|
||||||
ServerConfig::default()
|
ServerConfig::default()
|
||||||
|
@ -20,7 +22,7 @@ fn update_server(
|
||||||
mut server: UniqueViewMut<UdpServer>
|
mut server: UniqueViewMut<UdpServer>
|
||||||
) {
|
) {
|
||||||
if let Err(error) = server.0.update() {
|
if let Err(error) = server.0.update() {
|
||||||
println!("Server error: {error:?}")
|
log::error!("Server error: {error:?}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,5 +46,6 @@ fn main() {
|
||||||
world.run_workload(initialize).unwrap();
|
world.run_workload(initialize).unwrap();
|
||||||
loop {
|
loop {
|
||||||
world.run_workload(update).unwrap();
|
world.run_workload(update).unwrap();
|
||||||
|
thread::sleep(Duration::from_millis(16));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue