pub struct Chat { /* private fields */ }Expand description
私聊客户端
Implementations§
Source§impl Chat
impl Chat
pub fn new(api_key: String) -> Self
pub async fn connect( &mut self, reload: bool, user: Option<String>, ) -> Result<(), WebSocketError>
pub fn set_reconnect_policy(&mut self, policy: RetryPolicy)
pub fn on_ws_log<F>(&mut self, hook: F)
Sourcepub async fn off(&self, event: ChatEventType)
pub async fn off(&self, event: ChatEventType)
移除监听
Sourcepub fn disconnect(&mut self)
pub fn disconnect(&mut self)
断开连接
Sourcepub fn send_ws(&self, content: &str) -> Result<(), Error>
pub fn send_ws(&self, content: &str) -> Result<(), Error>
通过已连接的 chat-channel 发送私聊消息
该方法要求先调用 connect(..., Some(to_user)) 建立目标会话连接。
Sourcepub async fn history(
&self,
user: String,
page: u32,
size: u32,
autoread: bool,
) -> Result<Vec<ChatData>, Error>
pub async fn history( &self, user: String, page: u32, size: u32, autoread: bool, ) -> Result<Vec<ChatData>, Error>
获取用户私聊历史消息
page页数size每页消息数量autoread是否自动标记为已读
返回 私聊消息列表
Auto Trait Implementations§
impl Freeze for Chat
impl !RefUnwindSafe for Chat
impl Send for Chat
impl Sync for Chat
impl Unpin for Chat
impl UnsafeUnpin for Chat
impl !UnwindSafe for Chat
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