sword_layers/socketio/
config.rs

1use crate::utils::*;
2use serde::{Deserialize, Serialize};
3
4#[derive(Debug, Clone, Serialize, Deserialize, Default)]
5#[serde(default)]
6pub struct SocketIoServerConfig {
7    /// Whether to enable the Socket.IO server.
8    /// Defaults to false.
9    pub enabled: bool,
10
11    /// The amount of time the server will wait for an acknowledgement
12    /// from the client before closing the connection.
13    ///
14    /// Defaults to 5 seconds.
15    pub ack_timeout: Option<TimeConfig>,
16
17    /// The amount of time before disconnecting a client that has not
18    /// successfully joined a namespace.
19    ///
20    /// Defaults to 45 seconds.
21    pub connect_timeout: Option<TimeConfig>,
22
23    /// The maximum number of packets that can be buffered per connection
24    /// before being emitted to the client. If the buffer if full the emit()
25    /// method will return an error.
26    ///
27    /// Defaults to 128 packets.
28    pub max_buffer_size: Option<usize>,
29
30    /// The maximum size of a payload in bytes. If a payload is bigger than
31    /// this value the emit() method will return an error.
32    ///
33    /// Defaults to 100 kb.
34    pub max_payload: Option<ByteConfig>,
35
36    /// The interval at which the server will send a ping packet to the client.
37    /// Defaults to 25 seconds.
38    pub ping_interval: Option<TimeConfig>,
39
40    /// The amount of time the server will wait for a ping response from the
41    /// client before closing the connection.
42    ///
43    /// Defaults to 20 seconds.
44    pub ping_timeout: Option<TimeConfig>,
45
46    /// The path to listen for socket.io requests on.
47    /// Defaults to "/socket.io".
48    pub req_path: Option<String>,
49
50    /// The transports to allow for connections.
51    /// Valid options are "polling" and "websocket".
52    pub transports: Option<Vec<String>>,
53
54    /// The parser to use for encoding and decoding messages.
55    /// Valid options are "common" and "msgpack".
56    pub parser: Option<String>,
57
58    /// The size of the read buffer for the websocket transport.
59    /// You can tweak this value depending on your use case.
60    ///
61    /// Defaults to 4KiB.
62    ///
63    /// Setting it to a higher value will improve performance on heavy read scenarios
64    /// but will consume more memory.
65    pub ws_read_buffer_size: Option<usize>,
66}