JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 94
  • Score
    100M100P100Q65626F
  • License MIT

A modern RCON client implementation written in TypeScript (targeting ES2015) and is async/await friendly.

Package Exports

  • rcon-ts

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (rcon-ts) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

rcon-ts

A modern RCON client implementation written in TypeScript (targeting ES2015) and is async/await friendly.

(Originally node-modern-rcon.)

NOTE: This has only been tested with Minecraft. So be aware of possible bugs with other server implementations. Feel free to submit a PR if you have any problems.

Installation

npm install rcon-ts --save

API

Initialization

Creates a new Rcon object.

const rcon = new Rcon({
    host: "host-path",
    port: 25575 /*default*/, 
    password: "required",
    timeout: 5000 /*default (5 seconds)*/
});

Connecting

Connects with the credentials provided in the constructor. Can be awaited on.

rcon.connect();

Sending

Executes the provided command on the open connection and returns the response.

let response = await rcon.send("[rcon request]");

Disconnecting

Ends the current socket and subsequently signals to any pending request that the connection was disconnected.

rcon.disconnect();

Code Example

import Rcon from 'rcon-ts';
const rcon = new Rcon('localhost', 'some password');

async function sendHelp()
{
    rcon.connect();
    // safe to immediately setup requests without waiting.
    await rcon.send('help');
    rcon.disconnect();
}

sendHelp();

Factorio Setup

For usage or testing, make sure you are starting the game from command line.

Example:

factorio.exe --start-server [save-name].zip --rcon-port [port] --rcon-password [password]