prestonp / simple-rcon

Simple, painless node RCON client for Source servers

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

simple-rcon

Build Status Coverage Status

Dependency Status devDependency Status

Simple, painless node RCON client for Source servers.

Install
npm install simple-rcon
Examples
var Rcon = require('simple-rcon');
var client = new Rcon({
  host: '127.0.0.1',
  port: '27015',
  password: 'rconPassword'
}).exec('changelevel cp_badlands', function() {
  client.exec('say \'hey look the map changed!\'');
}).exec('status', function(res) {
  console.log('Server status', res.body);
}).exec('sm_kick somebody', function() {
  client.close();
}).connect();

client.on('authenticated', function() {
  console.log('Authenticated!');
}).on('connected', function() {
  console.log('Connected!');
}).on('disconnected', function() {
  console.log('Disconnected!');
});
API
  • new Rcon([options]):

    • options.host: string containing host address (default '127.0.0.1')
    • options.port: int for server port number (default 27015)
    • options.password: string containing rcon password
    • options.timeout: int for socket timeout (default 5000ms)
  • exec(command, callback): Sends rcon commands to server. If exec is called before the authenticated event is triggered, the commands will be buffered. Upon authentication, all commands will be executed in order.

    • command - String containing remote command
    • callback - Function with signature function(res) {}
  • close(): Closes connection

Events
  • connecting Client connecting to server.
  • connected Client connected to server, although not authenticated.
  • authenticated Client authenticated successfully with rcon password.
  • error Connection interrupted by an error. Event callback accepts a single err argument.
  • disconnecting Connecting is about to close.
  • disconnected Connection has been closed, interrupted, or dropped.
Contributors
Further Reading

Read more about the RCON Protocol

License

MIT

About

Simple, painless node RCON client for Source servers

License:MIT License


Languages

Language:JavaScript 100.0%