pub struct WebSocketClient { /* private fields */ }Expand description
基础 WebSocket 客户端
Implementations§
Source§impl WebSocketClient
impl WebSocketClient
Sourcepub async fn connect<H>(
url: &str,
message_handler: H,
) -> Result<Self, WebSocketError>where
H: MessageHandler + 'static,
pub async fn connect<H>(
url: &str,
message_handler: H,
) -> Result<Self, WebSocketError>where
H: MessageHandler + 'static,
创建并连接 WebSocket
Sourcepub async fn add_listener<F>(&self, event: WsEventType, listener: F)
pub async fn add_listener<F>(&self, event: WsEventType, listener: F)
添加事件监听器
Sourcepub async fn remove_listener(&self, event: Option<WsEventType>)
pub async fn remove_listener(&self, event: Option<WsEventType>)
移除监听器
Sourcepub fn disconnect(&self)
pub fn disconnect(&self)
断开连接
Trait Implementations§
Auto Trait Implementations§
impl Freeze for WebSocketClient
impl !RefUnwindSafe for WebSocketClient
impl Send for WebSocketClient
impl Sync for WebSocketClient
impl Unpin for WebSocketClient
impl UnsafeUnpin 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