]> jfr.im git - irc/quakenet/qwebirc.git/commitdiff
Few changes to the backend to prevent ping timeouts with the new retry logic.
authorChris Porter <redacted>
Fri, 17 Oct 2008 08:19:41 +0000 (09:19 +0100)
committerChris Porter <redacted>
Fri, 17 Oct 2008 08:19:41 +0000 (09:19 +0100)
js/irc/ircconnection.js
qwebirc/ajaxengine.py

index 9c95828a7f9dfb2a61b7f905f0fe6eaecb98b35a..619251b99ccb53f6c2b332166a6f4a69b1968574 100644 (file)
@@ -1,3 +1,5 @@
+/* This could do with a rewrite from scratch. */
+
 var IRCConnection = new Class({
   Implements: [Events, Options],
   options: {
@@ -38,9 +40,15 @@ var IRCConnection = new Class({
     return true;
   },
   __timeout: function() {
+    if(this.lastactiverequest) {
+      this.lastactiverequest.cancel();
+      this.lastactiverequest = null;
+      alert("warning: last active request");
+    }
     if(this.activerequest) {
-      this.activerequest.cancel();
-      this.activerequest = null;
+      this.lastactiverequest = this.activerequest;
+      /*this.activerequest.cancel();
+      this.activerequest = null;*/
     }
     if($defined(this.timeoutid)) {
       $clear(this.timeoutid);
@@ -50,13 +58,17 @@ var IRCConnection = new Class({
   },
   recv: function() {
     var r = new Request.JSON({url: "/e/s/" + this.sessionid + "?t=" + this.counter++, onComplete: function(o) {
-      this.activerequest = null;
+      if(this.lastactiverequest != r) 
+        this.activerequest = null;
+        
       if($defined(this.timeoutid)) {
         $clear(this.timeoutid);
         this.timeoutid = null;
       }
-      
+
       if(o) {
+        if(this.lastactiverequest == r)
+          this.lastactiverequest = null;
         this.lasttry = false;
         if(o[0] == false) {
           if(!this.disconnected) {
@@ -70,6 +82,10 @@ var IRCConnection = new Class({
           this.fireEvent("recv", [x]);
         }, this);
       } else {
+        if(this.lastactiverequest == r) {
+          this.lastactiverequest = null;
+          return;
+        }
         if(!this.disconnected) {
           if(this.lasttry) {
             this.disconnected = true;
index ff6bd8ef9718946002e66d949e02a4e2da61cbae..78c1c4daf46fd9f681e4705baecaf84e0e9ceb75 100644 (file)
@@ -41,7 +41,7 @@ class IRCSession:
 
   def subscribe(self, channel):
     if len(self.subscriptions) >= config.MAXSUBSCRIPTIONS:
-      self.subscriptions.pop(0)
+      self.subscriptions.pop(0).close()
 
     self.subscriptions.append(channel)
     self.flush()
@@ -111,6 +111,9 @@ class SingleUseChannel(Channel):
     self.request.finish()
     return False
     
+  def close(self):
+    self.request.finish()
+    
 class MultipleUseChannel(Channel):
   def write(self, data):
     self.request.write(data)