Client

API reference for Client in @erlcjs/core.

The main client for interacting with the ER:LC API and gateway. Manages multiple ER:LC game servers, each with its own caches and polling loop.

Signature:

declare class Client extends EventEmitter<ClientEvents>

Extends: EventEmitter<ClientEvents>

#Constructors

Constructor

Modifiers

Description

(constructor)(options)

Creates an instance of Client.

#Properties

Property

Modifiers

Type

Description

globalAppId?

string | number

(Optional) Global App ID.

isPolling

readonly

boolean

Whether any managed server is currently being polled.

options

ClientOptions

rest

RestManager

REST Manager for sending manual requests to the ER:LC API, shared across all servers.

servers

ServerManager

Collection of the game servers managed by this client, keyed by server ID.

#Methods

Method

Modifiers

Description

addServer(key)

Adds a server to the client at runtime, returning the created server. Polling is started automatically if the client options enable auto-start polling.

destroy()

Destroys the client, cleaning up resources and stopping any ongoing operations.

onceReady()

Resolves once the client is ready (after every server's first poll), or immediately if it is already ready.

registerCommand(cmd)

Registers an in-game custom command globally, available on all managed servers.

removeServer(id)

Removes and destroys a server by its ID, stopping its polling and clearing its caches.

startPolling(pollRateMs)

Starts polling the ER:LC API for all servers, restarting any existing polls.

stopPolling()

Stops polling the ER:LC API for all servers.

unregisterCommand(commandName)

Unregisters a globally registered in-game custom command.

waitFor(event, timeoutMs)

Waits for a specific event to be emitted.