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));
71 $body = $transp->init("plain", $header_out, $init_string, "", "0");
73 foreach ($header_out as $key => $value) {
74 header(sprintf("%s: %s", $key, $value));
81 // from 1 to 9 into the innerHTML and than close
82 for ($i = 1 ; $i < 10 ; $i++) {
83 $chunk = $transp->chunk($i, sprintf("\$('container').innerHTML = '%d';", $i));
90 // from 1 to 9 into the innerHTML and than close
91 for ($i = 1 ; $i < 10 ; $i++) {
92 $chunk = $transp->chunk($i, sprintf("gst.st++; \$('container').innerHTML = gst.st;"));
99 // from 1 to 9 with 60 secs after 8, the client js api must restart stream after 12 secs
100 for ($i = 1 ; $i < 10 ; $i++) {
101 $chunk = $transp->chunk($i, sprintf("\$('container').innerHTML = '%d';", $i));
110 // from 1 to 9 into the innerHTML and than close
111 for ($i = 1 ; $i < 10 ; $i++) {
113 $chunk = $transp->chunk($i, sprintf("\$('container').innerHTML = '%d';", $i));
116 $chunk = $transp->chunk($i, sprintf("\$('container').innerHTML = '%d';|sleep(gst,3000);", $i));
124 // from 1 to 9 into the innerHTML and than close
125 $cont = array('@BEGIN@', '@END@', '@BEGIN@ sleep(1); @END@');
126 for ($i = 1 ; $i < 10 ; $i++) {
131 $chunk = $transp->chunk($i, sprintf("\$('container').innerHTML = '%s';", xcape($cont[$i - 6])));
134 $chunk = $transp->chunk($i, sprintf("\$('container').innerHTML = '%d';", $i));
144 // from 1 to 9 into the innerHTML and than close
146 $chunk = $transp->chunk(1, sprintf("gst.st++; \$('container').innerHTML = gst.st;"));
148 // without this usleep the delay is doubled in iframe stream because
149 // no transp.xynt_streaming back-set is performed
154 for ($i = 1 ; $i < 10 ; $i++) {
155 $chunk = $transp->chunk($i, sprintf("gst.st++; \$('container').innerHTML = gst.st;"));
169 <title>XYNT TEST01</title>
170 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
171 <script type="text/javascript" src="xynt-streaming.js"></script>
172 <script type="text/javascript" src="commons.js"></script>
173 <script type="text/javascript" src="heartbit.js"></script>
175 <!-- <script type="text/javascript" src="myconsole.js"></script> -->
177 <script type="text/javascript"><!--
178 var sess = "for_test";
181 var gst = new globst();
182 window.onload = function() {
184 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);});
185 xstm.hbit_set(heartbit);
198 for ($test = 1 ; $test <= count($desc) ; $test++) {
200 foreach ($transs as $trans) {
201 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);
206 printf("<br>[%s]<br>Test: %d<br>", $f_trans, $f_test);
210 <b>Descrizione</b>: <?php echo $desc[$f_test - 1]; ?>
214 <b>Status</b>: <img id="stm_stat" class="nobo" style="vertical-align: bottom;" src="img/line-status_b.png"></div>
218 <b>Counter</b>: <span id="container">