Class Client

    The client that connects to an Archipelago server and provides helper methods and objects to facilitate communication, listen for events, and manage data.

    Constructors

    Properties

    deathLink: DeathLinkManager = ...

    A helper object for handling DeathLink mechanics.

    items: ItemsManager = ...

    A helper object for handling received items and hints.

    messages: MessageManager = ...

    A helper object for handling chat messages.

    options: Required<ClientOptions>

    Current options for this client.

    package: DataPackageManager = ...

    A helper object for handling game data packages.

    players: PlayersManager = ...

    A helper object for handling players (including self).

    room: RoomStateManager = ...

    A helper object for handling room state.

    socket: SocketManager = ...

    A helper object for handling websocket communication and AP network protocol.

    storage: DataStorageManager = ...

    A helper object for handling the data storage API.

    Accessors

    • get authenticated(): boolean
    • Returns true if currently connected and authenticated to the Archipelago server.

      Returns boolean

    • get game(): string
    • Returns the client's current game name (or an empty string, if never connected).

      Returns string

    • get name(): string
    • Returns the client's current slot name (or an empty string, if never connected).

      Returns string

    Methods

    • Send a bounce packet targeting any clients that fulfil any target parameters. Can be listened for by listening to "bounced" events on SocketManager.

      Parameters

      • targets: {
            games?: string[];
            slots?: number[];
            tags?: string[];
        }

        The targets to receive this bounce packet.

        • Optionalgames?: string[]

          Specific games that should receive this bounce.

        • Optionalslots?: number[]

          Specific slots that should receive this bounce.

        • Optionaltags?: string[]

          Specific clients with these tags that should receive this bounce.

      • data: JSONRecord

        The json-serializable data to send.

      Returns void

      UnauthenticatedError if attempting to send a bounce while not authenticated.

      If no targets are specified, no clients will receive this bounce packet.

    • Marks a list of locations as checked on the server.

      Parameters

      • Rest...locations: number[]

        Location ids to check.

      Returns void

      UnauthenticatedError if attempting to check locations while not authenticated.

      Locations that do not exist or have already been checked in the multi-world are ignored.

    • A shorthand for running Client.updateStatus(clientStatuses.goal). Once set, cannot be changed and if release and/or collect is set to automatic, will release/collect all items.

      Returns void

      UnauthenticatedError if not connected and authenticated.

    • Connect and authenticate to an Archipelago server.

      Type Parameters

      • SlotData extends JSONRecord

        If slot data is requested, this sets the type of the returning slot data.

      Parameters

      • url: string | URL

        The url of the server, including the protocol (e.g., wss://archipelago.gg:38281).

      • name: string

        The slot name this client will be connecting to.

      • game: string = ""

        The game name this client will be connecting to. If omitted, client will connect in "TextOnly" mode.

      • Optionaloptions: ConnectionOptions

        Additional optional connection arguments.

      Returns Promise<SlotData>

      ArgumentError if slot name is empty.

      LoginError if the server refuses the authentication attempt.

      TypeError if provided URL is malformed or invalid protocol.

      If the port is omitted, the client will default to 38281 (AP default).

      If the protocol is omitted, client will attempt to connect via wss, then fallback to ws if unsuccessful.

      Any paths, queries, fragments, or userinfo components of the provided url will be ignored.

      import { Client } from "archipelago.js";

      const client = new Client();

      await client.login("archipelago.gg:38281", "Phar", "Clique", {
      slotData: false,
      password: "4444"
      });
      import { Client } from "archipelago.js";

      type CliqueSlotData = {
      color: string
      hard_mode: boolean
      }

      const client = new Client();

      // slotData: CliqueSlotData { color: "red", hard_mode: false }
      const slotData = await client.login<CliqueSlotData>("archipelago.gg:38281", "Phar", "Clique");
    • Scout a list of locations for their containing items.

      Parameters

      • locations: number[]

        A list of location ids to scout.

      • createHint: 0 | 1 | 2 = 0

        Whether to create hints for these locations.

        • If set to 0, this packet will not create hints for any locations in this packet.
        • If set to 1, this packet will create hints for all locations in this packet and broadcast them to all relevant clients.
        • If set to 2, this packet will create hints for all locations in this packet and broadcast only new hints to all relevant clients.

      Returns Promise<Item[]>

      UnauthenticatedError if attempting to scout locations while not authenticated.

    • Request the server update the kinds of item received events this client should receive.

      Parameters

      • items: number

        New item handling flags.

      Returns void

      UnauthenticatedError if not connected and authenticated.

    • Update the client status for the current player. For a list of known client statuses, see clientStatuses.

      Parameters

      Returns void

      UnauthenticatedError if not connected and authenticated.

      The server will automatically set the player's status to clientStatuses.disconnected when all clients connected to this slot have disconnected, set the status to clientStatuses.connected if a client connects to this slot when previously set to clientStatuses.disconnected, or ignores any future updates if ever set to clientStatuses.goal.

      import { Client, clientStatuses } from "archipelago.js";

      const client = new Client();
      await client.login("wss://archipelago.gg:38281", "Phar", "Clique");

      // Mark client as ready to start.
      client.updateStatus(clientStatuses.ready);
    • Request the server update this client's tags.

      Parameters

      • tags: string[]

        Tags to replace the current ones.

      Returns void

      UnauthenticatedError if not connected and authenticated.