From c35dd062490b68aa01f887afa3ddf705b3e32372 Mon Sep 17 00:00:00 2001 From: "Matteo Nastasi (mop)" Date: Mon, 10 Dec 2012 10:25:41 +0100 Subject: [PATCH] xhr transport added --- TODO.txt | 3 +- web/Obj/brisk.phh | 13 +++++-- web/Obj/transports.phh | 49 ++++++++++++++++++++++++ web/Obj/user.phh | 8 ++-- web/briskin5/Obj/briskin5.phh | 9 ++++- web/commons.js | 6 ++- web/xynt-streaming.js | 21 +++++++--- web/xynt_test01.php | 72 ++++++++++++++++++++++++++++++++--- 8 files changed, 158 insertions(+), 23 deletions(-) diff --git a/TODO.txt b/TODO.txt index aed18eb..c475eff 100644 --- a/TODO.txt +++ b/TODO.txt @@ -12,12 +12,13 @@ - 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 diff --git a/web/Obj/brisk.phh b/web/Obj/brisk.phh index f38b504..f16ba02 100644 --- a/web/Obj/brisk.phh +++ b/web/Obj/brisk.phh @@ -140,10 +140,10 @@ $mlang_brisk = array( 'btn_backstand'=> array( 'it' => 'torna in piedi', $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.'), NOVITA\': 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.'), NOVITA\': nuovo stream dati xhr, prima versione completa.', 'Se vuoi iscriverti alla Mailing List, cliccala!' ), 'en' => array ( 'Brisk (Ver. '.$G_brisk_version.'), NEWS: usage of reader/writer locking instead of generic exclusive locking.', 'If you want to subscribe our Mailing List, click it!' ) ); @@ -2137,8 +2137,13 @@ class Room 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"; diff --git a/web/Obj/transports.phh b/web/Obj/transports.phh index 3de2197..0f0e4a7 100644 --- a/web/Obj/transports.phh +++ b/web/Obj/transports.phh @@ -22,6 +22,37 @@ * */ +/* + * 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() { @@ -139,4 +170,22 @@ push(\"%s\");\n// -->\n", $step, escpush($cont) ); 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 diff --git a/web/Obj/user.phh b/web/Obj/user.phh index a770964..ad63154 100644 --- a/web/Obj/user.phh +++ b/web/Obj/user.phh @@ -294,7 +294,7 @@ class User { 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; @@ -304,7 +304,7 @@ class User { $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() { @@ -688,8 +688,10 @@ function stream_init($init_string, $enc, &$header_out, &$body, $get, $post, $coo $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); diff --git a/web/briskin5/Obj/briskin5.phh b/web/briskin5/Obj/briskin5.phh index 8c51f0b..bd358a0 100644 --- a/web/briskin5/Obj/briskin5.phh +++ b/web/briskin5/Obj/briskin5.phh @@ -1171,8 +1171,13 @@ class Bin5 { 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"; diff --git a/web/commons.js b/web/commons.js index 9f70f65..75cabf4 100644 --- a/web/commons.js +++ b/web/commons.js @@ -235,8 +235,10 @@ function safestatus(a) } 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; diff --git a/web/xynt-streaming.js b/web/xynt-streaming.js index 4ebeb1a..50cea6d 100644 --- a/web/xynt-streaming.js +++ b/web/xynt-streaming.js @@ -138,9 +138,6 @@ function transport_htmlfile(doc, xynt_streaming, page) this.xynt_streaming = xynt_streaming; this.transfdoc = new ActiveXObject("htmlfile"); this.transfdoc.open(); - /*this.transfdoc.write("