Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example for less adept users #44

Open
surpriseassociate opened this issue May 4, 2022 · 1 comment
Open

Example for less adept users #44

surpriseassociate opened this issue May 4, 2022 · 1 comment

Comments

@surpriseassociate
Copy link

Hi!

Full disclaimer; I'm not very good at Javascript. I did a bit with jQuery/Javascript for web, but I'm just starting out with NodeJS.

I'm trying to build a forever looping service that just polls my Ark servers for the chat log, and posts it to my Discord server via webhooks. Unfortunately, I'm having issues using the response back from RCON outside of the .on() functions.

I used both examples to create something like this, and it fails because 'response' is not specified.

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

var conn = new Rcon('localhost', 1234, 'password');

conn.on('auth', function() {
  console.log("Authenticated");
  console.log("Sending command: help")
  conn.send("help");
}).on('response', function(str) {
  var response = str;
  console.log("Response: " + str);
}).on('error', function(err) {
  console.log("Error: " + err);
}).on('end', function() {
  console.log("Connection closed");
  process.exit();
});

conn.connect();

if (response == "some response") {
    console.log("Do something with " + response);
}

It would be nice to have an example that shows how to use the data outside of the .on() function. It may be seen as baby sitting but server admins aren't always the most saavy nodejs devs, and it's rather inhibiting getting stuck on things like this.

Googling didn't provide extraordinarily great assistance because I could use promises, but I don't know how that applies in context to this module.

@eX-C0n
Copy link

eX-C0n commented Oct 6, 2022

I am also trying to do the same thing. Respond if you figured something out!

-- @ex#1996 on disc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants