1.1.1 • Published 19 days ago

rustcon-js v1.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
19 days ago

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

1.1.1

19 days ago

1.1.0

22 days ago

1.0.0

2 months ago