il client aspetta 3 secondi, e poi da 10 a N ogni secondo"); $transs = array( "iframe", "xhr", "htmlfile" ); if (!isset($f_trans)) $f_trans = $transs[0]; if (!isset($f_test)) $f_test = 1; function mop_flush() { for ($i = 0; $i < ob_get_level(); $i++) ob_end_flush(); ob_implicit_flush(1); flush(); } $escpush_from = array("\\", "\""); $escpush_to = array("\\\\", "\\\""); function escpush($s) { GLOBAL $escpush_from, $escpush_to; return str_replace($escpush_from, $escpush_to, $s); } function xcape($s) { $from = array ( '\\', '@', '|' ); $to = array ( '\\\\', '@', '¦' ); return (str_replace($from, $to, htmlentities($s,ENT_COMPAT,"UTF-8"))); } if ($isstream == "true") { require_once("Obj/transports.phh"); if (isset($transp) && $transp == "xhr") { $transp = new Transport_xhr(); } else if (isset($transp) && $transp == "htmlfile") { $transp = new Transport_htmlfile(); } else { $transp = new Transport_iframe(); } $header_out = array(); $init_string = ""; for ($i = 0 ; $i < 4096 ; $i++) { if (($i % 128) == 0) $init_string .= " "; else $init_string .= chr(mt_rand(65, 90)); } $body = $transp->init("plain", $header_out, $init_string, "", "0"); foreach ($header_out as $key => $value) { header(sprintf("%s: %s", $key, $value)); } print($body); mop_flush(); switch ($f_test) { case 1: // from 1 to 9 into the innerHTML and than close for ($i = 1 ; $i < 10 ; $i++) { $chunk = $transp->chunk($i, sprintf("\$('container').innerHTML = '%d';", $i)); print($chunk); mop_flush(); sleep(1); } break; case 2: // from 1 to 9 into the innerHTML and than close for ($i = 1 ; $i < 10 ; $i++) { $chunk = $transp->chunk($i, sprintf("gst.st++; \$('container').innerHTML = gst.st;")); print($chunk); mop_flush(); sleep(1); } break; case 3: // from 1 to 9 with 60 secs after 8, the client js api must restart stream after 12 secs for ($i = 1 ; $i < 10 ; $i++) { $chunk = $transp->chunk($i, sprintf("\$('container').innerHTML = '%d';", $i)); print($chunk); mop_flush(); sleep(1); if ($i == 8) sleep(60); } break; case 4: // from 1 to 9 into the innerHTML and than close for ($i = 1 ; $i < 10 ; $i++) { if ($i != 5) { $chunk = $transp->chunk($i, sprintf("\$('container').innerHTML = '%d';", $i)); } else { $chunk = $transp->chunk($i, sprintf("\$('container').innerHTML = '%d';|sleep(gst,3000);", $i)); } print($chunk); mop_flush(); sleep(1); } break; case 5: // from 1 to 9 into the innerHTML and than close $cont = array('@BEGIN@', '@END@', '@BEGIN@ sleep(1); @END@'); for ($i = 1 ; $i < 10 ; $i++) { switch($i) { case 6: case 7: case 8: $chunk = $transp->chunk($i, sprintf("\$('container').innerHTML = '%s';", xcape($cont[$i - 6]))); break; default: $chunk = $transp->chunk($i, sprintf("\$('container').innerHTML = '%d';", $i)); break; } print($chunk); mop_flush(); if ($i < 9) sleep(1); } break; case 6: // from 1 to 9 into the innerHTML and than close if ($step == 8) { $chunk = $transp->chunk(1, sprintf("gst.st++; \$('container').innerHTML = gst.st+\" x_x \"+(%d)", $step)); print($chunk); // without this usleep the delay is doubled in iframe stream because // no transp.xynt_streaming back-set is performed usleep(250000); mop_flush(); } else { for ($i = 1 ; $i < 10 ; $i++) { $chunk = $transp->chunk($i, sprintf("gst.st++; \$('container').innerHTML = gst.st+\" _ \"+(%d)", $step)); print($chunk); mop_flush(); if ($i < 9) sleep(1); } } break; } exit; } ?> XYNT TEST01
"); for ($test = 1 ; $test <= count($desc) ; $test++) { printf(""); foreach ($transs as $trans) { printf("Test %s %02d", $trans, $test, $trans, $test); } printf("\n"); } printf(""); printf("
[%s]
Test: %d
", $f_trans, $f_test); ?>
Descrizione:
Counter: BEGIN