- try to be more antivirus-friendly
- packetize and automatize php-ancillary and apache module
- into the room local step remains -1
- - add xhr as transport layer and manage different streams better
- DISABLED_TO_FIX: DNS access (perform blocking dns requests, must be fixed)
DONE |
------+
+ DONE - manage too fast reload in xynt-streaming
+ DONE - add xhr as transport layer and manage different streams better
TEST - BUG: pari + 72 non fa 4x ma attualmente fa 3x, da correggere
TEST - BUG: lurker are logged out (and remain a pending socket opened (look the spush log)
DONE - save/restore database
$G_lng = langtolng($G_lang);
$G_all_points = array( 11,10,4,3,2, 0,0,0,0,0 );
-$G_brisk_version = "4.3.0";
+$G_brisk_version = "4.4.0";
/* MLANG: ALL THE INFO STRINGS IN brisk.phh */
-$root_wellarr = array( 'it' => array ( 'Brisk (Ver. '.$G_brisk_version.'), <b>NOVITA\'</b>: adottato sac-a-push come motore per l\'invio dei dati in tempo reale, nuovo trasporto httpfile per explorer, tanti bug fixati, freeze su disco, fix del calcolo dei punti, nuovo stream dati xhr.',
+$root_wellarr = array( 'it' => array ( 'Brisk (Ver. '.$G_brisk_version.'), <b>NOVITA\'</b>: nuovo stream dati xhr, prima versione completa.',
'Se vuoi iscriverti alla <a target="_blank" href="mailto:ml-briscola+subscribe@milug.org">Mailing List</a>, cliccala!' ),
'en' => array ( 'Brisk (Ver. '.$G_brisk_version.'), <b>NEWS</b>: usage of reader/writer locking instead of generic exclusive locking.',
'If you want to subscribe our <a target="_blank" href="ml-briscola+subscribe@milug.org">Mailing List</a>, click it!' ) );
printf("NEW_SOCKET (root): %d\n", intval($new_socket));
$enc = get_encoding($header);
- if (isset($header['User-Agent']) && strstr($header['User-Agent'], "MSIE")) {
- $transp_type = "htmlfile";
+ if (isset($header['User-Agent'])) {
+ if (strstr($header['User-Agent'], "MSIE")) {
+ $transp_type = "htmlfile";
+ }
+ else {
+ $transp_type = "xhr";
+ }
}
else {
$transp_type = "iframe";
*
*/
+/*
+ * test: SO x Browser
+ * Values: Y: works, N: not works, @: continuous download,
+ * D: continuous download after first reload
+ *
+ * Stream IFRAME:
+ *
+ * Iframe| IW | FF | Ch | Op | Ko | IE
+ * ------+----+----+----+----+----+----
+ * Lnx | D | | @ | | @ | x
+ * Win | x | D | @ | @ | | D
+ * Mac | x | | | | |
+ *
+ *
+ * XHR | IW | FF | Ch | Op | Ko | IE
+ * ------+----+----+----+----+----+----
+ * Lnx | Y | | ^D | | Y | x
+ * Win | x | Y | Y | | | N
+ * Mac | x | | | | |
+ *
+ *
+ * HtmlFl| IW | FF | Ch | Op | Ko | IE
+ * ------+----+----+----+----+----+----
+ * Lnx | N | | | | N |
+ * Win | x | N | N | | | Y* (* seems delay between click and load of a new page)
+ * Mac | x | | | | |
+ *
+ *
+ */
+
+
class Transport_template {
function Transport_template() {
class Transport_htmlfile extends Transport_iframe {
}
+class Transport {
+ function Transport()
+ {
+ }
+
+ static function create($transp)
+ {
+ if ($transp == 'xhr') {
+ return new Transport_xhr();
+ }
+ else if ($transp == 'htmlfile') {
+ return new Transport_htmlfile();
+ }
+ else {
+ return new Transport_iframe();
+ }
+ }
+}
?>
\ No newline at end of file
return ($thiz);
}
- function rd_data_set($curtime, $enc, $stat, $subst, $step, $from)
+ function rd_data_set($curtime, $transp, $enc, $stat, $subst, $step, $from)
{
$this->rd_endtime = $curtime + RD_ENDTIME_DELTA;
$this->rd_stat = $stat;
$this->rd_scristp = 0;
$this->rd_kalive = $curtime + RD_KEEPALIVE_TOUT;
$this->rd_zls = ZLibStream::create($enc);
- $this->rd_transp = new Transport_iframe();
+ $this->rd_transp = Transport::create($transp);
}
function rd_socket_get() {
$subst = "";
if (($step = gpcs_var('step', $get, $post, $cookie)) === FALSE)
unset($step);
+ if (($transp = gpcs_var('transp', $get, $post, $cookie)) === FALSE)
+ $transp = "iframe";
- $this->rd_data_set($curtime, $enc, $stat, $subst, $step, $from);
+ $this->rd_data_set($curtime, $transp, $enc, $stat, $subst, $step, $from);
$body .= $this->rd_transp->init($enc, &$header_out, $init_string, self::base_get(), $this->rd_scristp);
printf("NEW_SOCKET (root): %d\n", intval($new_socket));
$enc = get_encoding($header);
- if (isset($header['User-Agent']) && strstr($header['User-Agent'], "MSIE")) {
- $transp_type = "htmlfile";
+ if (isset($header['User-Agent'])) {
+ if (strstr($header['User-Agent'], "MSIE")) {
+ $transp_type = "htmlfile";
+ }
+ else {
+ $transp_type = "xhr";
+ }
}
else {
$transp_type = "iframe";
}
function createXMLHttpRequest() {
- try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) {}
- try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) {}
+ if (typeof(ActiveXObject) != 'undefined') { // Konqueror complain as unknown object
+ try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) {}
+ try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) {}
+ }
try { return new XMLHttpRequest(); } catch(e) {}
alert("XMLHttpRequest not supported");
return null;
this.xynt_streaming = xynt_streaming;
this.transfdoc = new ActiveXObject("htmlfile");
this.transfdoc.open();
- /*this.transfdoc.write("<html><head><script>");
- this.transfdoc.write("document.domain=\""+(doc.domain)+"\";");
- this.transfdoc.write("</"+"script></"+"head>"); */
this.transfdoc.write("<html><body><iframe id='iframe'></iframe></body></html>");
this.transfdoc.close();
return (typeof(this.ifra.contentWindow.xynt_streaming) != 'undefined');
},
+ /* only after a successfull is_initialized call */
+ xstr_is_ready: function () { /* public */
+ return (this.ifra.contentWindow.xynt_streaming == "ready");
+ },
+
/* only after a successfull is_initialized call */
xstr_set: function () { /* public */
if (this.ifra.contentWindow.xynt_streaming == "ready") {
this.page = page;
this.cmdproc = cmdproc;
// this.cmdproc = function(com){/* console.log("COM: "+com); */ eval(com);}
-
this.doc = win.document;
this.keepalive_old = -1;
this.keepalive_new = -1;
page: null,
cmdproc: null,
+ start_time: 0,
+ restart_wait: 5000, // wait restart_wait millisec before begin to check if restart is needed
+
doc: null,
cookiepath: "/brisk/",
watchdog_hdl: null,
/* restart after 4 * 40 * 100 millisec if server ping is missing => 16secs */
keepalives_eq_max: 4,
watchdog_checktm: 40,
- // FIXME watchdog_timeout: 100,
watchdog_timeout: 100,
watchdog_ct: 0,
watchable: false,
if (!this.the_end) {
this.watchdog_hdl = setTimeout(function(obj) { obj.log("tout1"); obj.watchdog(); }, this.watchdog_timeout, this);
}
+
+ var date = new Date();
+ this.start_time = date.getTime();
},
stop: function() {
} while (again);
this.watchdog_ct++;
if (!this.the_end) {
- this.transp.postproc();
+ var date = new Date();
+ if (date.getTime() > (this.start_time + this.restart_wait)) {
+ this.transp.postproc();
+ }
this.watchdog_hdl = setTimeout(function(obj) { /* obj.log("tout2"); */ obj.watchdog(); }, this.watchdog_timeout, this);
}
// alert("watchdog return normal");
<?php
+$desc = array( "Semplice: da 1 a 9 ogni secondo, poi ricomincia.",
+ "Continuo: da 1 a N ogni secondo, ricomincia ogni 9.",
+ "Restart: da 1 a 8 ogni secondo, pausa 16 secondi, poi ricomincia.",
+ "Pausa: da 1 a 5 ogni secondo, pausa 3 secondi, e poi 8 e 9 ogni secondo, e poi ricomincia.",
+ "Keyword: da 1 a 5 ogni secondo, @BEGIN@, @END@, @BEGIN@ xxx yyy @END@, 9",
+ "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");
+
+
$transs = array( "iframe", "xhr", "htmlfile" );
if (!isset($f_trans))
$f_trans = $transs[0];
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");
}
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));
sleep(60);
}
break;
- case 3:
+ case 4:
// from 1 to 9 into the innerHTML and than close
for ($i = 1 ; $i < 10 ; $i++) {
if ($i != 5) {
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;
}
<div>
<?php
-$desc = array( "Semplice: da 1 a 9 ogni secondo, poi ricomincia.",
- "Restart: da 1 a 8 ogni secondo, pausa 16 secondi, poi ricomincia.",
- "Pausa: da 1 a 5 ogni secondo, pausa 3 secondi, e poi 8 e 9 ogni secondo, e poi ricomincia.");
printf("<table>");
-for ($test = 1 ; $test <= 3 ; $test++) {
+for ($test = 1 ; $test <= count($desc) ; $test++) {
printf("<tr>");
foreach ($transs as $trans) {
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);