add session management and step passed to the streamer
[xynt.git] / web / test-hs-rd.php
1 <html>
2 <head>
3 <script type="text/javascript" src="xynt/xynt-console.js"></script>
4 <script type="text/javascript" src="xynt/xynt-http-streaming-ifra.js"></script>
5 <script type="text/javascript">
6 var http_streaming = "ready";
7
8 window.onload = function () { if (http_streaming != "ready") http_streaming.reload(); };
9 </script> 
10 </head>
11 <body onabort = "console.log('rd abort');" onunload = "console.log('rd unload');" onerror = "console.log('rd error');" onkeypress = "console.log('rd keypress');">
12 </body>
13 <?php
14 function mop_flush()
15 {
16     ob_flush();
17     flush();
18 }
19
20 function main()
21 {
22     GLOBAL $st;
23
24     $s = "";
25     for ($i = 0 ; $i < 4096 ; $i++) {
26         $s .= rand(65,90);
27     }
28
29     $to = rand(10,20);
30     for ($first = true, $i = $st+1 ; $i < $st+$to ; $i++, $first = false) {
31         // if ($i == 0)
32         //    sleep(1);
33      
34         if ($i != 8 || true) {
35             printf("<script id='hs%d' type='text/javascript'>
36 push(\"$('cont').innerHTML += '%s %d'; gst.st = %d;\");
37 </script>", $i, ($first ? "<br/>" : ""), $i, $i);
38         }
39         else {
40             // exit();
41             // sleep(30);
42         }
43         if ($first)
44             printf("<!-- %s -->", $s);
45         mop_flush();
46         usleep(1000000);
47     }
48 }
49 main();
50 ?>
51 </html>