mirror of
https://github.com/griffi-gh/kubi.git
synced 2024-12-26 21:58:20 -06:00
handle disconnect
This commit is contained in:
parent
5d8f253c3c
commit
7251dacedc
|
@ -134,6 +134,19 @@ fn check_server_hello_response(
|
|||
}
|
||||
}
|
||||
|
||||
fn handle_disconnect(
|
||||
network_events: View<NetworkEvent>,
|
||||
mut join_state: UniqueViewMut<ClientJoinState>
|
||||
) {
|
||||
for event in network_events.iter() {
|
||||
if matches!(event.0, ClientEvent::Disconnect) {
|
||||
log::warn!("Disconnected from server");
|
||||
*join_state = ClientJoinState::Disconnected;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn update_networking() -> Workload {
|
||||
(
|
||||
connect_client.run_if_missing_unique::<UdpClient>(),
|
||||
|
@ -143,8 +156,9 @@ pub fn update_networking() -> Workload {
|
|||
say_hello,
|
||||
).into_sequential_workload().run_if(if_just_connected),
|
||||
(
|
||||
check_server_hello_response
|
||||
).run_if(is_join_state::<{ClientJoinState::Connected as u8}>),
|
||||
check_server_hello_response,
|
||||
handle_disconnect,
|
||||
).into_sequential_workload().run_if(is_join_state::<{ClientJoinState::Connected as u8}>),
|
||||
(
|
||||
recv_block_place_events
|
||||
).run_if(is_join_state::<{ClientJoinState::Joined as u8}>).run_if(is_ingame_or_loading),
|
||||
|
|
Loading…
Reference in a new issue