Upgrade moment and varint dependencies

This commit is contained in:
Michael Morrison 2015-01-18 01:38:45 -06:00
parent bccf9092c2
commit b2e574217a
2 changed files with 15 additions and 10 deletions

View file

@ -33,8 +33,8 @@
"gbxremote": "~0.1.4", "gbxremote": "~0.1.4",
"request": "~2.33.0", "request": "~2.33.0",
"optimist": "~0.6.0", "optimist": "~0.6.0",
"varint": "~1.0.0", "varint": "~4.0.0",
"moment": "~2.8.3" "moment": "~2.9.0"
}, },
"bin": { "bin": {
"gamedig": "bin/gamedig.js" "gamedig": "bin/gamedig.js"

View file

@ -44,7 +44,7 @@ module.exports = require('./core').extend({
self.tcpSend(outBuffer, function(data) { self.tcpSend(outBuffer, function(data) {
if(data.length < 10) return false; if(data.length < 10) return false;
var expected = varint.decode(data); var expected = varint.decode(data);
data = data.slice(varint.decode.bytesRead); data = data.slice(varint.decode.bytes);
if(data.length < expected) return false; if(data.length < expected) return false;
receivedData = data; receivedData = data;
c(); c();
@ -56,17 +56,22 @@ module.exports = require('./core').extend({
var data = receivedData; var data = receivedData;
var packetId = varint.decode(data); var packetId = varint.decode(data);
data = data.slice(varint.decode.bytesRead); if(self.debug) console.log("Packet ID: "+packetId);
data = data.slice(varint.decode.bytes);
var strLen = varint.decode(data); var strLen = varint.decode(data);
data = data.slice(varint.decode.bytesRead); if(self.debug) console.log("String Length: "+strLen);
data = data.slice(varint.decode.bytes);
var str = data.toString('utf8'); var str = data.toString('utf8');
if(self.debug) {
console.log(str);
}
var json; var json;
try { try {
json = JSON.parse(str); json = JSON.parse(str);
delete json.favicon; delete json.favicon;
if(self.debug) console.log(json);
} catch(e) { } catch(e) {
return self.fatal('Invalid JSON'); return self.fatal('Invalid JSON');
} }