Browse files

Removed debug printouts and more consistent naming

  • Loading branch information...
1 parent 9acb3e5 commit c87ff031ec6cf9cb6e54b94eabfa694dfa9ce342 @kmpm committed Nov 21, 2011
Showing with 18 additions and 23 deletions.
  1. +8 −13 mcquery.js
  2. +10 −10 test/base-test.js
View
21 mcquery.js
@@ -17,7 +17,6 @@ function makePacket(type,session, payloadBuffer){
var pLength = typeof(payloadBuffer)==='undefined'? 0 : payloadBuffer.length;
var sLength = typeof(session.sessionToken)==='undefined'? 0: 4;
var b = new Buffer(7 + sLength+pLength);
- //console.log("pLength:", pLength, session);
b.writeUInt8(0xFE, 0);
b.writeUInt8(0xFD, 1);
b.writeUInt8(type, 2);
@@ -45,22 +44,22 @@ function readPacket(data){
var r = readString(data);
if(r.text !== 'splitnum'){
//basic stat
- res.motd = r.text;
+ res.hostname = r.text;
r = readString(data, r.offset);
- res.gameType = r.text;
+ res.gametype = r.text;
r = readString(data, r.offset);
- res.worldName = r.text;
+ res.map = r.text;
r = readString(data, r.offset);
- res.playersOnline = parseInt(r.text);
+ res.numplayers = parseInt(r.text);
r = readString(data, r.offset);
- res.playersMax = parseInt(r.text);
+ res.maxplayers = parseInt(r.text);
- res.port = data.readUInt16LE(r.offset);
+ res.hostport = data.readUInt16LE(r.offset);
r = readString(data, r.offset +2);
- res.host = r.text;
+ res.hostip = r.text;
}
else {
var offset=r.offset;
@@ -73,7 +72,6 @@ function readPacket(data){
key = r.text;
r = readString(data, offset); offset=r.offset;
value = r.text;
- console.log(key, 'string', value);
res[key]=value;
}
res.extra2 = data.readUInt16LE(offset);offset+=2;
@@ -85,7 +83,6 @@ function readPacket(data){
offset+=1;
r=readString(data, offset); offset=r.offset;
while(r.text.length>=1){
- console.log(r.text);
players.push(r.text);
r=readString(data, offset); offset=r.offset;
}
@@ -113,7 +110,6 @@ var Query = module.exports = function Query(){
this.requestQueue={};
socket.on('message', function(msg, rinfo){
- //console.log("message:", msg);
var res = readPacket(msg);
res.rinfo = rinfo;
deQueue(res);
@@ -133,7 +129,7 @@ var Query = module.exports = function Query(){
}
function doHandshake(){
- console.log("doHandshake");
+
var token = generateToken();
session.idToken=token;
m.send(session, CHALLENGE_TYPE, function(err, res){
@@ -202,7 +198,6 @@ var Query = module.exports = function Query(){
payloadBuffer=undefined;
}
var b = makePacket(type, session, payloadBuffer);
- //console.log('packet:', b);
socket.send(b, 0, b.length, session.port, session.host, function(err, sent){
if(err){
callback(err);
View
20 test/base-test.js
@@ -53,16 +53,16 @@ vows.describe('GS4 Query').addBatch({
},
'returns a stat object':function(err, stat){
assert.isObject(stat);
- assert.include(stat, 'motd');
- assert.include(stat, 'gameType');
- assert.include(stat, 'worldName');
- assert.include(stat, 'playersOnline');
- assert.isNumber(stat.playersOnline);
- assert.include(stat, 'playersMax');
- assert.isNumber(stat.playersMax);
- assert.include(stat, 'port');
- assert.isNumber(stat.port);
- assert.include(stat, 'host');
+ assert.include(stat, 'hostname');
+ assert.include(stat, 'gametype');
+ assert.include(stat, 'map');
+ assert.include(stat, 'numplayers');
+ assert.isNumber(stat.numplayers);
+ assert.include(stat, 'maxplayers');
+ assert.isNumber(stat.maxplayers);
+ assert.include(stat, 'hostport');
+ assert.isNumber(stat.hostport);
+ assert.include(stat, 'hostip');
//console.log(stat);
}
},//topic basic_stat

0 comments on commit c87ff03

Please sign in to comment.