From: Matteo Nastasi (mop) Date: Wed, 5 Dec 2012 09:13:32 +0000 (+0100) Subject: some fixes for xhr and iframe transport came to light after hunged stream test was... X-Git-Tag: v4.4.0~4 X-Git-Url: http://mop.ddnsfree.com/gitweb/?a=commitdiff_plain;h=087d3262b6c01417dad7b9eb365374fe5a9f2ba1;p=brisk.git some fixes for xhr and iframe transport came to light after hunged stream test was added --- diff --git a/web/Obj/sac-a-push.phh b/web/Obj/sac-a-push.phh index 3f5c4c1..c6858b8 100644 --- a/web/Obj/sac-a-push.phh +++ b/web/Obj/sac-a-push.phh @@ -339,7 +339,7 @@ class Sac_a_push { $thiz->rndstr = ""; for ($i = 0 ; $i < 4096 ; $i++) { if (($i % 128) == 0) - $thiz->rndstr .= "\n"; + $thiz->rndstr .= " "; else $thiz->rndstr .= chr(mt_rand(65, 90)); } diff --git a/web/Obj/transports.phh b/web/Obj/transports.phh index 92f11b4..fcf1631 100644 --- a/web/Obj/transports.phh +++ b/web/Obj/transports.phh @@ -47,7 +47,7 @@ class Transport_xhr { function init($enc, &$header_out, $init_string, $base, $step) { - $ret = $init_string; + $ret = sprintf("@BEGIN@ /* %s */ @END@", $init_string); if ($enc != 'plain') $header_out['Content-Encoding'] = $enc; $header_out['Cache-Control'] = 'no-cache, must-revalidate'; // HTTP/1.1 diff --git a/web/xynt-streaming.js b/web/xynt-streaming.js index 47ca442..fe14f24 100644 --- a/web/xynt-streaming.js +++ b/web/xynt-streaming.js @@ -95,6 +95,7 @@ transport_xhr.prototype = { }, ctx_new_getchar: function(idx) { /* public */ + return (this.ctx_new[idx]); }, ctx_old_len_is_set: function () { /* public */ @@ -247,13 +248,13 @@ transport_iframe.prototype = { try { if (this.ifra != null) { // FIXME: with opera on win this remove child crash js so is - // commented - // this.doc.body.removeChild(this.ifra); + // commented AND NOWWW ???? + this.doc.body.removeChild(this.ifra); delete this.ifra; this.ifra = null; } } catch (b) { - alert("catched"); + alert("destroy exception catched"); } }, diff --git a/web/xynt_test01.php b/web/xynt_test01.php index 38ddda0..fbeecf6 100644 --- a/web/xynt_test01.php +++ b/web/xynt_test01.php @@ -44,7 +44,7 @@ if ($isstream == "true") { $init_string = ""; for ($i = 0 ; $i < 4096 ; $i++) { if (($i % 128) == 0) - $init_string .= "\n"; + $init_string .= " "; else $init_string .= chr(mt_rand(65, 90)); } @@ -57,13 +57,27 @@ if ($isstream == "true") { print($body); mop_flush(); - for ($i = 1 ; $i < 10 ; $i++) { - $chunk = $transp->chunk($i, sprintf("\$('container').innerHTML = '%d';", $i)); - print($chunk); - mop_flush(); - - // exit(123); - sleep(1); + 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 = 'xx%d';", $i)); + print($chunk); + mop_flush(); + sleep(1); + } + break; + case 2: + // 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 = 'yy%d';", $i)); + print($chunk); + mop_flush(); + sleep(1); + if ($i == 8) + sleep(60); + } + break; } exit; } @@ -83,7 +97,8 @@ if ($isstream == "true") { var subst = ""; var gst = new globst(); window.onload = function() { - xstm = new xynt_streaming(window, "", null /* console */, gst, 'xynt_test01_php', 'sess', sess, null, 'xynt_test01.php?isstream=true', function(com){eval(com);}); + + xstm = new xynt_streaming(window, "", null /* console */, gst, 'xynt_test01_php', 'sess', sess, null, 'xynt_test01.php?isstream=true&f_test=', function(com){eval(com);}); /* xstm.hbit_set(heartbit); */ xstm.start(); }