]> git.wh0rd.org Git - tt-rss.git/commitdiff
implement sequence numbers for counter rpc requests
authorAndrew Dolgov <fox@fakecake.org>
Thu, 11 Nov 2010 19:59:01 +0000 (22:59 +0300)
committerAndrew Dolgov <fox@fakecake.org>
Thu, 11 Nov 2010 19:59:01 +0000 (22:59 +0300)
feedlist.js
modules/backend-rpc.php
tt-rss.js

index 9032ba0269954896324761fffeb329f573ffe227..33fdb891641ed015fa0f2c20c9338021eff20e73 100644 (file)
@@ -607,7 +607,7 @@ function request_counters_real() {
 
                console.log("requesting counters...");
 
-               var query = "?op=rpc&subop=getAllCounters";
+               var query = "?op=rpc&subop=getAllCounters&seq=" + next_seq();
 
                if (tagsAreDisplayed()) {
                        query = query + "&omode=tl";
index 6792fae7f8f04cf034aeb7492a5285e437e1f2a7..e5c922324bce2b46386949c20e2150a7e9c788ed 100644 (file)
@@ -2,6 +2,7 @@
        function handle_rpc_request($link) {
 
                $subop = $_REQUEST["subop"];
+               $seq = (int) $_REQUEST["seq"];
 
                if ($subop == "setprofile") {
                        $id = db_escape_string($_REQUEST["id"]);
 
                        print "<rpc-reply>";
 
+                       if ($seq)
+                               print "<seq>$seq</seq>";
+
                        if ($last_article_id != getLastArticleId($link)) {
                                print "<counters><![CDATA[";
                                $omode = $_REQUEST["omode"];
index e755faf70893378a52af57a1a3d1684fbcf3f965..4226fd8da4e28a3f4d927e72fda284759f89e374 100644 (file)
--- a/tt-rss.js
+++ b/tt-rss.js
@@ -15,6 +15,17 @@ var feedlist_sortable_enabled = false;
 var _force_scheduled_update = false;
 var last_scheduled_update = false;
 
+var _rpc_seq = 0;
+
+function next_seq() {
+       _rpc_seq += 1;
+       return _rpc_seq;
+}
+
+function get_seq() {
+       return _rpc_seq;
+}
+
 function activeFeedIsCat() {
        return _active_feed_is_cat;
 }
@@ -167,7 +178,7 @@ function timeout() {
 
                        window.clearTimeout(counter_timeout_id);
                
-                       var query_str = "?op=rpc&subop=getAllCounters";
+                       var query_str = "?op=rpc&subop=getAllCounters&seq=" + next_seq();
                
                        var omode;
                
@@ -1263,6 +1274,17 @@ function handle_rpc_reply(transport, scheduled_call) {
 
                        if (!transport_error_check(transport)) return false;
 
+                       var seq = transport.responseXML.getElementsByTagName("seq")[0];
+
+                       if (seq) {
+                               seq = seq.firstChild.nodeValue;
+
+                               if (get_seq() != seq) {
+                                       //console.log("[handle_rpc_reply] sequence mismatch: " + seq);
+                                       return true;
+                               }
+                       }
+
                        var message = transport.responseXML.getElementsByTagName("message")[0];
 
                        if (message) {