naia_client/client_config.rs
1use std::{default::Default, time::Duration};
2
3use naia_shared::ConnectionConfig;
4
5use crate::JitterBufferType;
6
7/// Contains Config properties which will be used by a Server or Client
8#[derive(Clone)]
9pub struct ClientConfig {
10 /// Used to configure the connection with the Server
11 pub connection: ConnectionConfig,
12 /// The duration between the resend of certain connection handshake messages
13 pub send_handshake_interval: Duration,
14 /// The duration to wait before sending a ping message to the remote host,
15 /// in order to estimate RTT time
16 pub ping_interval: Duration,
17 /// The number of network samples to take before completing the Connection Handshake.
18 /// Increase this for greater accuracy of network statistics, at the cost of the handshake
19 /// taking longer. Keep in mind that the network measurements affect how likely commands
20 /// are able to arrive at the server before processing.
21 pub handshake_pings: u8,
22 /// Configuration for jitter buffer behavior
23 pub jitter_buffer: JitterBufferType,
24}
25
26impl Default for ClientConfig {
27 fn default() -> Self {
28 Self {
29 connection: ConnectionConfig::default(),
30 send_handshake_interval: Duration::from_millis(250),
31 ping_interval: Duration::from_secs(1),
32 handshake_pings: 10,
33 jitter_buffer: JitterBufferType::Real,
34 }
35 }
36}