reorganize code a bit : debug code going to debug.js, put packets reading code in a function, add types using a addTypes function

This commit is contained in:
Romain Beaumont 2015-05-13 14:47:28 +02:00
parent fe443e84ff
commit 78e70dad8e
4 changed files with 102 additions and 95 deletions

17
src/debug.js Normal file
View file

@ -0,0 +1,17 @@
var util = require('util')
var debug;
if (process.env.NODE_DEBUG && /(minecraft-protocol|mc-proto)/.test(process.env.NODE_DEBUG)) {
var pid = process.pid;
debug = function(x) {
// if console is not set up yet, then skip this.
if (!console.error)
return;
console.error('MC-PROTO: %d', pid,
util.format.apply(util, arguments).slice(0, 500));
};
} else {
debug = function() { };
}
module.exports = debug;