pub struct WsConnection {
pub ws_sender: WsSender,
pub ws_receiver: WsReceiver,
pub msg_id: u64,
pub connecting: bool,
pub asking_size_max: u64,
pub available: bool,
pub name: String,
pub auto_loading: bool,
pub waiting_for_response: bool,
pub headers_received: bool,
}Expand description
WsConnection struct
Fields§
§ws_sender: WsSenderWebSocket sender
ws_receiver: WsReceiverWebSocket receiver
msg_id: u64Message ID
connecting: boolConnecting flag
asking_size_max: u64Asking size max
available: boolAvailable flag
name: StringName of the receiver
auto_loading: boolAuto-loading flag - when true, automatically requests more data
waiting_for_response: boolWaiting for response flag - true when a request has been sent and we’re waiting for the response
headers_received: boolWhether we have already requested and received headers (only need them once)
Implementations§
Source§impl WsConnection
impl WsConnection
Sourcepub fn connect(
url: &str,
wakeup: impl Fn() + Send + Sync + 'static,
) -> Result<(WsSender, WsReceiver), String>
pub fn connect( url: &str, wakeup: impl Fn() + Send + Sync + 'static, ) -> Result<(WsSender, WsReceiver), String>
Connect to a WebSocket
§Errors
Return an error as String if the connection failed - see [ewebsock::connect_with_wakeup] for more details
Sourcepub fn close_impl(&mut self) -> Result<(), TramexError>
pub fn close_impl(&mut self) -> Result<(), TramexError>
Try to close the ws
§Errors
Return an error if its fail see [ewebsock::WsSender::close] for more details
Source§impl WsConnection
impl WsConnection
Sourcepub fn should_request_more(&self) -> bool
pub fn should_request_more(&self) -> bool
Check if we should send a new request Returns true if auto-loading is enabled and not currently waiting for a response The server-side timeout and allow_empty=false handle the timing automatically