diff --git a/games/buildandshoot.js b/games/buildandshoot.js index da217a4..04ecbb2 100644 --- a/games/buildandshoot.js +++ b/games/buildandshoot.js @@ -12,7 +12,7 @@ module.exports = require('./protocols/core').extend({ uri: 'http://'+this.options.address+':'+this.options.port+'/', timeout: 3000, }, function(e,r,body) { - if(e) return self.error('HTTP error'); + if(e) return self.fatal('HTTP error'); var m = body.match(/status server for (.*?)\r|\n/); if(m) state.name = m[1]; diff --git a/games/mutantfactions.js b/games/mutantfactions.js index 34696c3..5df35bc 100644 --- a/games/mutantfactions.js +++ b/games/mutantfactions.js @@ -12,7 +12,7 @@ module.exports = require('./protocols/core').extend({ uri: 'http://mutantfactions.net/game/receiveLobby.php', timeout: 3000, }, function(e,r,body) { - if(e) return self.error('Lobby request error'); + if(e) return self.fatal('Lobby request error'); var split = body.split('
'); diff --git a/games/protocols/core.js b/games/protocols/core.js index 2a60589..0f2d592 100644 --- a/games/protocols/core.js +++ b/games/protocols/core.js @@ -22,11 +22,8 @@ module.exports = Class.extend(EventEmitter,{ },10000); }, - fatal: function(err) { - this.error(err,true); - }, - error: function(err,fatal) { - if(!fatal && this.attempt < this.maxAttempts) { + fatal: function(err,noretry) { + if(!noretry && this.attempt < this.maxAttempts) { this.attempt++; this.start(); return; @@ -115,7 +112,7 @@ module.exports = Class.extend(EventEmitter,{ function resolveStandard(host,c) { dns.lookup(host, function(err,address,family) { - if(err) return self.error(err); + if(err) return self.fatal(err); self.options.address = address; c(); }); @@ -248,10 +245,10 @@ module.exports = Class.extend(EventEmitter,{ }); if(!ondata) return; - //self.tcpTimeoutTimer = self.setTimeout(function() { - // self.tcpCallback = false; - // self.error('timeout'); - //},1000); + self.tcpTimeoutTimer = self.setTimeout(function() { + self.tcpCallback = false; + self.fatal('TCP Watchdog Timeout'); + },1000); self.tcpCallback = ondata; }); }, @@ -269,7 +266,7 @@ module.exports = Class.extend(EventEmitter,{ self.udpCallback = false; var timeout = false; if(!ontimeout || ontimeout() !== true) timeout = true; - if(timeout) self.error('timeout'); + if(timeout) self.fatal('UDP Watchdog Timeout'); },1000); self.udpCallback = onpacket; }); diff --git a/games/protocols/gamespy3.js b/games/protocols/gamespy3.js index 6d57775..c77ce43 100644 --- a/games/protocols/gamespy3.js +++ b/games/protocols/gamespy3.js @@ -151,7 +151,7 @@ module.exports = require('./core').extend({ var list = []; for(var i = 0; i < numPackets; i++) { if(!(i in packets)) { - self.error('Missing packet #'+i); + self.fatal('Missing packet #'+i); return true; } list.push(packets[i]); diff --git a/games/protocols/nadeo.js b/games/protocols/nadeo.js index 8ffb189..560a1e5 100644 --- a/games/protocols/nadeo.js +++ b/games/protocols/nadeo.js @@ -34,13 +34,13 @@ module.exports = require('./core').extend({ if(cmd == 'Connect') { var client = self.gbxclient = gbxremote.createClient(self.options.port,self.options.host, function(err) { - if(err) return self.error('GBX error '+JSON.stringify(err)); + if(err) return self.fatal('GBX error '+JSON.stringify(err)); c(); }); client.on('error',function(){}); } else { self.gbxclient.methodCall(cmd, params, function(err, value) { - if(err) return self.error('XMLRPC error '+JSON.stringify(err)); + if(err) return self.fatal('XMLRPC error '+JSON.stringify(err)); results.push(value); c(); }); diff --git a/games/protocols/valve.js b/games/protocols/valve.js index 427f6f1..24b1330 100644 --- a/games/protocols/valve.js +++ b/games/protocols/valve.js @@ -240,7 +240,7 @@ module.exports = require('./core').extend({ var list = []; for(var i = 0; i < numPackets; i++) { if(!(i in packets)) { - self.error('Missing packet #'+i); + self.fatal('Missing packet #'+i); return true; } list.push(packets[i]); diff --git a/games/terraria.js b/games/terraria.js index f2b581c..e3e7c3d 100644 --- a/games/terraria.js +++ b/games/terraria.js @@ -16,15 +16,15 @@ module.exports = require('./protocols/core').extend({ token: this.options.token } }, function(e,r,body) { - if(e) return self.error('HTTP error'); + if(e) return self.fatal('HTTP error'); var json; try { json = JSON.parse(body); } catch(e) { - return self.error('Invalid JSON'); + return self.fatal('Invalid JSON'); } - if(json.status != 200) return self.error('Invalid status'); + if(json.status != 200) return self.fatal('Invalid status'); json.players.forEach(function(one) { state.players.push({name:one.nickname,team:one.team});