Simple, painless node RCON client for Source servers.
npm install simple-rcon
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!');
});
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 passwordoptions.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 commandcallback
- Function with signature function(res) {}
close()
: Closes connection
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.Read more about the RCON Protocol
MIT