transport_xhr added
[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     $transp = new Transport_xhr();
30
31     $header_out = array();
32
33     $init_string = "";
34     for ($i = 0 ; $i < 4096 ; $i++) {
35         if (($i % 128) == 0)
36             $init_string .= "\n";
37         else
38             $init_string .= chr(mt_rand(65, 90));
39     }
40
41     $body = $transp->init("plain", $header_out, $init_string, "", "0");
42
43     foreach ($header_out as $key => $value) {
44         header(sprintf("%s: %s", $key, $value));
45     }
46     print($body);
47     mop_flush();
48
49     for ($i = 1 ; $i < 20 ; $i++) {
50         $chunk = $transp->chunk($i, sprintf("\$('container').innerHTML = '%d';", $i));
51         print($chunk);
52         mop_flush();
53         
54         // exit(123);
55         sleep(1);
56     }
57     exit;
58 }
59 ?>
60 <html>
61 <head>
62 <title>XYNT TEST01</title>
63 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
64 <script type="text/javascript" src="xynt-streaming.js"></script>
65 <script type="text/javascript" src="commons.js"></script>
66
67 <!-- <script type="text/javascript" src="myconsole.js"></script> -->
68 <!-- 
69 <script type="text/javascript" src="menu.js"></script>
70 <script type="text/javascript" src="ticker.js"></script>
71 <script type="text/javascript" src="heartbit.js"></script>
72 <script type="text/javascript" src="room.js"></script>
73 <script type="text/javascript" src="preload_img.js"></script>
74 <script type="text/javascript" src="AC_OETags.js"></script>
75 <script type="text/javascript" src="probrowser.js"></script>
76 -->
77 <SCRIPT type="text/javascript"><!--
78      var sess = "for_test";
79      var stat = "";
80      var subst = "";
81      var gst = new globst();
82      window.onload = function() {
83      xstm = new xynt_streaming(window, "xhr", null /* console */, gst, 'xynt_test01_php', 'sess', sess, null, 'xynt_test01.php?isstream=true', function(com){eval(com);});
84      /*     xstm.hbit_set(heartbit); */
85      xstm.start();
86  }
87  //-->
88 </SCRIPT>
89 </head>
90 <!-- if myconsole <body onunload="deconsole();"> -->
91 <body>
92 <div id="container">
93 BEGIN
94 </div>
95 </body>
96 </html>