#[non_exhaustive]pub struct WebSocketConfig {
pub connect_cooldown: Duration,
pub refresh_after: Duration,
pub url_prefix: String,
pub ignore_duplicate_during_reconnection: bool,
pub reconnection_wait: Duration,
pub message_timeout: Duration,
}Expand description
Configuration for WebSocketHandler.
Should be returned by WebSocketHandler::websocket_config().
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.connect_cooldown: DurationDuration that should elapse between each attempt to start a new connection.
This matters because the WebSocketConnection reconnects on error. If the error
continues to happen, it could spam the server if connect_cooldown is too short. Defaults to 3000ms.
refresh_after: DurationThe WebSocketConnection will automatically reconnect when refresh_after has elapsed since
the last connection started. If you don’t want this feature, set it to Duration::ZERO. Defaults to Duration::ZERO.
url_prefix: StringPrefix which will be used for connections that started using this WebSocketConfig. Defaults to "".
Example usage: "wss://example.com"
ignore_duplicate_during_reconnection: boolDuring reconnection, WebSocketHandler might receive two identical messages
even though the server sent only one message. By setting this to true, WebSocketConnection
will not send duplicate messages to the WebSocketHandler. You should set this option to true
when messages contain some sort of ID and are distinguishable.
Note, that WebSocketConnection will not check duplicate messages when it is not under reconnection
even this option is set to true.
reconnection_wait: DurationWhen ignore_duplicate_during_reconnection is set to true, WebSocketConnection will wait for a
certain amount of time to make sure no message is lost. Defaults to 300ms
message_timeout: DurationA reconnection will be triggered if no messages are received within this amount of time. Defaults to Duration::ZERO, which means no timeout will be applied.
Implementations§
Trait Implementations§
Source§impl Clone for WebSocketConfig
impl Clone for WebSocketConfig
Source§fn clone(&self) -> WebSocketConfig
fn clone(&self) -> WebSocketConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more