minor changes to netwrok code

This commit is contained in:
griffi-gh 2023-05-20 15:17:16 +02:00
parent 4dde1651ab
commit e8e3863d47
3 changed files with 4 additions and 3 deletions

View file

@ -35,7 +35,7 @@ pub fn bind_server(
endpoint_config: EndpointConfig { endpoint_config: EndpointConfig {
active_timeout_ms: config.server.timeout_ms, active_timeout_ms: config.server.timeout_ms,
keepalive: true, keepalive: true,
keepalive_interval_ms: 300, keepalive_interval_ms: 5000,
..Default::default() ..Default::default()
}, },
..Default::default() ..Default::default()

View file

@ -74,7 +74,7 @@ fn connect_client(
endpoint_config: EndpointConfig { endpoint_config: EndpointConfig {
active_timeout_ms: 10000, active_timeout_ms: 10000,
keepalive: true, keepalive: true,
keepalive_interval_ms: 300, keepalive_interval_ms: 5000,
..Default::default() ..Default::default()
}, },
}).expect("Client connection failed"); }).expect("Client connection failed");
@ -102,7 +102,6 @@ fn flush_client(
client.0.flush(); client.0.flush();
} }
fn handle_disconnect( fn handle_disconnect(
network_events: View<NetworkEvent>, network_events: View<NetworkEvent>,
mut join_state: UniqueViewMut<ClientJoinState> mut join_state: UniqueViewMut<ClientJoinState>

View file

@ -97,6 +97,7 @@ fn unload_downgrade_chunks(
return return
} }
//TODO refactor this //TODO refactor this
//TODO unsubscibe if in multiplayer
vm_world.chunks.retain(|_, chunk| { vm_world.chunks.retain(|_, chunk| {
if chunk.desired_state == DesiredChunkState::ToUnload { if chunk.desired_state == DesiredChunkState::ToUnload {
if let Some(mesh_index) = chunk.mesh_index { if let Some(mesh_index) = chunk.mesh_index {
@ -135,6 +136,7 @@ fn start_required_tasks(
DesiredChunkState::Loaded | DesiredChunkState::Rendered if chunk.current_state == CurrentChunkState::Nothing => { DesiredChunkState::Loaded | DesiredChunkState::Rendered if chunk.current_state == CurrentChunkState::Nothing => {
//start load task //start load task
if let Some(client) = &mut udp_client { if let Some(client) = &mut udp_client {
//crappy rate limiting
client.0.send( client.0.send(
postcard::to_allocvec(&ClientToServerMessage::ChunkSubRequest { postcard::to_allocvec(&ClientToServerMessage::ChunkSubRequest {
chunk: position, chunk: position,