UNPKG

rcon-node

Version:

A TypeScript RCON client library for modern game servers.

68 lines 2.74 kB
import { EventEmitter } from "node:events"; import { Game } from "./game"; import { MinecraftClient } from "./clients/minecraft.client"; import { RustClient } from "./clients/rust.client"; import { SevenDaysToDieClient } from "./clients/seven-days-to-die.client"; import { ArkSurvivalEvolvedClient } from "./clients/ark-survival-evolved.client"; import { ArkSurvivalAscendedClient } from "./clients/ark-survival-ascended.client"; import { DayZClient } from "./clients/dayz.client"; import { PalworldClient } from "./clients/palworld.client"; import { ArmaReforgerClient } from "./clients/arma-reforger.client"; import { ScumClient } from "./clients/scum.client"; import { ValheimClient } from "./clients/valheim.client"; export class Rcon extends EventEmitter { constructor(options) { super(); switch (options.game) { case Game.RUST: this.client = new RustClient(options); break; case Game.SEVEN_DAYS_TO_DIE: this.client = new SevenDaysToDieClient(options); break; case Game.ARK_SURVIVAL_EVOLVED: this.client = new ArkSurvivalEvolvedClient(options); break; case Game.ARK_SURVIVAL_ASCENDED: this.client = new ArkSurvivalAscendedClient(options); break; case Game.DAYZ: this.client = new DayZClient(options); break; case Game.PALWORLD: this.client = new PalworldClient(options); break; case Game.ARMA_REFORGER: this.client = new ArmaReforgerClient(options); break; case Game.SCUM: this.client = new ScumClient(options); break; case Game.VALHEIM: this.client = new ValheimClient(options); break; case Game.MINECRAFT: default: this.client = new MinecraftClient(options); break; } this.client.on("connect", () => this.emit("connect")); this.client.on("authenticated", () => this.emit("authenticated")); this.client.on("response", (response) => this.emit("response", response)); this.client.on("error", (error) => this.emit("error", error)); this.client.on("end", () => this.emit("end")); } send(command) { return this.client.send(command); } end() { this.client.end(); } static async connect(options) { const rcon = new Rcon(options); await rcon.client.connect(); await rcon.client.testAuthentication(); return rcon; } } //# sourceMappingURL=rcon.js.map