Skip to content

Commit db0c1ac

Browse files
author
Matthew Fisher
committed
remove unused NetworkEvent
Signed-off-by: Matthew Fisher <[email protected]>
1 parent f3d3f33 commit db0c1ac

File tree

4 files changed

+9
-16
lines changed

4 files changed

+9
-16
lines changed

examples/client.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,6 @@ fn connection_handler(mut events: EventReader<NetworkEvent>) {
3838
NetworkEvent::RecvError(err) => {
3939
error!("NetworkEvent::RecvError: {:?}", err);
4040
},
41-
NetworkEvent::ConnectionError(err, handle) => match handle {
42-
Some(h) => error!("NetworkEvent::ConnectionError from {}: {:?}", h, err),
43-
_ => error!("NetworkEvent::ConnectionError: {:?}", err),
44-
},
4541
// discard irrelevant events
4642
_ => {},
4743
}

examples/server.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,6 @@ fn connection_handler(mut events: EventReader<NetworkEvent>, mut transport: ResM
5151
NetworkEvent::RecvError(err) => {
5252
info!("NetworkEvent::RecvError: {:?}", err);
5353
}
54-
NetworkEvent::ConnectionError(err, handle) => match handle {
55-
Some(h) => info!("NetworkEvent::ConnectionError from {}: {:?}", h, err),
56-
_ => info!("NetworkEvent::ConnectionError: {:?}", err),
57-
},
5854
}
5955
}
6056
}

src/events.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,14 @@ use bytes::Bytes;
55
use super::message::Message;
66

77
pub enum NetworkEvent {
8-
// A message was received from a remote client
8+
// A message was received from a client
99
Message(SocketAddr, Bytes),
10-
// A new host has connected to us
10+
// A new client has connected to us
1111
Connected(SocketAddr),
12-
// A host has disconnected from us
12+
// A client has disconnected from us
1313
Disconnected(SocketAddr),
14-
// An error occurred while receiving a message.
14+
// An error occurred while receiving a message
1515
RecvError(io::Error),
16-
// An error occurred while sending a message.
16+
// An error occurred while sending a message
1717
SendError(io::Error, Message),
18-
// An error occurred while managing connections.
19-
ConnectionError(io::Error, Option<SocketAddr>),
2018
}

src/lib.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ use bevy::prelude::*;
1616
/// Defines how many times a client automatically sends a heartbeat packet.
1717
/// This should be no more than half of idle_timeout.
1818
const DEFAULT_HEARTBEAT_TICK_RATE_SECS: f32 = 2.;
19+
/// Defines how long the server will wait until it sends
20+
/// NetworkEvent::Disconnected
21+
const DEFAULT_IDLE_TIMEOUT_SECS: f32 = 5.;
1922

2023
pub struct NetworkResource {
2124
// Hashmap of each live connection and their last known packet activity
@@ -27,7 +30,7 @@ impl Default for NetworkResource {
2730
fn default() -> Self {
2831
Self {
2932
connections: Default::default(),
30-
idle_timeout: Duration::from_secs(5),
33+
idle_timeout: Duration::from_secs_f32(DEFAULT_IDLE_TIMEOUT_SECS),
3134
}
3235
}
3336
}

0 commit comments

Comments
 (0)