Skip to content

RustCON JS is a JavaScript library for interacting with Rust servers via WebSockets (Web RCON)

License

Notifications You must be signed in to change notification settings

RustCONxyz/rustcon-js

Repository files navigation

RustCON JS

RustCON JS is a JavaScript library for interacting with Rust servers via WebSockets (Web RCON)

Also works on browsers and Deno!

Links

Installation

npm install rustcon-js
yarn add rustcon-js
pnpm add rustcon-js
bun add rustcon-js

Also available via Deno package manager.

import { RconConnection } from "https://deno.land/x/rustcon/mod.ts";

Example Usage

import { RconConnection } from "rustcon-js";
// import { RconConnection } from "https://deno.land/x/rustcon/mod.ts";

const connection = new RconConnection({

    ip: "127.0.0.1",

    port: 28016, // Optional, default is 28016

    password: "password"

});

connection.on("connected", async () => {

    console.log("Connected to the Rust server!");

    const response = await connection.send("say Hello from RustCON JS!");

    console.log("Response from the Rust server:", response);

    const serverInfo = await connection.server.getInfo();

    console.log("Server info:", serverInfo);

    const playerList = await connection.players.getAll();

    console.log("Player list:", playerList);    

    setTimeout(() => {

        connection.disconnect();

    }, 10000);

});

connection.on("message", (message) => {

    console.log("Message from the Rust server:", message);

});

connection.on("error", (error) => {

    console.error("An error occurred:", error);

});

connection.on("disconnected", () => {

    console.log("Disconnected from the Rust server!");

});

connection.connect();

License

MIT

About

RustCON JS is a JavaScript library for interacting with Rust servers via WebSockets (Web RCON)

Resources

License

Stars

Watchers

Forks

Sponsor this project

Packages

No packages published