Adding Servers

You can add servers to interact with via your application by following the documentation on this page.

Example Code

import { RCEManager, RCEIntent } from "rce.js";

const rce = new RCEManager();
const success = await rce.addServer({
    identifier: "my-solo-duo-trio-3x",
    rcon: {
        host: "127.0.0.1",
        port: 1234,
        password: "testing123"
    },
    state: ["trio", "3x"],
    intents: [RCEIntent.ServerInfo, RCEIntent.PlayerList],
    intentTimers: {
        [RCEIntent.ServerInfo]: 30_000,
        [RCEIntent.PlayerList]: 45_000
    },
    reconnection: {
        enabled: true,
        interval: 10_000, // 10 seconds
        maxAttempts: -1 // unlimited
    },
});

Server Options

Below is a brief explanation of each option when defining new server(s).

Identifier

The identifier is a unique string which allows rce.js to identify the correct server(s) events are being received for or commands are being sent to. We suggest using a UUID for this!

Type: String

Required: Yes

RCON

The RCON information to connect to the rust server, including IP address, RCON port and RCON password.

Type: { host: String, port: Number, password: String }

Required: Yes

State

The state is an array of anything you wish to implement. For example, you can add "pvp" in your state array and check later in your code is the state array includes "pvp" to make your application behave differently if the server is a PvP-only server. You can use the state for anything.

Type: Any[]

Required: Yes

Default: []

Reconnection

If your server disconnects for any reason, enabling this will attempt reconnecting in intervals.

Type: { enabled: Boolean, interval: Number, maxAttempts: Number }

Required: No

Intents

Define a list of intents, this could include periodically fetching key information, or enabling caching of key information.

RCEIntent.ServerInfo - enables periodic "serverinfo" command fetching and caching

RCEIntent.PlayerList - enables periodic "playerlist" command fetching and caching

RCEIntent.Frequencies - enables periodic "rf.listboardcasters" command fetching and caching

RCEIntent.Gibs - enables periodic gib-related fetching and caching to emit RCEEvent.EventStart when the patrol helicopter or bradley APC is destroyed

RCEIntent.Kits - enables periodic "kit list" and "kit info" command fetching and caching

RCEIntent.CustomZones - enables periodic "zones.listcustomzones" and "zones.customzoneinfo" command fetching and caching

RCEIntent.Teams - add a "team" object onto the IPlayer interface

RCEIntent.RoleInfo - add a "role" object onto the IPlayer interface

Type: RCEIntent[]

Required: No

Intent Timers

Set specific interval timers on each data fetching intent instead of using default timer values.

Type: Record<RCEIntent, number>

Required: No

Last updated