Merge branch 'sac-a-push' of git.birds.lan:brisk into sac-a-push
authorMatteo Nastasi <nastasi@alternativeoutput.it>
Wed, 3 Oct 2012 20:20:46 +0000 (22:20 +0200)
committerMatteo Nastasi <nastasi@alternativeoutput.it>
Wed, 3 Oct 2012 20:20:46 +0000 (22:20 +0200)
web/Obj/brisk.phh
web/Obj/sac-a-push.phh
web/briskin5/Obj/briskin5.phh
web/commons.js
web/xynt-http-streaming.js

index b52c333..af2a901 100644 (file)
@@ -293,6 +293,13 @@ function mop_flush()
     flush();
 }
 
+function force_no_cache(&$header_out)
+{
+    $header_out['Pragma'] = 'no-cache, must-revalidate';
+    $header_out['Cache-Control'] = 'no-cache';
+    $header_out['Expires'] = '-1';
+}
+
 function file_lock($fname, $is_exclusive)
 {
     if (($res = @fopen($fname, "r+")) == FALSE) {
@@ -2179,6 +2186,8 @@ class Room {
       $content = ob_get_contents();
       ob_end_clean();
 
+      force_no_cache($header_out);
+
       $s_a_p->pgflush_try_add($new_socket, 20, $header_out, $content);
       return TRUE;
 
@@ -2189,6 +2198,8 @@ class Room {
           $content = ob_get_contents();
           ob_end_clean();
 
+          force_no_cache($header_out);
+
           $s_a_p->pgflush_try_add($new_socket, 20, $header_out, $content);
           return TRUE;
 
index cd0d6ab..1151ea1 100644 (file)
@@ -284,7 +284,7 @@ class Sac_a_push {
             }
             $write  = NULL;
             $except = NULL;
-            $num_changed_sockets = stream_select($read, $write, $except, 0, 250000);
+            $num_changed_sockets = stream_select($read, $write, $except, 5, 0);
         
             if ($num_changed_sockets == 0) {
                 printf(" no data in 5 secs ");
index 4fb54b1..c5ad7ce 100644 (file)
@@ -903,6 +903,29 @@ class Bin5 {
     var $the_end;
     var $tok;
 
+    static function page_manager($room, $header_out, $path, $method, $addr, $get, $post, $cookie) 
+    {
+        switch ($path) {
+        case "":
+        case "index.php":
+            ob_start();
+            bin5_index_main($room, $header_out, $addr, $get, $post, $cookie);
+            $content = ob_get_contents();
+            ob_end_clean();
+            
+            force_no_cache($header_out);
+
+            $pgflush = new PageFlush($new_socket, $curtime, 20, $header_out, $content);
+            
+            if ($pgflush->try_flush($curtime) == FALSE) {
+                // Add $pgflush to the pgflush array
+                array_push($pages_flush, $pgflush);
+            }
+            break;
+        }
+        return TRUE;
+    }
+
     function Bin5 ($room, $table_idx, $table_token) {
         $this->user = array();
         $this->table = array();
@@ -1414,6 +1437,8 @@ class Bin5 {
             $content = ob_get_contents();
             ob_end_clean();
         
+            force_no_cache($header_out);
+
             $s_a_p->pgflush_try_add($new_socket, 20, $header_out, $content);
             return TRUE;
         
@@ -1425,6 +1450,8 @@ class Bin5 {
             $content = ob_get_contents();
             ob_end_clean();
             
+            force_no_cache($header_out);
+
             $s_a_p->pgflush_try_add($new_socket, 20, $header_out, $content);
             return TRUE;
             
index f0ea078..99a2983 100644 (file)
@@ -249,6 +249,7 @@ function send_mesg(mesg)
     
     // alert("xhr_wr: "+xhr_wr+"  is_conn: "+is_conn);
     xhr_wr.open('GET', 'index_wr.php?'+(is_conn ? 'sess='+sess+'&' : '')+'mesg='+mesg, (is_conn ? true : false));
+    xhr_wr.setRequestHeader("If-Modified-Since", new Date().toUTCString());
     xhr_wr.onreadystatechange = function() { return; };
     if (typeof(g_debug) == 'number' && g_debug > 0
         && typeof(console) == 'object' && typeof(console.log) == 'function') {
index 0cbf36b..7d216aa 100644 (file)
@@ -39,7 +39,8 @@ http_streaming.prototype = {
     keepalives_equal:  0,
     keepalives_eq_max: 6,
     /* NOTE: right watch_timeout value to 100, for devel reasons use 1000 or more */
-    watchdog_timeout:  200,
+    // FIXME watchdog_timeout:  200,
+    watchdog_timeout:  2000,
     watchdog_ct:       0,
     watchdog_checktm:  20,
     watchable:         false,