pub struct LiveChatClient { /* private fields */ }Expand description
Client for receiving live chat messages over Kick’s Pusher WebSocket.
This connects to the public Pusher channel for a chatroom and yields chat messages in real time. No authentication is required.
The chatroom ID can be found by visiting
https://kick.com/api/v2/channels/{slug} in a browser and searching
for "chatroom":{"id":.
§Example
use kick_api::LiveChatClient;
let mut chat = LiveChatClient::connect(27670567).await?;
while let Some(msg) = chat.next_message().await? {
println!("{}: {}", msg.sender.username, msg.content);
}Implementations§
Source§impl LiveChatClient
impl LiveChatClient
Sourcepub async fn connect(chatroom_id: u64) -> Result<Self>
pub async fn connect(chatroom_id: u64) -> Result<Self>
Connect to a chatroom by its ID.
Opens a WebSocket to Pusher and subscribes to the chatroom’s public channel. No authentication is required.
To find a channel’s chatroom ID, visit
https://kick.com/api/v2/channels/{slug} in a browser and look for
"chatroom":{"id":.
Sourcepub async fn next_event(&mut self) -> Result<Option<PusherEvent>>
pub async fn next_event(&mut self) -> Result<Option<PusherEvent>>
Receive the next raw Pusher event.
Returns all events from the subscribed channel (chat messages, pins,
subs, bans, etc.). Automatically handles Pusher-level pings and
internal protocol events. Returns None if the connection is closed.
Sourcepub async fn next_message(&mut self) -> Result<Option<LiveChatMessage>>
pub async fn next_message(&mut self) -> Result<Option<LiveChatMessage>>
Receive the next chat message.
Blocks until a chat message arrives. Automatically handles Pusher-level
pings and skips non-chat events. Returns None if the connection is
closed.