ctx_new moved and $st added to manage status value
[xynt.git] / web / test-hs-rd.php
index 67bc876..bd4667e 100644 (file)
@@ -1,13 +1,15 @@
 <html>
 <head>
 <script type="text/javascript" src="xynt/xynt-console.js"></script>
-<!-- <script type="text/javascript">
-window.onload_old = function() {
-    // parent.ifra.contentWindow.location.href = 'winstream_rd.php';     
-     window.location.href = 'winstream_rd.php';     
-}
+<script type="text/javascript" src="xynt/xynt-http-streaming-ifra.js"></script>
+<script type="text/javascript">
+var http_streaming = "ready";
 
-</script> -->
+window.onload = function () { if (http_streaming != "ready") http_streaming.reload(); };
+</script> 
+</head>
+<body onabort = "console.log('rd abort');" onunload = "console.log('rd unload');" onerror = "console.log('rd error');" onkeypress = "console.log('rd keypress');">
+</body>
 <?php
 function mop_flush()
 {
@@ -17,29 +19,30 @@ function mop_flush()
 
 function main()
 {
+    $st = 0;
+    $fp = fopen("/tmp/test-hs-rd.log", "a");
+    fwrite($fp, "START\n");
+    fclose($fp);
+
     $s = "";
     for ($i = 0 ; $i < 4096 ; $i++) {
-        $s .= rand(0,255);
+        $s .= rand(65,90);
     }
-    for ($i = 0 ; $i < 300 ; $i++) {
-        
-        /*                    parent.document.getElementById('cont').innerHTML = \"%d\";
-                             parent.allmythings =  \"%d\"; */
-        if ($i != 350) {
-            printf("<script id=\"hs%d\" type=\"text/javascript\">
-                    parent.allmythings = %d;
-                    console.log(\"zorro \"+parent.allmythings);
 
-                </script>", $i, $i);
+    $to = rand(10,20);
+    for ($first = true, $i = $st+1 ; $i < $st+$to ; $i++, $first = false) {
+        // if ($i == 0)
+        //    sleep(1);
+     
+        if ($i == $st+8) {
+            // exit();
+            sleep(30);
         }
-        else {
-            printf("<script id=\"hs%d\" type=\"text/javascript\">
-                    parent.allmythings = %d;
-                    console.log(\"zorro \"+parent.allmythings);
-                    parent.document.location.assign('winstream2.php');
-                </script>", $i, $i);
-        }
-        if ($i == 0)
+        printf("<script id='hs%d' type='text/javascript'>
+push(\"$('cont').innerHTML += '%s %d';\");
+</script>", $i, ($first ? "<br/>" : ""), $i);
+
+        if ($first)
             printf("<!-- %s -->", $s);
         mop_flush();
         usleep(1000000);
@@ -47,7 +50,4 @@ function main()
 }
 main();
 ?>
-</head>
-<body>
-</body>
 </html>
\ No newline at end of file