Skip to content
Browse files

Finished protocol reader/writers, added callbacks

Wrote Package.json
  • Loading branch information...
1 parent 24d7cbf commit 7283ff9b1668668ee916d801ec1e6779f8feae76 James committed
Showing with 19 additions and 9 deletions.
  1. +17 −8 node-rcon.js
  2. +2 −1 package.json
View
25 node-rcon.js
@@ -5,11 +5,15 @@ this.socket=null;
this.reqID=1;
this.authed = false;
this.online = false;
-this.isOnline = function() {return this.online;}
+
+this.isOnline = function() {return this.online;}//return online status of connection
+
+//Callbacks
this.onResponse = function(data){console.log(data)};
this.onAuthFail = function(){console.log("AUTH FAIL");};
+
+//connect command
this.connect = function(ip,port,password){
- //TODO: CONNECT HERE//
this.socket = net.createConnection(port,ip);
this.socket.rcon = this;
this.socket.on('close',function(){this.rcon.authed=false;this.rcon.online=false});
@@ -35,6 +39,8 @@ this.sendCommand = function(command) {
this.reqID +=1;
return this.reqID-1;
};
+
+//makes a packet for RCON
this.makePacket = function(req,type,S1){
var b = new Buffer(14+S1.length);
@@ -45,12 +51,15 @@ this.makePacket = function(req,type,S1){
b.writeInt16LE(0,(12+S1.length));
return b;
}
+
+//read a packet out into a JSON object
this.readPacket = function(packet){
-return {
-reqID: packet.readInt32LE(4),
-type: packet.readInt32LE(8),
-data:packet.toString('utf8',12,packet.length-2)};
-};
-return this;
+ return {
+ reqID: packet.readInt32LE(4),
+ type: packet.readInt32LE(8),
+ data:packet.toString('utf8',12,packet.length-2)
};
+ };
+return this;
+};
View
3 package.json
@@ -1,5 +1,6 @@
{
"name": "node-rcon"
- , "version": "0.0.1"
+ , "version": "0.1"
, "main":"node-rcon.js"
+ , "description":"RCON protocol support. Provides Asyncronous support for the RCON (Remote Console) Protocol, used in various games for remote server management"
}

0 comments on commit 7283ff9

Please sign in to comment.
Something went wrong with that request. Please try again.