3 $desc = array( "Semplice: da 1 a 9 ogni secondo, poi ricomincia.",
4 "Continuo: da 1 a N ogni secondo, ricomincia ogni 9.",
5 "Restart: da 1 a 8 ogni secondo, pausa 16 secondi, poi ricomincia.",
6 "Pausa: da 1 a 5 ogni secondo, pausa 3 secondi, e poi 8 e 9 ogni secondo, e poi ricomincia.",
7 "Keyword: da 1 a 5 ogni secondo, @BEGIN@, @END@, @BEGIN@ xxx yyy @END@, 9",
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");
11 $transs = array( "iframe", "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 == "xhr") {
50 $transp = new Transport_xhr();
52 else if (isset($transp) && $transp == "htmlfile") {
53 $transp = new Transport_htmlfile();
56 $transp = new Transport_iframe();
58 $header_out = array();
61 for ($i = 0 ; $i < 4096 ; $i++) {
65 $init_string .= chr(mt_rand(65, 90));
68 $body = $transp->init("plain", $header_out, $init_string, "", "0");
70 foreach ($header_out as $key => $value) {
71 header(sprintf("%s: %s", $key, $value));
78 // from 1 to 9 into the innerHTML and than close
79 for ($i = 1 ; $i < 10 ; $i++) {
80 $chunk = $transp->chunk($i, sprintf("\$('container').innerHTML = '%d';", $i));
87 // from 1 to 9 into the innerHTML and than close
88 for ($i = 1 ; $i < 10 ; $i++) {
89 $chunk = $transp->chunk($i, sprintf("gst.st++; \$('container').innerHTML = gst.st;"));
96 // from 1 to 9 with 60 secs after 8, the client js api must restart stream after 12 secs
97 for ($i = 1 ; $i < 10 ; $i++) {
98 $chunk = $transp->chunk($i, sprintf("\$('container').innerHTML = '%d';", $i));
107 // from 1 to 9 into the innerHTML and than close
108 for ($i = 1 ; $i < 10 ; $i++) {
110 $chunk = $transp->chunk($i, sprintf("\$('container').innerHTML = '%d';", $i));
113 $chunk = $transp->chunk($i, sprintf("\$('container').innerHTML = '%d';|sleep(gst,3000);", $i));
121 // from 1 to 9 into the innerHTML and than close
122 $cont = array('@BEGIN@', '@END@', '@BEGIN@ sleep(1); @END@');
123 for ($i = 1 ; $i < 10 ; $i++) {
128 $chunk = $transp->chunk($i, sprintf("\$('container').innerHTML = '%s';", xcape($cont[$i - 6])));
131 $chunk = $transp->chunk($i, sprintf("\$('container').innerHTML = '%d';", $i));
141 // from 1 to 9 into the innerHTML and than close
143 $chunk = $transp->chunk(1, sprintf("gst.st++; \$('container').innerHTML = gst.st;"));
145 // without this usleep the delay is doubled in iframe stream because
146 // no transp.xynt_streaming back-set is performed
151 for ($i = 1 ; $i < 10 ; $i++) {
152 $chunk = $transp->chunk($i, sprintf("gst.st++; \$('container').innerHTML = gst.st;"));
166 <title>XYNT TEST01</title>
167 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
168 <script type="text/javascript" src="xynt-streaming.js"></script>
169 <script type="text/javascript" src="commons.js"></script>
171 <!-- <script type="text/javascript" src="myconsole.js"></script> -->
173 <script type="text/javascript"><!--
174 var sess = "for_test";
177 var gst = new globst();
178 window.onload = function() {
180 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);});
181 /* xstm.hbit_set(heartbit); */
194 for ($test = 1 ; $test <= count($desc) ; $test++) {
196 foreach ($transs as $trans) {
197 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);
202 printf("<br>[%s]<br>Test: %d<br>", $f_trans, $f_test);
206 <b>Descrizione</b>: <?php echo $desc[$f_test - 1]; ?>
209 <b>Counter</b>: <span id="container">