kicksdk (JavaScript)
    Preparing search index...

    Interface ChatOptions

    connectChat's options. Every optional one may be left out or given as undefined (as a Partial<> or optional config carries it), with the same meaning.

    interface ChatOptions {
        channelId?: number;
        channels?: readonly string[];
        chatroomId: number;
        createSocket?: (url: string) => ChatSocket;
        endpoints?: Endpoints;
        fetch?: (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
        now?: () => number;
        onDrop?: (reason: string, drop: ChatDrop) => void;
        onError?: (error: unknown) => void;
        onState?: (s: ChatState) => void;
        timeoutMs?: number;
        WebSocket?: ChatSocketConstructor;
        onEvent(e: ChatEvent): void;
    }
    Index
    channelId?: number

    The channel; also locates the chat's region.

    channels?: readonly string[]

    The feeds to subscribe to; chatChannels(chatroomId, channelId) by default. The first is taken for the chat feed: its subscribe resets the reconnect backoff (with none listed, Kick accepting the connection does). A feed listed twice is subscribed and reported once.

    chatroomId: number

    The chatroom (website API chatroom.id).

    createSocket?: (url: string) => ChatSocket

    Opens the socket yourself, instead of WebSocket.

    endpoints?: Endpoints

    Kick's URLs to use instead; a key left out or undefined stays Kick's.

    fetch?: (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>

    The fetch to make Kick's requests with. Default: the global fetch.

    Type Declaration

      • (input: RequestInfo | URL, init?: RequestInit): Promise<Response>
      • Parameters

        • input: RequestInfo | URL
        • Optionalinit: RequestInit

        Returns Promise<Response>

    now?: () => number

    The session's clock, ms, only ever going forward. Default: performance.now(). A reading that is not a number from 0 to Number.MAX_SAFE_INTEGER (or a throw) is reported to onError once, and connectChat carries on with performance.now().

    onDrop?: (reason: string, drop: ChatDrop) => void

    A connection, or an attempt at one, ended; another follows after drop.waitMs.

    onError?: (error: unknown) => void

    A callback above threw, or now gave a reading it cannot use. Default: console.error. The connection carries on either way.

    onState?: (s: ChatState) => void

    The connection or its subscriptions changed.

    timeoutMs?: number

    How long a request, or the WebSocket handshake, may take, ms: above 0 and at most 2147483647 (setTimeout's limit; there is no "no timeout"). Default 10000. Out of range, or not a number: connectChat throws a RangeError.

    The WebSocket class, where the runtime has none (Node before 22: pass the ws package's). Default: the global WebSocket.