Class Client
Index
Constructors
Properties
Accessors
Methods
Constructors
constructor
- new
Client (options?): Client Instantiates a new Archipelago client. After creating, call Client.login to connect and authenticate to a server.
Parameters
Optional
options: ClientOptionsAdditional configuration options for this client. See ClientOptions for more information.
Returns Client
Properties
Readonly
deathLink
A helper object for handling DeathLink mechanics.
Readonly
items
A helper object for handling received items and hints.
Readonly
messages
A helper object for handling chat messages.
options
Current options for this client.
Readonly
package
A helper object for handling game data packages.
Readonly
players
A helper object for handling players (including self).
Readonly
room
A helper object for handling room state.
Readonly
socket
A helper object for handling websocket communication and AP network protocol.
Readonly
storage
A helper object for handling the data storage API.
Accessors
arguments
- get arguments(): Required<ConnectionOptions>
Returns a copy of this client's current connection arguments (or defaults, if never connected).
Returns Required<ConnectionOptions>
authenticated
- get authenticated(): boolean
Returns
true
if currently connected and authenticated to the Archipelago server.Returns boolean
game
- get game(): string
Returns the client's current game name (or an empty string, if never connected).
Returns string
name
- get name(): string
Returns the client's current slot name (or an empty string, if never connected).
Returns string
Methods
bounce
- bounce(targets, data): void
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.
Optional
games?: string[]Specific games that should receive this bounce.
Optional
slots?: number[]Specific slots that should receive this bounce.
Optional
tags?: string[]Specific clients with these tags that should receive this bounce.
- data: JSONRecord
The json-serializable data to send.
Returns void
Throws
UnauthenticatedError if attempting to send a bounce while not authenticated.
- targets: {
check
- check(...locations): void
Marks a list of locations as checked on the server.
Parameters
Rest
...locations: number[]Location ids to check.
Returns void
Throws
UnauthenticatedError if attempting to check locations while not authenticated.
goal
- goal(): void
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
Throws
UnauthenticatedError if not connected and authenticated.
login
- login<SlotData>(url, name, game?, options?): Promise<SlotData>
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.
Optional
options: ConnectionOptionsAdditional optional connection arguments.
Returns Promise<SlotData>
Throws
ArgumentError if slot name is empty.
Throws
LoginError if the server refuses the authentication attempt.
Remarks
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.
Example: Password Required and No Slot Data
import { Client } from "archipelago.js";
const client = new Client();
await client.login("archipelago.gg:38281", "Phar", "Clique", {
slotData: false,
password: "4444"
});Example: TypeScript with Slot Data
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");- SlotData extends JSONRecord
scout
- scout(locations, createHint?): Promise<Item[]>
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.
- If set to
Returns Promise<Item[]>
Throws
UnauthenticatedError if attempting to scout locations while not authenticated.
- locations: number[]
updateItemsHandling
- update
Items (items): voidHandling Request the server update the kinds of item received events this client should receive.
Parameters
- items: number
New item handling flags.
Returns void
Throws
UnauthenticatedError if not connected and authenticated.
- items: number
updateStatus
- update
Status (status): void Update the client status for the current player. For a list of known client statuses, see clientStatuses.
Parameters
- status: ClientStatus
The status to change to.
Returns void
Throws
UnauthenticatedError if not connected and authenticated.
Remarks
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.
- status: ClientStatus
updateTags
- update
Tags (tags): void Request the server update this client's tags.
Parameters
- tags: string[]
Tags to replace the current ones.
Returns void
Throws
UnauthenticatedError if not connected and authenticated.
- tags: string[]
The client that connects to an Archipelago server and provides helper methods and objects to facilitate communication, listen for events, and manage data.