mirror of
https://github.com/tribufu/node-gamedig
synced 2026-05-18 09:35:50 +00:00
Merge error and fatal
This commit is contained in:
parent
e857eb1b47
commit
9ebb95c69d
7 changed files with 17 additions and 20 deletions
|
|
@ -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;
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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]);
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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]);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue