fix hard cabled stream_fini response when some error occurs
authorMatteo Nastasi (mop) <nastasi@alternativeoutput.it>
Fri, 4 Jan 2013 09:07:05 +0000 (10:07 +0100)
committerMatteo Nastasi (mop) <nastasi@alternativeoutput.it>
Fri, 4 Jan 2013 09:07:05 +0000 (10:07 +0100)
TODO.txt
web/Obj/brisk.phh
web/Obj/transports.phh
web/Obj/user.phh

index b25fc15..40ebb1e 100644 (file)
--- a/TODO.txt
+++ b/TODO.txt
@@ -4,11 +4,12 @@
   MAJOR |
  -------+
    - BUG: some connection to the named socket fails
-   - Page still opened after the server restart
+   - Not simultaneous more then one stream
 
   MINOR |
  -------+
    WIP - try to be more antivirus-friendly
+   - multiple rows between games
    - packetize and automatize php-ancillary and apache module
    - into the room local step remains -1
    - DISABLED_TO_FIX: DNS access (perform blocking dns requests, must be fixed)
@@ -16,6 +17,7 @@
 
   DONE |
  ------+
+   DONE - Page still opened after the server restart
    DONE - log_legal address fix
    DONE - manage too fast reload in xynt-streaming
    DONE - add xhr as transport layer and manage different streams better
index 6249c43..f8c9225 100644 (file)
@@ -2188,8 +2188,11 @@ class Room
           do {
               if (!isset($cookie['sess'])
                   || (($user = $this->get_user($cookie['sess'], $idx)) == FALSE)) {
-                  $content = User::stream_fini($s_a_p->rndstr, TRUE);
+                  if (($transp  = gpcs_var('transp', $get, $post, $cookie)) === FALSE)
+                      $transp = "iframe";
                   
+                  $content = User::stream_fini($transp, $s_a_p->rndstr, TRUE);
+
                   $s_a_p->pgflush_try_add($enc, $new_socket, 20, $header_out, $content);
                   return TRUE;
 
index e0b11ee..2d9714e 100644 (file)
@@ -90,6 +90,7 @@ class Transport_xhr {
 
     static function fini($init_string, $base, $blockerr)
     {
+        return (sprintf('@BEGIN@ %s window.onbeforeunload = null; window.onunload = null; document.location.assign("%sindex.php"); @END@',  ($blockerr ? 'xstm.stop(); ' : ''), $base));
         return ("");
     }
 
@@ -187,5 +188,14 @@ class Transport {
             return new Transport_iframe();
         }
     }
+    static function gettype($transp)
+    {
+        if ($transp == 'xhr' || $transp == 'htmlfile') {
+            return "Transport_".$transp;
+        }
+        else {
+            return 'Transport_iframe';
+        }
+    }
 }
 ?>
\ No newline at end of file
index b6efbcd..d5e82ee 100644 (file)
@@ -651,13 +651,13 @@ class User {
       return ($ret);
   }  //   function maincheck (...
 
-  public static function stream_fini($init_string, $is_unrecoverable)
+  public static function stream_fini($transp, $init_string, $is_unrecoverable)
 {
     printf("xXx user::stream_fini\n");
 
     // FIXME: dynamic "Transport_" type
-    $tans_class = "Transport_iframe";
-    $body = $tans_class::fini($init_string, self::base_get(), static::blocking_error($is_unrecoverable));
+    $trans_class = Transport::gettype($transp);
+    $body = $trans_class::fini($init_string, self::base_get(), static::blocking_error($is_unrecoverable));
 
     // ELSE IF XHR THEN:
     // return (static::blocking_error($is_unrecoverable));