xhr transport added
[brisk.git] / web / Obj / transports.phh
index 72ad49b..0f0e4a7 100644 (file)
  *
  */
 
+/*
+ *  test: SO x Browser
+ *  Values: Y: works, N: not works, @: continuous download,
+ *          D: continuous download after first reload
+ *
+ *  Stream IFRAME:
+ *
+ * Iframe| IW | FF | Ch | Op | Ko | IE
+ * ------+----+----+----+----+----+----
+ *   Lnx | D  |    | @  |    | @  | x
+ *   Win | x  | D  | @  | @  |    | D
+ *   Mac | x  |    |    |    |    |
+ *
+ *
+ *   XHR | IW | FF | Ch | Op | Ko | IE
+ * ------+----+----+----+----+----+----
+ *   Lnx | Y  |    | ^D |    | Y  | x
+ *   Win | x  | Y  | Y  |    |    | N
+ *   Mac | x  |    |    |    |    |
+ *
+ *
+ * HtmlFl| IW | FF | Ch | Op | Ko | IE
+ * ------+----+----+----+----+----+----
+ *   Lnx | N  |    |    |    | N  |
+ *   Win | x  | N  | N  |    |    | Y* (* seems delay between click and load of a new page)
+ *   Mac | x  |    |    |    |    |
+ *
+ *
+ */
+
+
 class Transport_template {
 
     function Transport_template() {
@@ -31,7 +62,7 @@ class Transport_template {
     {
     }
 
-    static function fini($init_string, $blockerr)
+    static function fini($init_string, $base, $blockerr)
     {
     }
 
@@ -47,7 +78,7 @@ class Transport_xhr {
 
     function init($enc, &$header_out, $init_string, $base, $step)
     {
-        $ret = $init_string;
+        $ret = sprintf("@BEGIN@ /* %s */ @END@", $init_string);
         if ($enc != 'plain')
             $header_out['Content-Encoding'] = $enc;
         $header_out['Cache-Control'] = 'no-cache, must-revalidate';     // HTTP/1.1
@@ -57,7 +88,7 @@ class Transport_xhr {
         return ($ret);
     }
 
-    static function fini($init_string, $blockerr)
+    static function fini($init_string, $base, $blockerr)
     {
         return ("");
     }
@@ -92,7 +123,7 @@ var xynt_streaming = \"ready\";", $base, $base);
         if ($step > 0)
             $ret .= sprintf("last_clean = %d;\n", ($step-1));
         $ret .= sprintf("
-window.onload = function () { if (xynt_streaming != \"ready\") { xynt_streaming.reload(); } };
+window.onload = function () { if (xynt_streaming != \"ready\") { xynt_streaming.transp.stopped = true; } };
 </script> 
 </head>
 <body>");
@@ -101,7 +132,7 @@ window.onload = function () { if (xynt_streaming != \"ready\") { xynt_streaming.
         return ($ret);
     }
 
-    static function fini($init_string, $blockerr)
+    static function fini($init_string, $base, $blockerr)
     {
         $ret = "";
         $ret .= sprintf("<html>
@@ -109,7 +140,7 @@ window.onload = function () { if (xynt_streaming != \"ready\") { xynt_streaming.
 <script type=\"text/javascript\" src=\"%scommons.js\"></script>
 <script type=\"text/javascript\" src=\"%sxynt-streaming-ifra.js\"></script>
 <script type=\"text/javascript\">
-var xynt_streaming = \"ready\";", self::base_get(), self::base_get());
+var xynt_streaming = \"ready\";", $base, $base);
         $ret .= sprintf("
 window.onload = function () { if (xynt_streaming != \"ready\") { xynt_streaming.reload(); } };
 </script>
@@ -135,4 +166,26 @@ push(\"%s\");\n// -->\n</script>", $step, escpush($cont) );
         }
     }
 }
+
+class Transport_htmlfile extends Transport_iframe {
+}
+
+class Transport {
+    function Transport()
+    {
+    }
+
+    static function create($transp)
+    {
+        if ($transp == 'xhr') {
+            return new Transport_xhr();
+        }
+        else if ($transp == 'htmlfile') {
+            return new Transport_htmlfile();
+        }
+        else  {
+            return new Transport_iframe();
+        }
+    }
+}
 ?>
\ No newline at end of file