pub struct WebSocketClient { /* private fields */ }Expand description
WebSocket 客户端
只处理协议层,其他功能委托给 ClientCore
Implementations§
Source§impl WebSocketClient
impl WebSocketClient
Sourcepub fn new(config: ClientConfig) -> Self
pub fn new(config: ClientConfig) -> Self
创建新的 WebSocket 客户端
Sourcepub async fn connect_with_config(config: ClientConfig) -> Result<Self>
pub async fn connect_with_config(config: ClientConfig) -> Result<Self>
创建并连接
Sourcepub fn with_core(config: ClientConfig, core: ClientCore) -> Self
pub fn with_core(config: ClientConfig, core: ClientCore) -> Self
使用 ClientCore 创建(用于 HybridClient)
Sourcepub async fn establish_network_connection(
&mut self,
) -> Result<Arc<Mutex<Box<dyn Connection>>>>
pub async fn establish_network_connection( &mut self, ) -> Result<Arc<Mutex<Box<dyn Connection>>>>
仅建立网络连接(不发送 CONNECT 消息)
用于协议竞速:先建立网络连接,选择最快协议,然后再发送 CONNECT
Sourcepub fn core(&self) -> &ClientCore
pub fn core(&self) -> &ClientCore
获取 ClientCore(用于外部访问)
Trait Implementations§
Source§impl Client for WebSocketClient
impl Client for WebSocketClient
fn connect<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn set_disconnect_requested(&mut self, value: bool)
fn disconnect<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn send_frame<'life0, 'life1, 'async_trait>(
&'life0 mut self,
frame: &'life1 Frame,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn is_connected(&self) -> bool
fn add_observer(&mut self, observer: ArcObserver)
fn remove_observer(&mut self, observer: ArcObserver)
fn connection_id(&self) -> Option<String>
Auto Trait Implementations§
impl !RefUnwindSafe for WebSocketClient
impl !UnwindSafe for WebSocketClient
impl Freeze for WebSocketClient
impl Send for WebSocketClient
impl Sync for WebSocketClient
impl Unpin for WebSocketClient
impl UnsafeUnpin for WebSocketClient
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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