transports isolation in php code
[brisk.git] / web / xynt_test01.php
1 <?php
2
3 function mop_flush()
4 {
5     for ($i = 0; $i < ob_get_level(); $i++)
6         ob_end_flush();
7     ob_implicit_flush(1);
8     flush();
9 }
10
11 $escpush_from = array("\\", "\"");
12 $escpush_to   = array("\\\\", "\\\"");
13 function escpush($s)
14 {
15     GLOBAL $escpush_from, $escpush_to;
16
17     return str_replace($escpush_from, $escpush_to, $s);
18 }
19
20 if ($isstream == "true") {
21
22     require_once("Obj/transports.phh");
23
24
25     // TODO: what stream ? 
26     //       iframe, htmlfile, xhr
27
28     $transp = new Transport_iframe();
29
30     $header_out = array();
31
32     $init_string = "";
33     for ($i = 0 ; $i < 4096 ; $i++) {
34         if (($i % 128) == 0)
35             $init_string .= "\n";
36         else
37             $init_string .= chr(mt_rand(65, 90));
38     }
39
40     $body = $transp->init("plain", $header_out, $init_string, "", "0");
41
42     foreach ($header_out as $key => $value) {
43         header(sprintf("%s: %s", $key, $value));
44     }
45     print($body);
46     mop_flush();
47
48     for ($i = 1 ; $i < 20 ; $i++) {
49         $chunk = $transp->chunk($i, sprintf("\$('container').innerHTML = '%d';", $i));
50         print($chunk);
51         mop_flush();
52         
53         // exit(123);
54         sleep(1);
55     }
56     exit;
57 }
58 ?>
59 <html>
60 <head>
61 <title>XYNT TEST01</title>
62 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
63 <script type="text/javascript" src="xynt-streaming.js"></script>
64 <script type="text/javascript" src="commons.js"></script>
65
66 <!-- <script type="text/javascript" src="myconsole.js"></script> -->
67 <!-- 
68 <script type="text/javascript" src="menu.js"></script>
69 <script type="text/javascript" src="ticker.js"></script>
70 <script type="text/javascript" src="heartbit.js"></script>
71 <script type="text/javascript" src="room.js"></script>
72 <script type="text/javascript" src="preload_img.js"></script>
73 <script type="text/javascript" src="AC_OETags.js"></script>
74 <script type="text/javascript" src="probrowser.js"></script>
75 -->
76 <SCRIPT type="text/javascript"><!--
77      var sess = "for_test";
78      var stat = "";
79      var subst = "";
80      var gst = new globst();
81      window.onload = function() {
82      xstm = new xynt_streaming(window, "iframe", null /* console */, gst, 'xynt_test01_php', 'sess', sess, null, 'xynt_test01.php?isstream=true', function(com){eval(com);});
83      /*     xstm.hbit_set(heartbit); */
84      xstm.start();
85  }
86  //-->
87 </SCRIPT>
88 </head>
89 <!-- if myconsole <body onunload="deconsole();"> -->
90 <body>
91 <div id="container">
92 BEGIN
93 </div>
94 </body>
95 </html>