Interface ClientToServerBase

Messages that clients send, regardless of target server

interface ClientToServerBase {
    authenticate: ((data) => undefined | {
        id: number;
        username: string;
    });
    net/ping: ((data) => void);
}

Hierarchy (view full)

Properties

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/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