3 $desc = array( "Semplice: da 1 a 9 ogni secondo, poi ricomincia (status sempre verde).",
4 "Continuo: da 1 a N ogni secondo, ricomincia ogni 9 (status sempre verde).",
5 "Restart: da 1 a 8 ogni secondo, pausa 16 secondi (status passa ad arancione e poi a rosso), poi ricomincia (e status torna a verde).",
6 "Pausa: da 1 a 5 ogni secondo, pausa 3 secondi, e poi 8 e 9 ogni secondo, e poi ricomincia (status sempre verde).",
7 "Keyword: da 1 a 5 ogni secondo, @BEGIN@, @END@, @BEGIN@ xxx yyy @END@, 9, (status sempre verde).",
8 "Reload limiter: da 1 a 8 ogni secondo e chiude, 9 setta e chiude subito,<br>il client aspetta 3 secondi, e poi da 10 a N ogni secondo, (status sempre verde).");
11 $transs = array( "iframe", "websocket", "xhr", "htmlfile" );
13 $f_trans = $transs[0];
21 for ($i = 0; $i < ob_get_level(); $i++)
27 $escpush_from = array("\\", "\"");
28 $escpush_to = array("\\\\", "\\\"");
31 GLOBAL $escpush_from, $escpush_to;
33 return str_replace($escpush_from, $escpush_to, $s);
38 $from = array ( '\\', '@', '|' );
39 $to = array ( '\\\\', '@', '¦' );
41 return (str_replace($from, $to, htmlentities($s,ENT_COMPAT,"UTF-8")));
44 if ($isstream == "true") {
46 require_once("Obj/transports.phh");
49 if (isset($transp) && $transp == "websocket") {
50 $transp = new Transport_websocket();
52 else if (isset($transp) && $transp == "xhr") {
53 $transp = new Transport_xhr();
55 else if (isset($transp) && $transp == "htmlfile") {
56 $transp = new Transport_htmlfile();
59 $transp = new Transport_iframe();
61 $header_out = array();
64 for ($i = 0 ; $i < 4096 ; $i++) {
68 $init_string .= chr(mt_rand(65, 90));
72 $body = $transp->init("plain", $header, $header_out, $init_string, "", "0");
74 foreach ($header_out as $key => $value) {
75 header(sprintf("%s: %s", $key, $value));
82 // from 1 to 9 into the innerHTML and than close
83 for ($i = 1 ; $i < 10 ; $i++) {
84 $chunk = $transp->chunk($i, sprintf("\$('container').innerHTML = '%d';", $i));
91 // from 1 to 9 into the innerHTML and than close
92 for ($i = 1 ; $i < 10 ; $i++) {
93 $chunk = $transp->chunk($i, sprintf("gst.st++; \$('container').innerHTML = gst.st;"));
100 // from 1 to 9 with 60 secs after 8, the client js api must restart stream after 12 secs
101 for ($i = 1 ; $i < 10 ; $i++) {
102 $chunk = $transp->chunk($i, sprintf("\$('container').innerHTML = '%d';", $i));
111 // from 1 to 9 into the innerHTML and than close
112 for ($i = 1 ; $i < 10 ; $i++) {
114 $chunk = $transp->chunk($i, sprintf("\$('container').innerHTML = '%d';", $i));
117 $chunk = $transp->chunk($i, sprintf("\$('container').innerHTML = '%d';|sleep(gst,3000);", $i));
125 // from 1 to 9 into the innerHTML and than close
126 $cont = array('@BEGIN@', '@END@', '@BEGIN@ sleep(1); @END@');
127 for ($i = 1 ; $i < 10 ; $i++) {
132 $chunk = $transp->chunk($i, sprintf("\$('container').innerHTML = '%s';", xcape($cont[$i - 6])));
135 $chunk = $transp->chunk($i, sprintf("\$('container').innerHTML = '%d';", $i));
145 // from 1 to 9 into the innerHTML and than close
147 $chunk = $transp->chunk(1, sprintf("gst.st++; \$('container').innerHTML = gst.st;"));
149 // without this usleep the delay is doubled in iframe stream because
150 // no transp.xynt_streaming back-set is performed
155 for ($i = 1 ; $i < 10 ; $i++) {
156 $chunk = $transp->chunk($i, sprintf("gst.st++; \$('container').innerHTML = gst.st;"));
170 <title>XYNT TEST01</title>
171 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
172 <script type="text/javascript" src="xynt-streaming.js"></script>
173 <script type="text/javascript" src="commons.js"></script>
174 <script type="text/javascript" src="heartbit.js"></script>
176 <!-- <script type="text/javascript" src="myconsole.js"></script> -->
178 <script type="text/javascript"><!--
179 var sess = "for_test";
182 var gst = new globst();
183 window.onload = function() {
185 xstm = new xynt_streaming(window, "<?php echo "$f_trans";?>", null /* console */, gst, 'xynt_test01_php', 'sess', sess, null, 'xynt_test01.php?isstream=true&f_test=<?php echo "$f_test";?>', function(com){eval(com);});
186 xstm.hbit_set(heartbit);
199 for ($test = 1 ; $test <= count($desc) ; $test++) {
201 foreach ($transs as $trans) {
202 printf("<td style=\"padding: 8px; border: 1px solid black;\"><a href=\"?f_trans=%s&f_test=%d\">Test %s %02d</a></td>", $trans, $test, $trans, $test);
207 printf("<br>[%s]<br>Test: %d<br>", $f_trans, $f_test);
211 <b>Descrizione</b>: <?php echo $desc[$f_test - 1]; ?>
215 <b>Status</b>: <img id="stm_stat" class="nobo" style="vertical-align: bottom;" src="img/line-status_b.png"></div>
219 <b>Counter</b>: <span id="container">