pub struct WebSocketClient { /* private fields */ }Expand description
WebSocket client for real-time message reception.
Implementations§
Source§impl WebSocketClient
impl WebSocketClient
Sourcepub fn new(config: WebSocketConfig, tls_config: Option<TLSConfig>) -> Self
pub fn new(config: WebSocketConfig, tls_config: Option<TLSConfig>) -> Self
Create a new WebSocket client.
Sourcepub fn on_message<F>(&mut self, callback: F)
pub fn on_message<F>(&mut self, callback: F)
Set the message callback handler.
Sourcepub async fn start_background(&mut self) -> WebsocketResult<()>
pub async fn start_background(&mut self) -> WebsocketResult<()>
Start the WebSocket connection in the background (spawns a worker task).
Sourcepub async fn start_blocking(&mut self) -> WebsocketResult<()>
pub async fn start_blocking(&mut self) -> WebsocketResult<()>
Start the WebSocket connection and block until it closes.
Sourcepub async fn stop_background(&mut self) -> WebsocketResult<()>
pub async fn stop_background(&mut self) -> WebsocketResult<()>
Stop the WebSocket connection and worker.
Sourcepub async fn is_connected(&self) -> bool
pub async fn is_connected(&self) -> bool
Check if the WebSocket is currently connected.
Sourcepub async fn reconnect(&self) -> WebsocketResult<()>
pub async fn reconnect(&self) -> WebsocketResult<()>
Force a reconnection attempt.
Trait Implementations§
Source§impl Debug for WebSocketClient
impl Debug for WebSocketClient
Auto Trait Implementations§
impl Freeze for WebSocketClient
impl !RefUnwindSafe for WebSocketClient
impl Send for WebSocketClient
impl Sync for WebSocketClient
impl Unpin for WebSocketClient
impl !UnwindSafe for WebSocketClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more