pub struct ChatRoom { /* private fields */ }Expand description
聊天室客户端
Implementations§
Source§impl ChatRoom
impl ChatRoom
pub fn new(api_key: String) -> Self
pub async fn get_node(&self) -> Result<ChatRoomNodeResponse, WebSocketError>
Sourcepub async fn get_ws_url(&self) -> Result<String, WebSocketError>
pub async fn get_ws_url(&self) -> Result<String, WebSocketError>
获取 WebSocket URL
Sourcepub async fn reconnect(&mut self) -> Result<(), WebSocketError>
pub async fn reconnect(&mut self) -> Result<(), WebSocketError>
重连
pub fn set_reconnect_policy(&mut self, policy: RetryPolicy)
pub fn on_ws_log<F>(&mut self, hook: F)
Sourcepub async fn on_discuss<F>(&self, listener: F)
pub async fn on_discuss<F>(&self, listener: F)
监听话题变更事件
Sourcepub async fn on_barrager<F>(&self, listener: F)
pub async fn on_barrager<F>(&self, listener: F)
监听弹幕消息事件
Sourcepub async fn on_redpacket<F>(&self, listener: F)
pub async fn on_redpacket<F>(&self, listener: F)
监听红包消息事件
Sourcepub async fn on_redpacketstatus<F>(&self, listener: F)
pub async fn on_redpacketstatus<F>(&self, listener: F)
监听红包状态事件
Sourcepub async fn on_weather<F>(&self, listener: F)
pub async fn on_weather<F>(&self, listener: F)
监听天气消息事件
pub async fn on_all<F>(&self, listener: F)
Sourcepub async fn off(&self, event: ChatRoomEventType)
pub async fn off(&self, event: ChatRoomEventType)
移除监听
Sourcepub fn disconnect(&mut self)
pub fn disconnect(&mut self)
断开连接
Sourcepub async fn get_discuss(&self) -> String
pub async fn get_discuss(&self) -> String
当前话题
Sourcepub async fn set_discuss(&self, discuss: String)
pub async fn set_discuss(&self, discuss: String)
Sourcepub async fn get_online_count(&self) -> usize
pub async fn get_online_count(&self) -> usize
当前在线人数
Sourcepub fn set_api_key(&mut self, api_key: String)
pub fn set_api_key(&mut self, api_key: String)
重新设置apiKey
Sourcepub fn set_client_type(&mut self, client: ClientType, version: Option<String>)
pub fn set_client_type(&mut self, client: ClientType, version: Option<String>)
Sourcepub async fn history(
&self,
page: u32,
type_: ChatContentType,
) -> Result<Vec<ChatRoomMsg>, Error>
pub async fn history( &self, page: u32, type_: ChatContentType, ) -> Result<Vec<ChatRoomMsg>, Error>
查询聊天室历史消息
#参数
page - 页码
type_ - 内容类型 ChatContentType
Sourcepub async fn get_msg_around(
&self,
o_id: &str,
mode: ChatRoomMessageMode,
size: u32,
type_: ChatContentType,
) -> Result<Vec<ChatRoomMsg>, Error>
pub async fn get_msg_around( &self, o_id: &str, mode: ChatRoomMessageMode, size: u32, type_: ChatContentType, ) -> Result<Vec<ChatRoomMsg>, Error>
获取指定消息附近的聊天室消息
§参数
o_id- 消息 Idmode- 获取模式,context 上下文模式,after 之后模式 ChatRoomMessageModesize- 获取消息数量,默认 25,最大 100type_- 获取消息类型,默认 HTML ChatContentType- 返回 ChatRoomMsg 消息列表
Sourcepub async fn barrage_cost(&self) -> Result<BarragerCost, Error>
pub async fn barrage_cost(&self) -> Result<BarragerCost, Error>
获取弹幕花费
§返回 BarragerCost
Auto Trait Implementations§
impl Freeze for ChatRoom
impl !RefUnwindSafe for ChatRoom
impl Send for ChatRoom
impl Sync for ChatRoom
impl Unpin for ChatRoom
impl UnsafeUnpin for ChatRoom
impl !UnwindSafe for ChatRoom
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