mbr-rcon

1.1.0 • Public • Published

mbr-rcon

My Valve Source RCON (remote console) protocol implementation. Only TCP is supported yet.

Example

All commands can be called directly one after another. They are being put in queue, and executed accordingly. If any command fails, the whole queue is being cleared of tasks.

const Rcon = require('mbr-rcon');

const rcon = new Rcon({
  host: 'localhost',      // RCON hostname to connect to (localhost is default).
  port: 27015,            // Connection port (27015 is default).
  pass: '123',            // Password to RCON server.
  onClose: function () {} // Callback in case of connection being closed.
});

const connection = rcon.connect({
  onSuccess: function () {},   // Callback in case of successfull connection.
  onError: function (error) {} // Callback in case of connection error.
});

connection.auth({
  password: '123',              // Password can be provided here. If this field is omitted,
                                // then password from constructor will be used.
  onSuccess: function () {},    // Callback in case of successfull authentication.
  onError: function (error) {}  // Callback in case of authentication failure.
});

connection.send(
  'command',                            // Command to be sent to the server.
  {
    onSuccess: function (response) {},  // Callback with server response.
    onError: function (error) {}        // Callback in case of execution failure.
  }
);

connection.close();   // Close rcon server.

You can also chain commands, like so:

new Rcon(<...>).connect().auth().send().send().<...>.close();

Package Sidebar

Install

npm i mbr-rcon

Weekly Downloads

6

Version

1.1.0

License

ISC

Unpacked Size

14 kB

Total Files

12

Last publish

Collaborators

  • madbrozzer