pub struct FlareClient { /* private fields */ }Expand description
Flare 客户端
Implementations§
Source§impl FlareClient
impl FlareClient
Sourcepub async fn send_frame(&self, frame: &Frame) -> Result<()>
pub async fn send_frame(&self, frame: &Frame) -> Result<()>
发送消息 Frame
Sourcepub async fn send_frame_and_wait(
&self,
frame: &Frame,
timeout: Duration,
) -> Result<Frame>
pub async fn send_frame_and_wait( &self, frame: &Frame, timeout: Duration, ) -> Result<Frame>
发送并等待响应(按 message_id 匹配)
Sourcepub fn is_connected(&self) -> bool
pub fn is_connected(&self) -> bool
检查是否已连接(native 同步;WASM 请用 Self::is_connected_async)
Sourcepub async fn is_connected_async(&self) -> bool
pub async fn is_connected_async(&self) -> bool
检查是否已连接(async,全平台)
Sourcepub async fn disconnect(self) -> Result<()>
pub async fn disconnect(self) -> Result<()>
断开连接
Sourcepub fn connection_id(&self) -> Option<String>
pub fn connection_id(&self) -> Option<String>
获取连接 ID(native 同步;WASM 请用 Self::connection_id_async)
Sourcepub async fn connection_id_async(&self) -> Option<String>
pub async fn connection_id_async(&self) -> Option<String>
获取连接 ID(async,全平台)
Sourcepub async fn parser_snapshot(&self) -> MessageParser
pub async fn parser_snapshot(&self) -> MessageParser
获取协商后的消息解析器快照
Sourcepub fn active_protocol(&self) -> TransportProtocol
pub fn active_protocol(&self) -> TransportProtocol
获取活动协议
Sourcepub async fn update_heartbeat_config(&self, config: HeartbeatConfig)
pub async fn update_heartbeat_config(&self, config: HeartbeatConfig)
运行期替换心跳策略。
Sourcepub async fn set_heartbeat_app_state(&self, state: HeartbeatAppState)
pub async fn set_heartbeat_app_state(&self, state: HeartbeatAppState)
更新应用前后台状态。移动端进入后台时可拉长心跳,回到前台时恢复较短心跳。
Sourcepub async fn set_heartbeat_nat_timeout(&self, timeout: Option<Duration>)
pub async fn set_heartbeat_nat_timeout(&self, timeout: Option<Duration>)
更新 NAT 空闲超时探测结果。传入 None 表示清除探测值。
Sourcepub async fn heartbeat_effective_interval(&self) -> Duration
pub async fn heartbeat_effective_interval(&self) -> Duration
当前实际心跳间隔。
Sourcepub async fn update_parser(&self, parser: MessageParser)
pub async fn update_parser(&self, parser: MessageParser)
更新消息管道解析器(协商完成后调用)
Sourcepub async fn add_observer(&self, observer: Arc<dyn ConnectionObserver>)
pub async fn add_observer(&self, observer: Arc<dyn ConnectionObserver>)
添加连接观察者
观察者会收到连接事件(Connected、Disconnected、Error、Message)
Trait Implementations§
Source§impl Clone for FlareClient
impl Clone for FlareClient
Source§fn clone(&self) -> FlareClient
fn clone(&self) -> FlareClient
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for FlareClient
impl !UnwindSafe for FlareClient
impl Freeze for FlareClient
impl Send for FlareClient
impl Sync for FlareClient
impl Unpin for FlareClient
impl UnsafeUnpin for FlareClient
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