Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Porter <slug@qwebirc.org>2011-02-20 01:36:27 (GMT)
committer Chris Porter <slug@qwebirc.org>2011-02-20 01:36:27 (GMT)
commitfef44cde4b20e0b538a5ce9d54653788ed644337 (patch)
tree4bf5d31d3d83bc440bd64f46a3b3d913d52ba0bb
parent903f4124d2188947023695ad67543bf2f9ccf64c (diff)
IRCConnection now increases timeout period when previous timeouts were successful.
-rw-r--r--js/irc/ircconnection.js30
1 files changed, 18 insertions, 12 deletions
diff --git a/js/irc/ircconnection.js b/js/irc/ircconnection.js
index 1b42859..136e057 100644
--- a/js/irc/ircconnection.js
+++ b/js/irc/ircconnection.js
@@ -4,7 +4,10 @@ qwebirc.irc.IRCConnection = new Class({
Implements: [Events, Options],
options: {
initialNickname: "ircconnX",
- timeout: 45000,
+ minTimeout: 45000,
+ maxTimeout: 5 * 60000,
+ timeoutIncrement: 10000,
+ initialTimeout: 65000,
floodInterval: 200,
floodMax: 10,
floodReset: 5000,
@@ -27,6 +30,7 @@ qwebirc.irc.IRCConnection = new Class({
this.__retryAttempts = 0;
this.__timeoutId = null;
+ this.__timeout = this.options.initialTimeout;
this.__lastActiveRequest = null;
this.__activeRequest = null;
@@ -159,8 +163,7 @@ qwebirc.irc.IRCConnection = new Class({
return true;
},
__scheduleTimeout: function() {
- if(this.options.timeout)
- this.__timeoutId = this.__timeoutEvent.delay(this.options.timeout, this);
+ this.__timeoutId = this.__timeoutEvent.delay(this.__timeout, this);
},
__cancelTimeout: function() {
if($defined(this.__timeoutId)) {
@@ -174,16 +177,16 @@ qwebirc.irc.IRCConnection = new Class({
if(!$defined(this.__activeRequest))
return;
- if(this.__checkRetries()) {
- if(this.__lastActiveRequest)
- this.__lastActiveRequest.cancel();
+ if(this.__lastActiveRequest)
+ this.__lastActiveRequest.cancel();
- this.__activeRequest.__replaced = true;
- this.__lastActiveRequest = this.__activeRequest;
- this.recv();
- } else {
- this.__cancelRequests();
- }
+ this.__activeRequest.__replaced = true;
+ this.__lastActiveRequest = this.__activeRequest;
+
+ if(this.__timeout + this.options.timeoutIncrement <= this.options.maxTimeout)
+ this.__timeout+=this.options.timeoutIncrement;
+
+ this.recv();
},
__checkRetries: function() {
/* hmm, something went wrong! */
@@ -194,6 +197,9 @@ qwebirc.irc.IRCConnection = new Class({
return false;
}
+ if(this.__timeout - this.options.timeoutIncrement >= this.options.minTimeout)
+ this.__timeout-=this.options.timeoutIncrement;
+
return true;
},
recv: function() {