php log added
[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 var ctx_new = "";
8
9 window.onload = function () { if (http_streaming != "ready") http_streaming.reload(); };
10 </script> 
11 </head>
12 <body onabort = "console.log('rd abort');" onunload = "console.log('rd unload');" onerror = "console.log('rd error');" onkeypress = "console.log('rd keypress');">
13 </body>
14 <?php
15 function mop_flush()
16 {
17     ob_flush();
18     flush();
19 }
20
21 function main()
22 {
23     $fp = fopen("/tmp/test-hs-rd.log", "a");
24     fwrite($fp, "START\n");
25     fclose($fp);
26
27     $s = "";
28     for ($i = 0 ; $i < 4096 ; $i++) {
29         $s .= rand(65,90);
30     }
31     for ($i = 0 ; $i < 15 ; $i++) {
32         // if ($i == 0)
33         //    sleep(1);
34      
35         if ($i == 8) {
36             // exit();
37             sleep(30);
38         }
39         printf("<script id='hs%d' type='text/javascript'>
40 push(\"$('cont').innerHTML += '%s %d';\");
41 </script>", $i, ($i == 0 ? "<br/>" : ""), $i);
42
43         if ($i == 0)
44             printf("<!-- %s -->", $s);
45         mop_flush();
46         usleep(1000000);
47     }
48 }
49 main();
50 ?>
51 </html>