pushrax / node-rcon

A generic RCON protocol client for node.js
MIT License
133 stars 31 forks source link

Another question #23

Closed HEKOO321 closed 5 years ago

HEKOO321 commented 5 years ago

Hey sorry for disturbing but can you possibly tell me how do I excute commands using your rcon library, I did everything thing correctly, got "authed" message too, sorry again

pushrax commented 5 years ago

Once you're authed (i.e. in the auth callback, or somewhere else in your program after you've received the auth callback), call conn.send() with a command. For example:

var Rcon = require('../node-rcon');

var conn = new Rcon('localhost', 1234, 'password');
conn.on('auth', function() {
  console.log("Authed!");
  conn.send("help");
}).on('response', function(str) {
  console.log(str);
}).on('end', function() {
  console.log("Socket closed!");
  process.exit();
});

conn.connect();