# rustcon-js

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

Latest version **1.1.1** (published 2024-05-03) · MIT license · 0 weekly downloads

## Install

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

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.1 |
| Published | 2024-05-03 |
| First published | 2024-03-31 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 88.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Kopter |
| Maintainers | kop7er |
| Keywords | rcon, rust, rustcon, webrcon |

## Links

- npm: https://www.npmjs.com/package/rustcon-js
- Repository: https://github.com/RustCONxyz/rustcon-js
- Homepage: https://github.com/RustCONxyz/rustcon-js#readme
- Issues: https://github.com/RustCONxyz/rustcon-js/issues
- npm.io page: https://npm.io/package/rustcon-js

## Dependencies (2)

- [unws](https://npm.io/package/unws.md) ^0.2.4
- [events](https://npm.io/package/events.md) ^3.3.0

## Alternatives

- [jsforce](https://npm.io/package/jsforce.md) — 851.2K weekly downloads
- [react-native-qrcode-svg](https://npm.io/package/react-native-qrcode-svg.md) — 693.5K weekly downloads
- [@salesforce/plugin-data](https://npm.io/package/@salesforce/plugin-data.md) — 394.9K weekly downloads
- [@backstage/plugin-search-common](https://npm.io/package/@backstage/plugin-search-common.md) — 308.5K weekly downloads
- [@chain-registry/types](https://npm.io/package/@chain-registry/types.md) — 38.4K weekly downloads

## Recent versions

- 1.1.1 (latest) — 2024-05-03
- 1.1.0 — 2024-04-29
- 1.0.0 — 2024-03-31

## README

# RustCON JS

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

Also works on browsers and Deno!

## Links

- [Website](https://rustcon.xyz)
- [Documentation](https://rustcon.xyz/developers)
- [GitHub](https://github.rustcon.xyz/)
- [Support](https://support.rustcon.xyz/)

## Installation

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

Also available via [Deno package manager](https://deno.land/x/rustcon).

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

## Example Usage

```js
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](/LICENSE)

---
_Source: https://npm.io/package/rustcon-js · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
