io library

connectChat: Kick's chat feed over dart:io's HttpClient and WebSocket.

Classes

Backoff
Reconnect delays: 1 s doubling to 30 s, back to 1 s once connected, and a slower stage for terminal closes (5, 10, 20, then 30 minutes, see nextDelayFor). The core's realtime::Backoff, in milliseconds: a first wait under 1 ms counts as 1 ms, and a longest wait below the first is raised to it.
ChatConnection
A live connection to one channel's chat, from connectChat.
ChatDrop
A connection lost or not made, for onDropInfo in connectChat. A reconnect follows after retryIn, unless the connection is closed first.
Content
Chat message text.
Events
Kick's chat-feed events, typed: {"type": "chat_message", ...}.
KickRequest
A request to send, with whatever HTTP client the app uses.
PublicApi
Kick's official API (api.kick.com/public/v1).
Realtime
Kick's realtime chat feed. Its server only accepts a WebSocket with Origin: https://kick.com; connectChat in package:kicksdk/io.dart sends it.
Session
One connection's worth of Kick's Centrifugo protocol. Each method returns the actions to carry out: {"action": "send", "text": ...}, {"action": "close", "code", "reason", "terminal", "retry_after_ms"} (close the socket, call closed, wait Backoff.nextDelayFor(retry_after_ms, random) and reconnect, with a new client id if terminal: never stop for good on one, docs/KICK.md ยง6.1), refresh_token (fetch a token for the same client id and pass it to refresh; if that fails, carry on: Kick ends the connection when the old token runs out), connected, subscribed, unsubscribed, subscribe_failed, event. subscribed for the chat feed (the first of Realtime.chatChannels) is when to call Backoff.reset. Times are milliseconds.
Webhooks
Kick's official webhooks.
Website
kick.com's own endpoints (kick.com/api/v2): undocumented, a grey area under Kick's terms. Treat a failure as a gap.

Functions

connectChat({required int chatroomId, int? channelId, List<String>? channels, required void onEvent(Map<String, dynamic> event), void onState(bool connected, List<String> subscribed)?, void onDrop(String reason)?, void onDropInfo(ChatDrop drop)?, void onError(Object error, StackTrace stack)?, Map<String, String>? endpoints, Duration timeout = const Duration(seconds: 10), Backoff? backoff}) → ChatConnection
Connects to one channel's chat and keeps it up until ChatConnection.close.

Typedefs

Json = Map<String, dynamic>

Exceptions / Errors

KickException
Kick answered with an error, or a call could not be made.