Fixes for [#232]

This commit is contained in:
reality 2013-01-27 15:19:56 +00:00
parent bd75519047
commit 27e24a8173

View File

@ -18,23 +18,31 @@ var timers = function(dbot) {
setTimeout(function() {
console.log('Running first timer at ' + new Date().toUTCString());
this.runningIntervals.push(this.api.addTimer(timeout, callback));
try {
callback();
} catch(err) {
console.log('Callback failed: ' + err);
}
}.bind(this), firstTimeout);
} else {
this.runningIntervals.push(setInterval(function() {
console.log('Running subsequent timer at ' + new Date().toUTCString());
try {
callback();
} catch(err) {
console.log('Callback failed: ' + err);
}
}.bind(this), timeout));
}
}
};
this.onDestroy = function() {
for(var i=0;i<this.runningTimeouts;i++) {
for(var i=0;i<this.runningTimeouts.length;i++) {
clearTimeout(this.runningTimeouts[i]);
}
for(i=0;i<this.runningIntervals;i++) {
clearTimer(this.runningIntervals[i]);
for(i=0;i<this.runningIntervals.length;i++) {
clearInterval(this.runningIntervals[i]);
}
}.bind(this);
};