From 91fa2e11b2366f5fc78fba3251ac5018688b08a5 Mon Sep 17 00:00:00 2001 From: Michael Morrison Date: Sun, 2 Feb 2014 06:17:05 -0600 Subject: [PATCH] Fix TCP debugging --- games/protocols/core.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/games/protocols/core.js b/games/protocols/core.js index 0f2d592..591301d 100644 --- a/games/protocols/core.js +++ b/games/protocols/core.js @@ -206,15 +206,16 @@ module.exports = Class.extend(EventEmitter,{ var port = this.options.port; var socket = this.tcpSocket = net.connect(port,address,function() { + if(self.debug) console.log(address+':'+port+" TCPCONNECTED"); c(socket); }); socket.setTimeout(10000); socket.setNoDelay(true); - if(this.debug) console.log(address+':'+port+" TCPCONNECT-->"); + if(this.debug) console.log(address+':'+port+" TCPCONNECT"); var writeHook = socket.write; socket.write = function(data) { - if(this.debug) console.log(address+':'+port+" TCP--> "+data.toString('hex')); + if(self.debug) console.log(address+':'+port+" TCP--> "+data.toString('hex')); writeHook.apply(this,arguments); } @@ -226,7 +227,7 @@ module.exports = Class.extend(EventEmitter,{ }); socket.on('data', function(data) { if(!self.tcpCallback) return; - if(this.debug) console.log(address+':'+port+" <--TCP "+data.toString('hex')); + if(self.debug) console.log(address+':'+port+" <--TCP "+data.toString('hex')); received = Buffer.concat([received,data]); if(self.tcpCallback(received)) { clearTimeout(this.tcpTimeoutTimer);