pub struct ObserverClientBuilder { /* private fields */ }Expand description
Implementations§
Source§impl ObserverClientBuilder
impl ObserverClientBuilder
Sourcepub fn with_event_handler(
self,
event_handler: Arc<dyn ClientEventHandler>,
) -> Self
pub fn with_event_handler( self, event_handler: Arc<dyn ClientEventHandler>, ) -> Self
设置事件处理器(可选,用于自定义业务逻辑)
Sourcepub fn with_observer(self, observer: Arc<dyn ConnectionObserver>) -> Self
pub fn with_observer(self, observer: Arc<dyn ConnectionObserver>) -> Self
设置观察者(必须)
Sourcepub fn with_protocol(self, protocol: TransportProtocol) -> Self
pub fn with_protocol(self, protocol: TransportProtocol) -> Self
设置传输协议
Sourcepub fn with_protocol_race(self, protocols: Vec<TransportProtocol>) -> Self
pub fn with_protocol_race(self, protocols: Vec<TransportProtocol>) -> Self
启用多协议竞速
协议列表的顺序就是优先级顺序,前面的协议优先级更高
Sourcepub fn with_protocol_url(self, protocol: TransportProtocol, url: String) -> Self
pub fn with_protocol_url(self, protocol: TransportProtocol, url: String) -> Self
为特定协议设置服务器地址
Sourcepub fn with_user_id(self, user_id: String) -> Self
pub fn with_user_id(self, user_id: String) -> Self
设置用户 ID
Sourcepub fn with_format(self, format: SerializationFormat) -> Self
pub fn with_format(self, format: SerializationFormat) -> Self
设置序列化格式
Sourcepub fn with_compression(self, compression: CompressionAlgorithm) -> Self
pub fn with_compression(self, compression: CompressionAlgorithm) -> Self
设置压缩算法
Sourcepub fn with_heartbeat(self, heartbeat: HeartbeatConfig) -> Self
pub fn with_heartbeat(self, heartbeat: HeartbeatConfig) -> Self
设置心跳配置
Sourcepub fn with_connect_timeout(self, timeout: Duration) -> Self
pub fn with_connect_timeout(self, timeout: Duration) -> Self
设置连接超时
Sourcepub fn with_reconnect_interval(self, interval: Duration) -> Self
pub fn with_reconnect_interval(self, interval: Duration) -> Self
设置重连间隔
Sourcepub fn with_max_reconnect_attempts(self, max: Option<u32>) -> Self
pub fn with_max_reconnect_attempts(self, max: Option<u32>) -> Self
设置最大重连次数
Sourcepub fn enable_router(self) -> Self
pub fn enable_router(self) -> Self
启用消息路由
启用后,可以通过 ClientCore 的 router 方法注册消息处理器
Sourcepub fn with_device_info(self, device_info: DeviceInfo) -> Self
pub fn with_device_info(self, device_info: DeviceInfo) -> Self
设置设备信息(用于协商和设备管理)
Sourcepub fn with_token(self, token: String) -> Self
pub fn with_token(self, token: String) -> Self
设置 Token(用于认证,如果服务端启用认证,必须提供)
Sourcepub async fn build_with_race(self) -> Result<ObserverClient>
pub async fn build_with_race(self) -> Result<ObserverClient>
构建客户端(使用协议竞速)
Sourcepub fn build(self) -> Result<ObserverClient>
pub fn build(self) -> Result<ObserverClient>
构建客户端
Auto Trait Implementations§
impl !RefUnwindSafe for ObserverClientBuilder
impl !UnwindSafe for ObserverClientBuilder
impl Freeze for ObserverClientBuilder
impl Send for ObserverClientBuilder
impl Sync for ObserverClientBuilder
impl Unpin for ObserverClientBuilder
impl UnsafeUnpin for ObserverClientBuilder
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