Struct generic_api_client::websocket::WebSocketConfig
source · #[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: Duration
Duration 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: Duration
The 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: String
Prefix which will be used for connections that started using this WebSocketConfig
. Defaults to ""
.
Example usage: "wss://example.com"
ignore_duplicate_during_reconnection: bool
During 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: Duration
When 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: Duration
A 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