mirror of
https://github.com/gamedig/node-gamedig.git
synced 2024-11-19 02:00:38 +01:00
Fix TCP debugging
This commit is contained in:
parent
3c0de4060c
commit
91fa2e11b2
1 changed files with 4 additions and 3 deletions
|
@ -206,15 +206,16 @@ module.exports = Class.extend(EventEmitter,{
|
||||||
var port = this.options.port;
|
var port = this.options.port;
|
||||||
|
|
||||||
var socket = this.tcpSocket = net.connect(port,address,function() {
|
var socket = this.tcpSocket = net.connect(port,address,function() {
|
||||||
|
if(self.debug) console.log(address+':'+port+" TCPCONNECTED");
|
||||||
c(socket);
|
c(socket);
|
||||||
});
|
});
|
||||||
socket.setTimeout(10000);
|
socket.setTimeout(10000);
|
||||||
socket.setNoDelay(true);
|
socket.setNoDelay(true);
|
||||||
if(this.debug) console.log(address+':'+port+" TCPCONNECT-->");
|
if(this.debug) console.log(address+':'+port+" TCPCONNECT");
|
||||||
|
|
||||||
var writeHook = socket.write;
|
var writeHook = socket.write;
|
||||||
socket.write = function(data) {
|
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);
|
writeHook.apply(this,arguments);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -226,7 +227,7 @@ module.exports = Class.extend(EventEmitter,{
|
||||||
});
|
});
|
||||||
socket.on('data', function(data) {
|
socket.on('data', function(data) {
|
||||||
if(!self.tcpCallback) return;
|
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]);
|
received = Buffer.concat([received,data]);
|
||||||
if(self.tcpCallback(received)) {
|
if(self.tcpCallback(received)) {
|
||||||
clearTimeout(this.tcpTimeoutTimer);
|
clearTimeout(this.tcpTimeoutTimer);
|
||||||
|
|
Loading…
Reference in a new issue