naia_socket_shared/
socket_config.rs

1use std::default::Default;
2
3use super::link_conditioner_config::LinkConditionerConfig;
4
5const DEFAULT_RTC_PATH: &str = "rtc_session";
6
7/// Contains Config properties which will be shared by Server and Client sockets
8#[derive(Clone)]
9pub struct SocketConfig {
10    /// Configuration used to simulate network conditions
11    pub link_condition: Option<LinkConditionerConfig>,
12    /// The endpoint URL path to use for initiating new WebRTC sessions
13    pub rtc_endpoint_path: String,
14}
15
16impl SocketConfig {
17    /// Creates a new SocketConfig
18    pub fn new(
19        link_condition: Option<LinkConditionerConfig>,
20        rtc_endpoint_path: Option<String>,
21    ) -> Self {
22        let endpoint_path = {
23            if let Some(path) = rtc_endpoint_path {
24                path
25            } else {
26                DEFAULT_RTC_PATH.to_string()
27            }
28        };
29
30        SocketConfig {
31            link_condition,
32            rtc_endpoint_path: endpoint_path,
33        }
34    }
35}
36
37impl Default for SocketConfig {
38    fn default() -> Self {
39        Self {
40            link_condition: None,
41            rtc_endpoint_path: DEFAULT_RTC_PATH.to_string(),
42        }
43    }
44}