phoenix
    Preparing search index...

    Interface SocketOptions

    interface SocketOptions {
        authToken?: string;
        binaryType?: string;
        debug?: boolean;
        decode?: (
            payload: string | ArrayBuffer,
            callback: (decoded: Message) => void,
        ) => void;
        encode?: (
            payload: any,
            callback: (encoded: string | ArrayBuffer) => void,
        ) => void;
        heartbeatIntervalMs?: number;
        logger?: (kind: string, msg: string, data?: any) => void;
        longpollerTimeout?: number;
        longPollFallbackMs?: number;
        params?: Record<string, any> | (() => Record<string, any>);
        reconnectAfterMs?: (tries: number) => number;
        rejoinAfterMs?: (tries: number) => number;
        sessionStorage?: {
            getItem(key: string): string;
            removeItem(key: string): void;
            setItem(key: string, value: string): void;
        };
        timeout?: number;
        transport?: Transport;
        vsn?: string;
    }
    Index

    Properties

    authToken?: string

    The optional authentication token to be exposed on the server under the :auth_token connect_info key.

    binaryType?: string

    The binary type to use for binary WebSocket frames.

    Defaults to "arraybuffer"

    debug?: boolean

    When true, enables debug logging. Default false.

    decode?: (
        payload: string | ArrayBuffer,
        callback: (decoded: Message) => void,
    ) => void

    The function to decode incoming messages.

    Defaults to JSON:

    (payload, callback) => callback(JSON.parse(payload))
    
    encode?: (
        payload: any,
        callback: (encoded: string | ArrayBuffer) => void,
    ) => void

    The function to encode outgoing messages.

    Defaults to JSON encoder.

    heartbeatIntervalMs?: number

    The millisec interval to send a heartbeat message.

    Defaults to 30000.

    logger?: (kind: string, msg: string, data?: any) => void

    The optional function for specialized logging, ie:

    function(kind, msg, data) {
    console.log(`${kind}: ${msg}`, data)
    }
    longpollerTimeout?: number

    The maximum timeout of a long poll AJAX request.

    Defaults to 20s (double the server long poll timer).

    longPollFallbackMs?: number

    The millisecond time to attempt the primary transport before falling back to the LongPoll transport. Disabled by default.

    params?: Record<string, any> | (() => Record<string, any>)

    The optional params to pass when connecting.

    reconnectAfterMs?: (tries: number) => number

    The optional function that returns the socket reconnect interval, in milliseconds.

    Defaults to stepped backoff of:

    function(tries){
    return [10, 50, 100, 150, 200, 250, 500, 1000, 2000][tries - 1] || 5000
    }
    rejoinAfterMs?: (tries: number) => number

    The optional function that returns the millisec rejoin interval for individual channels.

    function(tries){
    return [1000, 2000, 5000][tries - 1] || 10000
    }
    sessionStorage?: {
        getItem(key: string): string;
        removeItem(key: string): void;
        setItem(key: string, value: string): void;
    }

    An optional Storage compatible object Phoenix uses sessionStorage for longpoll fallback history. Overriding the store is useful when Phoenix won't have access to sessionStorage. For example, This could happen if a site loads a cross-domain channel in an iframe. Example usage:

    class InMemoryStorage {
      constructor() { this.storage = {} }
      getItem(keyName) { return this.storage[keyName] || null }
      removeItem(keyName) { delete this.storage[keyName] }
      setItem(keyName, keyValue) { this.storage[keyName] = keyValue }
    }
    
    timeout?: number

    The default timeout in milliseconds to trigger push timeouts.

    Defaults to 10000

    transport?: Transport

    The Websocket Transport, for example WebSocket or Phoenix.LongPoll.

    Defaults to WebSocket with automatic LongPoll fallback if WebSocket is not defined. To fallback to LongPoll when WebSocket attempts fail, use longPollFallbackMs: 2500.

    vsn?: string

    The serializer's protocol version to send on connect.

    Defaults to "2.0.0".