1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
use std::{default::Default, time::Duration};

use naia_shared::ConnectionConfig;

/// Contains Config properties which will be used by a Server or Client
#[derive(Clone)]
pub struct ClientConfig {
    /// Used to configure the connection with the Server
    pub connection: ConnectionConfig,
    /// The duration between the resend of certain connection handshake messages
    pub send_handshake_interval: Duration,
    /// The duration to wait before sending a ping message to the remote host,
    /// in order to estimate RTT time
    pub ping_interval: Duration,
    /// The number of network samples to take before completing the Connection Handshake.
    /// Increase this for greater accuracy of network statistics, at the cost of the handshake
    /// taking longer. Keep in mind that the network measurements affect how likely commands
    /// are able to arrive at the server before processing.
    pub handshake_pings: u8,
}

impl Default for ClientConfig {
    fn default() -> Self {
        Self {
            connection: ConnectionConfig::default(),
            send_handshake_interval: Duration::from_millis(250),
            ping_interval: Duration::from_secs(1),
            handshake_pings: 10,
        }
    }
}