pub struct ClientConnectionManager { /* private fields */ }Expand description
客户端连接管理器
管理客户端连接的生命周期,包括:
- 自动连接和重连
- 心跳管理
- 连接状态监控
- 消息观察者管理
Implementations§
Source§impl ClientConnectionManager
impl ClientConnectionManager
Sourcepub fn new(client: Box<dyn Client>, config: ClientConfig) -> Self
pub fn new(client: Box<dyn Client>, config: ClientConfig) -> Self
Sourcepub async fn disconnect(&self) -> Result<()>
pub async fn disconnect(&self) -> Result<()>
断开连接
Sourcepub async fn send_frame(&self, frame: &Frame) -> Result<()>
pub async fn send_frame(&self, frame: &Frame) -> Result<()>
发送消息
Sourcepub async fn start_auto_reconnect(&self)
pub async fn start_auto_reconnect(&self)
启动自动重连
Sourcepub fn add_observer(&self, observer: ArcObserver)
pub fn add_observer(&self, observer: ArcObserver)
添加观察者
Sourcepub fn remove_observer(&self, observer: ArcObserver)
pub fn remove_observer(&self, observer: ArcObserver)
移除观察者
Sourcepub async fn is_connected(&self) -> bool
pub async fn is_connected(&self) -> bool
检查是否已连接
Sourcepub async fn connection_id(&self) -> Option<String>
pub async fn connection_id(&self) -> Option<String>
获取连接 ID
Sourcepub fn state(&self) -> ConnectionState
pub fn state(&self) -> ConnectionState
获取连接状态
Auto Trait Implementations§
impl !RefUnwindSafe for ClientConnectionManager
impl !UnwindSafe for ClientConnectionManager
impl Freeze for ClientConnectionManager
impl Send for ClientConnectionManager
impl Sync for ClientConnectionManager
impl Unpin for ClientConnectionManager
impl UnsafeUnpin for ClientConnectionManager
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