Interface ClientToAIServer

This is an exhaustive list of the messages that the client can send to the AI servers.

interface ClientToAIServer {
    ai-analyze-position: ((data) => any);
    ai-analyze-subscribe: ((data) => void);
    ai-analyze-unsubscribe: ((data) => void);
    ai-analyze-variation: ((data) => void);
    ai-nexus-status-subscribe: ((data) => void);
    ai-nexus-status-unsubscribe: ((data) => void);
    ai-relay-analyzed-position: ((data) => any);
    ai-review-connect: ((data) => void);
    ai-review-disconnect: ((data) => void);
    authenticate: ((data) => undefined | {
        id: number;
        username: string;
    });
    net/connects: ((data) => void);
    net/ping: ((data) => void);
    net/route_latency: ((data) => void);
    net/timeout: ((data) => void);
    net/unrecoverable_error: ((data) => void);
}

Hierarchy (view full)

Properties

ai-analyze-position: ((data) => any)

Requests a position be analyzed, intermediate and final results are sent to the given channel. The final response is returned as well.

Type declaration

    • (data): any
    • Parameters

      • data: {
            black_prisoners: number;
            board: number[][];
            board_string?: string;
            channel_id: string;
            komi: number;
            moves?: JGOFMove[];
            player: JGOFNumericPlayerColor;
            rules: RuleSet;
            uuid: string;
            white_prisoners: number;
        }
        • black_prisoners: number

          Number of captures black has

        • board: number[][]

          Board position state

        • Optional board_string?: string

          Unique board string used to relay to other clients

        • channel_id: string

          Channel identifier, for instance ai-position-analysis-stream-review-

        • komi: number

          Komi

        • Optional moves?: JGOFMove[]

          Moves to replay

        • player: JGOFNumericPlayerColor

          Whose turn it is

        • rules: RuleSet

          Ruleset to use

        • uuid: string

          UUID identifying the request

        • white_prisoners: number

          Number of captures white has

      Returns any

ai-analyze-subscribe: ((data) => void)

Subscribers to analyze position calls

Type declaration

    • (data): void
    • Parameters

      • data: {
            channel_id: string;
        }
        • channel_id: string

      Returns void

ai-analyze-unsubscribe: ((data) => void)

Un-subscribers to analyze position calls

Type declaration

    • (data): void
    • Parameters

      • data: {
            channel_id: string;
        }
        • channel_id: string

      Returns void

ai-analyze-variation: ((data) => void)

Type declaration

    • (data): void
    • Parameters

      • data: {
            ai_review_id: string | number;
            from: number;
            game_id: string | number;
            uuid: string;
            variation: string;
        }
        • ai_review_id: string | number

          The AI review id we're basing our analysis off of

        • from: number

          The move number we're branching from

        • game_id: string | number

          The game id we're analyzing

        • uuid: string

          AI UUID

        • variation: string

          Move string

      Returns void

ai-nexus-status-subscribe: ((data) => void)

Subscribe to AI nexus status updates (admin only)

Type declaration

    • (data): void
    • Parameters

      • data: Record<string, never>

      Returns void

ai-nexus-status-unsubscribe: ((data) => void)

Unsubscribe from AI nexus status updates

Type declaration

    • (data): void
    • Parameters

      • data: Record<string, never>

      Returns void

ai-relay-analyzed-position: ((data) => any)

Relay an already analyzed position out to any other viewers

Type declaration

    • (data): any
    • Parameters

      • data: {
            channel_id: string;
            data: any;
        }
        • channel_id: string

          Channel identifier, for instance ai-position-analysis-stream-review-

        • data: any

      Returns any

ai-review-connect: ((data) => void)

Type declaration

    • (data): void
    • Parameters

      • data: {
            ai_review_id: string | number;
            game_id: string | number;
            uuid: string;
        }
        • ai_review_id: string | number

          The AI review id we're basing our analysis off of

        • game_id: string | number

          The game id we're reviewing

        • uuid: string

          AI UUID

      Returns void

ai-review-disconnect: ((data) => void)

Type declaration

    • (data): void
    • Parameters

      • data: {
            uuid: string;
        }
        • uuid: string

          AI UUID

      Returns void

authenticate: ((data) => undefined | {
    id: number;
    username: string;
})

Authenticate with the server.

Prior to authentication, you should perform a GET request to /api/v1/ui/config to get the current configuration. Within the returned JSON you will find all of the necessary fields to authenticate.

Type declaration

    • (data): undefined | {
          id: number;
          username: string;
      }
    • Parameters

      • data: {
            bot_apikey?: string;
            bot_username?: string;
            client?: string;
            client_version?: string;
            device_id?: string;
            jwt: string;
            language?: string;
            language_version?: string;
            user_agent?: string;
        }
        • Optional bot_apikey?: string

          Bot API key, if applicable

        • Optional bot_username?: string

          Bot username connecting, if applicable

        • Optional client?: string

          Client name (your application name)

        • Optional client_version?: string

          Client version string.

        • Optional device_id?: string

          Client generated unique id for the device.

        • jwt: string

          The JSON Web Token (user_jwt field) from /api/v1/ui/config. If connecting as a guest, send ""

        • Optional language?: string

          ISO 639-1 language code used on this device.

        • Optional language_version?: string

          The version of the translation dictionary.

        • Optional user_agent?: string

          Browser user agent (or websocket library)

      Returns undefined | {
          id: number;
          username: string;
      }

net/connects: ((data) => void)

Report connection count and device info for analytics. Sent on each (re)connect to track route reliability.

Type declaration

    • (data): void
    • Parameters

      • data: {
            device_info: DeviceInfo;
            previous_connection_duration_ms: number;
            route: string;
            times_connected: number;
        }
        • device_info: DeviceInfo

          Device information for analytics segmentation

        • previous_connection_duration_ms: number

          Duration in ms of the previous connection, or 0 if first connect

        • route: string

          Network route name (e.g. "cloudflare", "google", "public")

        • times_connected: number

          How many times the client has connected this session

      Returns void

net/ping: ((data) => void)

Sends a ping to the server. This message should be sent regularly. The default interval is 10 seconds. This keeps the connection alive and allows a client to measure clock drift and latency, both of which are vital to adjusting the client's game clock displays.

Type declaration

    • (data): void
    • Parameters

      • data: {
            client: number;
            drift: number;
            latency: number;
        }
        • client: number

          Client timestamp - milliseconds since epoch

        • drift: number

          Last clock drift measurement, or 0

        • latency: number

          Last latency measurement, or 0

      Returns void

net/route_latency: ((data) => void)

Report measured latency for a specific network route

Type declaration

    • (data): void
    • Parameters

      • data: {
            latency: number;
            mobile: boolean;
            route: string;
        }
        • latency: number

          Measured latency in milliseconds

        • mobile: boolean

          Whether the client is on a mobile device

        • route: string

          Network route name

      Returns void

net/timeout: ((data) => void)

Report a ping timeout event for diagnostics. Sent when the client detects that a ping response (pong) was not received within the expected timeout window.

Type declaration

    • (data): void
    • Parameters

      • data: {
            device_info: DeviceInfo;
            in_live_game: boolean;
            latency: number;
            ping_interval: number;
            route: string;
            timeout_delay: number;
            times_connected: number;
        }
        • device_info: DeviceInfo

          Device information

        • in_live_game: boolean

          Whether the client is currently viewing their own live game

        • latency: number

          Last measured latency before timeout (ms)

        • ping_interval: number

          Ping interval at time of timeout (ms)

        • route: string

          Network route name (e.g. "cloudflare", "google", "public")

        • timeout_delay: number

          Timeout delay threshold that was exceeded (ms)

        • times_connected: number

          How many times the client has connected this session

      Returns void

net/unrecoverable_error: ((data) => void)

Report an unrecoverable WebSocket error (e.g. close code 1014/1015)

Type declaration

    • (data): void
    • Parameters

      • data: {
            code: number;
            device_info: DeviceInfo;
            route: string;
            tag: string;
            times_connected: number;
        }
        • code: number

          WebSocket close code

        • device_info: DeviceInfo

          Device information

        • route: string

          Network route name

        • tag: string

          Error tag for categorization

        • times_connected: number

          Connection count at time of error

      Returns void