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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
use std::{default::Default, time::Duration};
#[derive(Clone, Debug)]
pub struct ConnectionConfig {
pub disconnection_timeout_duration: Duration,
pub heartbeat_interval: Duration,
pub ping_interval: Duration,
pub ping_sample_size: u16,
}
impl ConnectionConfig {
pub fn new(
disconnection_timeout_duration: Duration,
heartbeat_interval: Duration,
ping_interval: Duration,
rtt_sample_size: u16,
) -> Self {
ConnectionConfig {
disconnection_timeout_duration,
heartbeat_interval,
ping_interval,
ping_sample_size: rtt_sample_size,
}
}
}
impl Default for ConnectionConfig {
fn default() -> Self {
Self {
disconnection_timeout_duration: Duration::from_secs(10),
heartbeat_interval: Duration::from_secs(4),
ping_interval: Duration::from_secs(1),
ping_sample_size: 20,
}
}
}