Copyright date updated
[brisk.git] / web / briskin5 / Obj / briskin5.phh
index c5ad7ce..8f5cd82 100644 (file)
@@ -2,7 +2,7 @@
 /*
  *  brisk - briskin5.phh
  *
- *  Copyright (C) 2006-2011 Matteo Nastasi
+ *  Copyright (C) 2006-2012 Matteo Nastasi
  *                          mailto: nastasi@alternativeoutput.it 
  *                                  matteo.nastasi@milug.org
  *                          web: http://www.alternativeoutput.it
@@ -477,13 +477,15 @@ class Bin5_user extends User {
        } 
     */
     
-    function spawn($from, &$bri, $table, $table_pos)
+    function spawn($from, &$bri, $table, $table_pos, $get, $post, $cookie)
     {
-        GLOBAL $CO_bin5_pref_ring_endauct;
-        
         if (($thiz = new Bin5_user()) == FALSE)
             return (FALSE);
-        
+
+        if (($CO_bin5_pref_ring_endauct = gpcs_var("CO_bin5_pref_ring_endauct", $get, $post, $cookie)) === FALSE) {
+            $CO_bin5_pref_ring_endauct = "";
+        }
+
         $thiz->parentcopy($from);
         
         /* NOTE: at this moment idx and table_pos fields have the same value 
@@ -498,7 +500,7 @@ class Bin5_user extends User {
         log_wr("Bin5 constructor");
         
         $this->privflags  = ($CO_bin5_pref_ring_endauct == "true" ? BIN5_USER_FLAG_RING_ENDAUCT : 0) | 0;
-        
+
         $thiz->table_orig = $table;
         $thiz->table      = 0;
         $thiz->table_pos  = $table_pos;
@@ -718,7 +720,37 @@ class Bin5_user extends User {
         return ($ret);
     }
 
-    static function blocking_error($is_unrecoverable)
+public static function stream_fini($is_unrecoverable)
+{
+    GLOBAL $G_four_rnd_string;
+
+    printf("xXx user::stream_fini\n");
+
+    // IF IFRAME THEN:
+    $body = "";
+    $body .= sprintf("<html>
+<head>
+<script type=\"text/javascript\" src=\"%scommons.js\"></script>
+<script type=\"text/javascript\" src=\"%sxynt-http-streaming-ifra.js\"></script>
+<script type=\"text/javascript\">
+var http_streaming = \"ready\";", self::base_get(), self::base_get());
+    $body .= sprintf("
+window.onload = function () { if (http_streaming != \"ready\") { http_streaming.reload(); } };
+</script>
+</head>
+<body>");
+    $body .= sprintf("<!-- \n%s -->\n", $G_four_rnd_string);
+    $body .= sprintf("<script id='hs%d' type='text/javascript'><!--
+push(\"%s\");
+// -->
+</script>", 0, escpush(self::blocking_error($is_unrecoverable)) );
+    // ELSE IF XHR THEN:
+    // return (self::blocking_error($is_unrecoverable));
+    return ($body);
+}
+
+
+    protected function blocking_error($is_unrecoverable)
     {
         GLOBAL $is_page_streaming;
         
@@ -926,7 +958,7 @@ class Bin5 {
         return TRUE;
     }
 
-    function Bin5 ($room, $table_idx, $table_token) {
+    function Bin5 ($room, $table_idx, $table_token, $get, $post, $cookie) {
         $this->user = array();
         $this->table = array();
         
@@ -944,7 +976,7 @@ class Bin5 {
         
         for ($i = 0 ; $i < $table->player_n ; $i++) {
             $user[$table->player[$i]]->table_token = $table_token;
-            $this->user[$i] = Bin5_user::spawn($user[$table->player[$i]], $this, $table_idx, $i);
+            $this->user[$i] = Bin5_user::spawn($user[$table->player[$i]], $this, $table_idx, $i, $get, $post, $cookie);
         }
         $this->table[0] = Bin5_table::spawn(&$table);
         
@@ -1429,6 +1461,8 @@ class Bin5 {
         if (($table_token = gpcs_var('table_token', $get, $post, $cookie)) === FALSE) 
             unset($table_token);
 
+        force_no_cache($header_out);
+
         switch ($path) {
         case "":
         case "index.php":
@@ -1437,8 +1471,6 @@ 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;
         
@@ -1450,8 +1482,6 @@ 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;