sed -i "s@var \+cookiepath \+= \+\"[^\"]*\";@var cookiepath = \"$prefix_path\";@g" ${web_path}__/commons.js
-sed -i "s@\( \+cookiepath *: *\)\"[^\"]*\" *,@\1 \"$prefix_path\",@g" ${web_path}__/xynt-http-streaming.js
+sed -i "s@\( \+cookiepath *: *\)\"[^\"]*\" *,@\1 \"$prefix_path\",@g" ${web_path}__/xynt-streaming.js
document_root="$(grep DocumentRoot "${apache_conf}" | grep -v '^#' | awk '{ print $2 }')"
sed -i "s@^\(\$DOCUMENT_ROOT *= *[\"']\)[^\"']*\([\"']\)@\1$document_root\2@g" ${web_path}__/spush/*.ph*
$ret = "gst.st = ".($user_cur->step+1)."; ".($remove_wagon ? sprintf("tra.rem(%d);",$table_idx) : "");
if ($from_table && ($user_cur->table == $table_idx || $user->idx_get() == $i)) {
- $ret .= 'gst.st_loc++; hstm.stop(); window.onunload = null; window.onbeforeunload = null; document.location.assign("index.php");|';
+ $ret .= 'gst.st_loc++; xstm.stop(); window.onunload = null; window.onbeforeunload = null; document.location.assign("index.php");|';
// $ret .= 'gst.st_loc++; document.location.assign("index.php");|';
log_main("DOCUMENT.index.php: from table");
}
$is_page_streaming = TRUE;
log_crit("BLOCKING_ERROR UNREC: ".($is_unrecoverable ? "TRUE" : "FALSE"));
- return (sprintf(($is_unrecoverable ? 'hstm.stop(); ' : '').'window.onbeforeunload = null; window.onunload = null; document.location.assign("index.php");'));
+ return (sprintf(($is_unrecoverable ? 'xstm.stop(); ' : '').'window.onbeforeunload = null; window.onunload = null; document.location.assign("index.php");'));
}
// FIXME TO SUPPORT iframe
log_rd2("PAGE_SYNC");
printf("xXx USER::PAGE_SYNC [%s]\n", get_class($this));
- return (sprintf('createCookie("table_idx", %d, 24*365, cookiepath); createCookie("table_token", "%s", 24*365, cookiepath); hstm.stop(); window.onunload = null; window.onbeforeunload = null; document.location.assign("%s");', $table_idx, $table_token, $page));
+ return (sprintf('createCookie("table_idx", %d, 24*365, cookiepath); createCookie("table_token", "%s", 24*365, cookiepath); xstm.stop(); window.onunload = null; window.onbeforeunload = null; document.location.assign("%s");', $table_idx, $table_token, $page));
}
$body .= sprintf("<html>
<head>
<script type=\"text/javascript\" src=\"%scommons.js\"></script>
-<script type=\"text/javascript\" src=\"%sxynt-http-streaming-ifra.js\"></script>
+<script type=\"text/javascript\" src=\"%sxynt-streaming-ifra.js\"></script>
<script type=\"text/javascript\">
-var http_streaming = \"ready\";", self::base_get(), self::base_get());
+var xynt_streaming = \"ready\";", self::base_get(), self::base_get());
$body .= sprintf("
-window.onload = function () { if (http_streaming != \"ready\") { http_streaming.reload(); } };
+window.onload = function () { if (xynt_streaming != \"ready\") { xynt_streaming.reload(); } };
</script>
</head>
<body>");
$body .= sprintf("<html>
<head>
<script type=\"text/javascript\" src=\"%scommons.js\"></script>
-<script type=\"text/javascript\" src=\"%sxynt-http-streaming-ifra.js\"></script>
+<script type=\"text/javascript\" src=\"%sxynt-streaming-ifra.js\"></script>
<script type=\"text/javascript\">
-var http_streaming = \"ready\";", self::base_get(), self::base_get());
+var xynt_streaming = \"ready\";", self::base_get(), self::base_get());
if ($this->rd_scristp > 0)
$body .= sprintf("last_clean = %d;\n", ($this->rd_scristp-1));
$body .= sprintf("
-window.onload = function () { if (http_streaming != \"ready\") { http_streaming.reload(); } };
+window.onload = function () { if (xynt_streaming != \"ready\") { xynt_streaming.reload(); } };
</script>
</head>
<body>");
$body .= sprintf("<html>
<head>
<script type=\"text/javascript\" src=\"%scommons.js\"></script>
-<script type=\"text/javascript\" src=\"%sxynt-http-streaming-ifra.js\"></script>
+<script type=\"text/javascript\" src=\"%sxynt-streaming-ifra.js\"></script>
<script type=\"text/javascript\">
-var http_streaming = \"ready\";", self::base_get(), self::base_get());
+var xynt_streaming = \"ready\";", self::base_get(), self::base_get());
$body .= sprintf("
-window.onload = function () { if (http_streaming != \"ready\") { http_streaming.reload(); } };
+window.onload = function () { if (xynt_streaming != \"ready\") { xynt_streaming.reload(); } };
</script>
</head>
<body>");
$is_page_streaming = TRUE;
log_crit("BLOCKING_ERROR UNREC: ".($is_unrecoverable ? "TRUE" : "FALSE"));
- return (sprintf(($is_unrecoverable ? 'hstm.stop(); ' : '').'window.onbeforeunload = null; window.onunload = null; document.location.assign("../index.php");'));
+ return (sprintf(($is_unrecoverable ? 'xstm.stop(); ' : '').'window.onbeforeunload = null; window.onunload = null; document.location.assign("../index.php");'));
}
protected function page_sync($sess, $page)
$is_page_streaming = TRUE;
log_rd2("PAGE_SYNC");
printf("xXx BIN5_USER::PAGE_SYNC\n");
- return (sprintf('hstm.stop(); window.onbeforeunload = null; window.onunload = null; document.location.assign("%s");', $page));
+ return (sprintf('xstm.stop(); window.onbeforeunload = null; window.onunload = null; document.location.assign("%s");', $page));
}
protected function maincheck($cur_stat, $cur_subst, $cur_step, &$new_stat, &$new_subst, &$new_step, $splashdate, $table_idx, $table_token)
$user_cur->laccwr = $curtime;
$ret = "gst.st = ".($user_cur->step+1)."; ";
- $ret .= 'gst.st_loc++; hstm.stop(); window.onbeforeunload = null; window.onunload = null; document.location.assign("../index.php");|';
+ $ret .= 'gst.st_loc++; xstm.stop(); window.onbeforeunload = null; window.onunload = null; document.location.assign("../index.php");|';
log_wr($user_cur->sess." BIN5_WAKEUP: ".$ret);
$user_cur->comm[$user_cur->step % COMM_N] = $ret;
<link rel="shortcut icon" href="../img/brisk_ico.png">
<script type="text/javascript" src="../commons.js"></script>
<script type="text/javascript" src="../heartbit.js"></script>
-<script type="text/javascript" src="../xynt-http-streaming.js"></script>
+<script type="text/javascript" src="../xynt-streaming.js"></script>
<script type="text/javascript" src="dnd.js"></script>
<script type="text/javascript" src="dom-drag.js"></script>
<script type="text/javascript" src="preload_img<?php echo langtolng($G_lang); ?>.js"></script>
<body>
<SCRIPT type="text/javascript">
var sess = "not_connected";
- var hstm = null;
+ var xstm = null;
var g_lang = "<?php echo "$G_lang"; ?>";
var stat = "table";
var subst = "none";
preferences_update();
sess = "<?php echo "$sess"; ?>";
- hstm = new http_streaming(window, null /* console */, gst, 'table_php', 'sess', sess, $('sandbox'), 'index_rd_ifra.php', function(com){eval(com);});
- hstm.hbit_set(heartbit);
+ xstm = new xynt_streaming(window, null /* console */, gst, 'table_php', 'sess', sess, $('sandbox'), 'index_rd_ifra.php', function(com){eval(com);});
+ xstm.hbit_set(heartbit);
window.onbeforeunload = onbeforeunload_cb;
window.onunload = onunload_cb;
- hstm.start();
+ xstm.start();
// FIXME: add this setTimeout(preload_images into data stream to avoid
// race on opened socket
// setTimeout(preload_images, 0, g_preload_img_arr, g_imgct);
$is_page_streaming = TRUE;
log_rd2("BLOCKING_ERROR UNREC: ".($is_unrecoverable ? "TRUE" : "FALSE"));
- return (sprintf(($is_unrecoverable ? 'hstm.stop(); ' : '').'window.onbeforeunload = null; window.onunload = null; document.location.assign("../index.php");'));
+ return (sprintf(($is_unrecoverable ? 'xstm.stop(); ' : '').'window.onbeforeunload = null; window.onunload = null; document.location.assign("../index.php");'));
}
function page_sync($sess, $page)
$is_page_streaming = TRUE;
log_rd2("PAGE_SYNC");
- return (sprintf('hstm.stop(); window.onbeforeunload = null; window.onunload = null; document.location.assign("%s");', $page));
+ return (sprintf('xstm.stop(); window.onbeforeunload = null; window.onunload = null; document.location.assign("%s");', $page));
}
function maincheck($sess, $cur_stat, $cur_subst, $cur_step, &$new_stat, &$new_subst, &$new_step, $table_idx, $table_token)
if (($sem = Bin5::lock_data(FALSE, $table_idx)) == FALSE) {
// wait 20 secs, then restart the xhr
ignore_user_abort(FALSE);
- return ("sleep(gst,20000);|hstm.xhr_abort();");
+ return ("sleep(gst,20000);|xstm.xhr_abort();");
}
if (($user = Bin5_user::load_data($table_idx, $proxy_step['i'], $sess)) == FALSE) {
if (($sem = Bin5::lock_data(TRUE, $table_idx)) == FALSE) {
// wait 20 secs, then restart the xhr
ignore_user_abort(FALSE);
- return ("sleep(gst,20000);|hstm.xhr_abort();");
+ return ("sleep(gst,20000);|xstm.xhr_abort();");
}
$S_load_stat['lL_laccgarb']++;
// else {
// ignore_user_abort(FALSE);
-// return ("sleep(gst,20000);|hstm.xhr_abort();");
+// return ("sleep(gst,20000);|xstm.xhr_abort();");
// }
// $first_loop = FALSE;
<!--<script type="text/javascript" src="myconsole.js"></script> -->
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript" src="heartbit.js"></script>
-<script type="text/javascript" src="xynt-http-streaming.js"></script>
+<script type="text/javascript" src="xynt-streaming.js"></script>
<script type="text/javascript" src="preload_img<?php echo langtolng($G_lang); ?>.js"></script>
<script type="text/javascript" src="AC_OETags.js"></script>
<script type="text/javascript" src="room.js"></script>
var gst = new globst();
var topbanner_sfx, topbanner_dx;
var g_brow = null;
- var hstm = null;
+ var xstm = null;
var sess = "not_connected";
var spo_slide, sup_slide;
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript" src="ticker.js"></script>
<script type="text/javascript" src="heartbit.js"></script>
-<script type="text/javascript" src="xynt-http-streaming.js"></script>
+<script type="text/javascript" src="xynt-streaming.js"></script>
<script type="text/javascript" src="room.js"></script>
<script type="text/javascript" src="preload_img<?php echo langtolng($G_lang); ?>.js"></script>
<script type="text/javascript" src="AC_OETags.js"></script>
?>
sess = "<?php echo "$sess"; ?>";
-hstm = new http_streaming(window, null /* console*/ , gst, 'index_php', 'sess', sess, $('sandbox'), 'index_rd_ifra.php', function(com){eval(com);});
- hstm.hbit_set(heartbit);
+xstm = new xynt_streaming(window, null /* console*/ , gst, 'index_php', 'sess', sess, $('sandbox'), 'index_rd_ifra.php', function(com){eval(com);});
+ xstm.hbit_set(heartbit);
tra = new train($('room_tit'));
window.onunload = onunload_cb;
window.onbeforeunload = onbeforeunload_cb;
$("proflashext").innerHTML = "";
// console.log("session from main: "+sess);
- hstm.start();
+ xstm.start();
// alert("ARR LENGTH "+g_preload_img_arr.length);
// FIXME: preload image will be fired by stream instead here
// setTimeout(preload_images, 0, g_preload_img_arr, g_imgct);
$is_page_streaming = TRUE;
log_crit("BLOCKING_ERROR UNREC: ".($is_unrecoverable ? "TRUE" : "FALSE"));
- return (sprintf(($is_unrecoverable ? 'hstm.stop(); ' : '').'window.onbeforeunload = null; window.onunload = null; document.location.assign("index.php");'));
+ return (sprintf(($is_unrecoverable ? 'xstm.stop(); ' : '').'window.onbeforeunload = null; window.onunload = null; document.location.assign("index.php");'));
}
function page_sync($sess, $page, $table_idx, $table_token)
$is_page_streaming = TRUE;
log_rd2("PAGE_SYNC");
- return (sprintf('createCookie("table_idx", %d, 24*365, cookiepath); createCookie("table_token", "%s", 24*365, cookiepath); hstm.stop(); window.onunload = null; window.onbeforeunload = null; document.location.assign("%s");', $table_idx, $table_token, $page));
+ return (sprintf('createCookie("table_idx", %d, 24*365, cookiepath); createCookie("table_token", "%s", 24*365, cookiepath); xstm.stop(); window.onunload = null; window.onbeforeunload = null; document.location.assign("%s");', $table_idx, $table_token, $page));
}
if (($sem = Room::lock_data(FALSE)) == FALSE) {
// wait 20 secs, then restart the xhr
ignore_user_abort(FALSE);
- return ("sleep(gst,20000);|hstm.xhr_abort();");
+ return ("sleep(gst,20000);|xstm.xhr_abort();");
}
// Verifica l'expire time lato server
if (($sem = Room::lock_data(TRUE)) == FALSE) {
// wait 20 secs, then restart the xhr
ignore_user_abort(FALSE);
- return ("sleep(gst,20000);|hstm.xhr_abort();");
+ return ("sleep(gst,20000);|xstm.xhr_abort();");
}
$S_load_stat['lL_laccgarb']++;
// // wait 20 secs, then restart the xhr
// ignore_user_abort(FALSE);
-// return ("sleep(gst,20000);|hstm.xhr_abort();");
+// return ("sleep(gst,20000);|xstm.xhr_abort();");
// }
// $first_loop = FALSE;
// } // if ($first_loop == TRUE) {
while (array_pop($user_cur->comm) != NULL);
$ret = "";
- $ret .= sprintf('gst.st_loc++; gst.st=%d; createCookie("table_idx", %d, 24*365, cookiepath); createCookie("table_token", "%s", 24*365, cookiepath); createCookie("lang", "%s", 24*365, cookiepath); hstm.stop(); window.onunload = null ; window.onbeforeunload = null ; document.location.assign("briskin5/index.php");|', $user_cur->step+1, $table_idx, $table_token, $G_lang);
+ $ret .= sprintf('gst.st_loc++; gst.st=%d; createCookie("table_idx", %d, 24*365, cookiepath); createCookie("table_token", "%s", 24*365, cookiepath); createCookie("lang", "%s", 24*365, cookiepath); xstm.stop(); window.onunload = null ; window.onbeforeunload = null ; document.location.assign("briskin5/index.php");|', $user_cur->step+1, $table_idx, $table_token, $G_lang);
$user_cur->comm[$user_cur->step % COMM_N] = $ret;
$user_cur->trans_step = $user_cur->step + 1;
+++ /dev/null
-var ctx_new = "";
-var ctx_old_len = 0;
-var last_clean = 0;
-var script_clean = -1;
-
-function push(s) {
- var i;
-
- // window.parent.console.log('push('+s+');');
- for (i = last_clean ; i < script_clean ; i++) {
- if (typeof($('hs'+i)) != 'undefined' && $('hs'+i) != null) {
- document.body.removeChild($('hs'+i));
- // if (typeof(CollectGarbage) == "function") {
- // CollectGarbage();
- // }
-
- last_clean = i;
- }
- else {
- // window.parent.console.log('ifra: hs'+i+" NOT FOUND");
- }
- }
- // FIXME: remove this barbarian log
- // window.parent.console.log("ifra: ctx_new.length: "+ctx_new.length+" ctx_old_len: "+ctx_old_len);
- if (ctx_new.length == ctx_old_len && ctx_old_len > 0) {
- // FIXME: remove this barbarian log
- // window.parent.console.log("ifra: NOW clean");
- // alert("cleanna");
- ctx_new = "";
- ctx_old_len = 0;
- }
- if (s != null) {
- ctx_new = ctx_new + "@BEGIN@" + s + "@END@";
- // FIXME: remove this barbarian log
- // window.parent.console.log("ifra: CTX_NEW: ["+ctx_new+"]");
-
- }
- else {
- ctx_new = ctx_new + "_";
- }
- return;
-}
+++ /dev/null
-// old targetpage == page and moved into start method
-
-function http_streaming(win, console, gst, from, cookiename, sess, sandbox, page, cmdproc)
-{
- this.win = win;
- this.console = console;
- this.gst = gst;
- this.from = from;
- this.cookiename = cookiename;
- this.sess = sess;
- this.sandbox = sandbox;
- 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;
-}
-
-http_streaming.prototype = {
- win: null,
- console: null,
- gst: null,
- from: null,
- cookiename: null,
- sess: null,
- sandbox: null,
- page: null,
- cmdproc: null,
-
- doc: null,
- ifra: null,
- cookiepath: "/brisk/",
- watchdog_hdl: null,
- hbit: null,
- keepalive_old: -1,
- keepalive_new: -1,
- keepalives_equal: 0,
- /* NOTE: right watch_timeout value to 100, for devel reasons use 1000 or more */
- // FIXME watchdog_timeout: 200,
- /* restart after 3 * 40 * 100 millisec if server ping is missing => 12secs */
- keepalives_eq_max: 3,
- watchdog_checktm: 40,
- watchdog_timeout: 100,
- watchdog_ct: 0,
- watchable: false,
- restart_n: 0,
- comm_match: /_*@BEGIN@(.*?)@END@/g,
- comm_clean: /_*@BEGIN@(.*?)@END@/,
- stream: "",
- the_end: false,
-
- start: function() { /* public */
- if (this.the_end)
- return;
-
- createCookie(this.cookiename, sess, 24*365, this.cookiepath);
- // alert("start");
- this.log("http_streaming:start restart: "+this.restart_n);
- this.keepalives_equal = 0;
- this.ifra = this.doc.createElement("iframe");
- this.ifra.style.visibility = "hidden";
- this.doc.body.appendChild(this.ifra);
- this.page = url_complete(this.win.location.href, this.page);
- // stat, subst, this.gst.st
-
- this.page = url_append_args(this.page, "sess", this.sess, "stat", stat, "subst", subst, "step", this.gst.st, "from", this.from);
- // alert(this.page);
- this.log(this.page);
-
- // this.log(this.ifra);
- this.ifra.contentWindow.location.href = this.page;
- // this.ifra.src = this.page;
- this.watchdog_ct = 0;
- if (!this.the_end) {
- this.watchdog_hdl = setTimeout(function(obj) { obj.log("tout1"); obj.watchdog(); }, this.watchdog_timeout, this);
- }
- },
-
- stop: function() {
- this.the_end = true;
- this.abort();
- },
-
- hbit_set: function (hbit) {
- this.hbit = hbit;
- },
-
- watchdog: function () {
- // alert("watchdog");
- var i, again;
- var comm_newpart, comm_len, comm_arr;
- var ctx_new_len;
-
- if (this.sandbox != null) {
- // from old: var zug = "POLL sess = "+sess+" stat = "+stat+" subst = "+subst+" step = "+this.gst.st+" step_loc = "+this.gst.st_loc+" step_loc_new = "+this.gst.st_loc_new+" STOP: "+this.stopped;
- var zug = "WATCHDOG sess = ["+this.sess+"] step = "+this.gst.st+" step_loc = "+this.gst.st_loc+" step_loc_new = "+this.gst.st_loc_new;
- if (zug != this.sandbox.innerHTML)
- this.sandbox.innerHTML = zug;
- }
-
- // WATCHDOGING THE CONNECTION
- this.log("hs::watchdog: start, cur equal times: "+this.keepalives_equal);
- if (!this.watchable) {
- do {
- try{
- if (typeof(this.ifra.contentWindow.http_streaming) == 'undefined')
- break;
- }
- catch(b) {
- break;
- }
-
- /*
- on IE7 the the window frame scope is cleaned after the href is set, so we wait
- for a well know variable value before assign this object value to it (OO is a passion)
- */
- if (this.ifra.contentWindow.http_streaming == "ready") {
- this.ifra.contentWindow.http_streaming = this;
- this.watchable = true;
- this.watchdog_ct = 0;
- this.log("hs::watchdog: watchable = yes");
- }
- } while (false);
- }
- if ( (this.watchdog_ct % this.watchdog_checktm) == 0) {
- this.log("hs::watchdog: this.keepalive_old: "+this.keepalive_old+" this.keepalive_new: "+this.keepalive_new);
- if (this.keepalive_old == this.keepalive_new) {
- this.keepalives_equal++;
- }
- else {
- this.keepalive_old = this.keepalive_new;
- this.keepalives_equal = 0;
- }
-
- if (this.keepalives_equal > this.keepalives_eq_max) {
- this.log("hs::watchdog: MAX ACHIEVED "+this.keepalives_equal);
- this.reload();
- // alert("watchdog return reload");
- return;
- }
- }
-
- // PICK COMMANDS FROM STREAM
- do {
- // alert("do--while begin ["+again+"]");
- // CHECK: maybe again here isn't needed
- again = 0;
- try {
- if (typeof(this.ifra.contentWindow.ctx_new) == 'undefined' ||
- typeof(this.ifra.contentWindow.ctx_old_len) == 'undefined')
- break;
- }
- catch(b) {
- break;
- }
-
- ctx_new_len = this.ifra.contentWindow.ctx_new.length;
- if (ctx_new_len <= this.ifra.contentWindow.ctx_old_len) {
- break;
- }
- this.log("new: "+ ctx_new_len + " old: "+this.ifra.contentWindow.ctx_old_len);
- this.keepalive_new++;
- // alert("pre-loop 1");
- for (i = this.ifra.contentWindow.ctx_old_len ; i < ctx_new_len ; i++) {
- if (this.ifra.contentWindow.ctx_new.charAt(i) != '_') {
- // this.log("ctx_new.char(i) != '_' ["+this.ifra.contentWindow.ctx_new.charAt(i)+"]");
- break;
- }
- // else {
- // this.log("ctx_new.charAt(i) == '_'");
- // }
- }
- this.ifra.contentWindow.ctx_old_len = i;
- if (i == ctx_new_len) {
- this.log("old_len == i");
- break;
- }
- else {
- this.log("old_len != i: "+i);
- }
- // alert("do--while middle ["+this.ifra.contentWindow.ctx_old_len+"]");
-
- comm_newpart = this.ifra.contentWindow.ctx_new.substr(this.ifra.contentWindow.ctx_old_len);
- this.log("COM_NEWPART: ["+comm_newpart+"]");
- comm_len = 0;
- comm_arr = comm_newpart.match(this.comm_match);
-
- // alert("do--while middle2 ["+again+"]");
- if (comm_arr) {
- var comm_arr_len = comm_arr.length;
- for (i = 0 ; i < comm_arr_len ; i++) {
- var temp = comm_arr[i].replace(this.comm_clean,"$1").split("|");
- this.gst.comms = this.gst.comms.concat(temp);
- comm_len += comm_arr[i].length;
- }
- again = 1;
- }
- this.ifra.contentWindow.ctx_old_len += comm_len;
- this.ifra.contentWindow.script_clean = this.gst.st;
- // alert("do--while end ["+again+"]");
- } while (again);
-
- // alert("post while");
- // EXECUTION OF STREAM COMMANDS
- do {
- again = 0;
- //MOP ?? xhrrestart = 0;
- if (this.gst.st_loc < this.gst.st_loc_new) {
- // there is some slow actions running
- break;
- }
- else if (this.gst.comms.length > 0) {
- var singlecomm;
-
- singlecomm = this.gst.comms.shift();
- // alert("EXE"+gugu);
- // $("xhrdeltalog").innerHTML = "EVALL: "+singlecomm.replace("<", "<", "g"); +"<br>";
- //xx this.hbit("+");
-
- // alert("SINGLE: ["+singlecomm+"]");
- this.cmdproc(singlecomm);
- again = 1;
- }
- } while (again);
- this.watchdog_ct++;
- if (!this.the_end) {
- this.watchdog_hdl = setTimeout(function(obj) { /* obj.log("tout2"); */ obj.watchdog(); }, this.watchdog_timeout, this);
- }
- // alert("watchdog return normal");
-
- return;
- },
-
- //
- // moved to xynt-http-streaming-ifra as push()
- //
- // keepalive: function (s) {
- // this.log("hs::keepalive");
- // if (s != null) {
- // this.log(s);
- // this.ifra.contentWindow.ctx_new += "@BEGIN@"+s+"@END@";
- // }
- // else {
- // this.ifra.contentWindow.ctx_new += "_";
- // }
- // // this.keepalive_new++;
- // },
-
- abort: function () { /* public */
- // this.log("PATH: "+this.ifra.contentWindow.location.protocol + "://" + this.ifra.contentWindow.location.host + "/" + this.ifra.contentWindow.location.pathname);
-
- this.gst.abort();
- if (this.watchdog_hdl != null) {
- clearTimeout(this.watchdog_hdl);
- this.watchdog_hdl = null;
- }
-
- this.restart_n++;
- this.log("hs::reload");
- this.watchable = false;
- if (this.ifra != null) {
- this.doc.body.removeChild(this.ifra);
- delete this.ifra;
- this.ifra = null;
- }
- },
-
- reload: function () {
- this.abort();
- this.start(null);
- },
-
- log: function (s) {
- if (this.console != null) {
- return (this.console.log(s));
- }
- }
-}
--- /dev/null
+var ctx_new = "";
+var ctx_old_len = 0;
+var last_clean = 0;
+var script_clean = -1;
+
+function push(s) {
+ var i;
+
+ // window.parent.console.log('push('+s+');');
+ for (i = last_clean ; i < script_clean ; i++) {
+ if (typeof($('hs'+i)) != 'undefined' && $('hs'+i) != null) {
+ document.body.removeChild($('hs'+i));
+ // if (typeof(CollectGarbage) == "function") {
+ // CollectGarbage();
+ // }
+
+ last_clean = i;
+ }
+ else {
+ // window.parent.console.log('ifra: hs'+i+" NOT FOUND");
+ }
+ }
+ // FIXME: remove this barbarian log
+ // window.parent.console.log("ifra: ctx_new.length: "+ctx_new.length+" ctx_old_len: "+ctx_old_len);
+ if (ctx_new.length == ctx_old_len && ctx_old_len > 0) {
+ // FIXME: remove this barbarian log
+ // window.parent.console.log("ifra: NOW clean");
+ // alert("cleanna");
+ ctx_new = "";
+ ctx_old_len = 0;
+ }
+ if (s != null) {
+ ctx_new = ctx_new + "@BEGIN@" + s + "@END@";
+ // FIXME: remove this barbarian log
+ // window.parent.console.log("ifra: CTX_NEW: ["+ctx_new+"]");
+
+ }
+ else {
+ ctx_new = ctx_new + "_";
+ }
+ return;
+}
--- /dev/null
+// old targetpage == page and moved into start method
+
+function xynt_streaming(win, console, gst, from, cookiename, sess, sandbox, page, cmdproc)
+{
+ this.win = win;
+ this.console = console;
+ this.gst = gst;
+ this.from = from;
+ this.cookiename = cookiename;
+ this.sess = sess;
+ this.sandbox = sandbox;
+ 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;
+}
+
+xynt_streaming.prototype = {
+ win: null,
+ console: null,
+ gst: null,
+ from: null,
+ cookiename: null,
+ sess: null,
+ sandbox: null,
+ page: null,
+ cmdproc: null,
+
+ doc: null,
+ ifra: null,
+ cookiepath: "/brisk/",
+ watchdog_hdl: null,
+ hbit: null,
+ keepalive_old: -1,
+ keepalive_new: -1,
+ keepalives_equal: 0,
+ /* NOTE: right watch_timeout value to 100, for devel reasons use 1000 or more */
+ // FIXME watchdog_timeout: 200,
+ /* restart after 3 * 40 * 100 millisec if server ping is missing => 12secs */
+ keepalives_eq_max: 3,
+ watchdog_checktm: 40,
+ watchdog_timeout: 100,
+ watchdog_ct: 0,
+ watchable: false,
+ restart_n: 0,
+ comm_match: /_*@BEGIN@(.*?)@END@/g,
+ comm_clean: /_*@BEGIN@(.*?)@END@/,
+ stream: "",
+ the_end: false,
+
+ start: function() { /* public */
+ if (this.the_end)
+ return;
+
+ createCookie(this.cookiename, sess, 24*365, this.cookiepath);
+ // alert("start");
+ this.log("xynt_streaming:start restart: "+this.restart_n);
+ this.keepalives_equal = 0;
+ this.ifra = this.doc.createElement("iframe");
+ this.ifra.style.visibility = "hidden";
+ this.doc.body.appendChild(this.ifra);
+ this.page = url_complete(this.win.location.href, this.page);
+ // stat, subst, this.gst.st
+
+ this.page = url_append_args(this.page, "sess", this.sess, "stat", stat, "subst", subst, "step", this.gst.st, "from", this.from);
+ // alert(this.page);
+ this.log(this.page);
+
+ // this.log(this.ifra);
+ this.ifra.contentWindow.location.href = this.page;
+ // this.ifra.src = this.page;
+ this.watchdog_ct = 0;
+ if (!this.the_end) {
+ this.watchdog_hdl = setTimeout(function(obj) { obj.log("tout1"); obj.watchdog(); }, this.watchdog_timeout, this);
+ }
+ },
+
+ stop: function() {
+ this.the_end = true;
+ this.abort();
+ },
+
+ hbit_set: function (hbit) {
+ this.hbit = hbit;
+ },
+
+ watchdog: function () {
+ // alert("watchdog");
+ var i, again;
+ var comm_newpart, comm_len, comm_arr;
+ var ctx_new_len;
+
+ if (this.sandbox != null) {
+ // from old: var zug = "POLL sess = "+sess+" stat = "+stat+" subst = "+subst+" step = "+this.gst.st+" step_loc = "+this.gst.st_loc+" step_loc_new = "+this.gst.st_loc_new+" STOP: "+this.stopped;
+ var zug = "WATCHDOG sess = ["+this.sess+"] step = "+this.gst.st+" step_loc = "+this.gst.st_loc+" step_loc_new = "+this.gst.st_loc_new;
+ if (zug != this.sandbox.innerHTML)
+ this.sandbox.innerHTML = zug;
+ }
+
+ // WATCHDOGING THE CONNECTION
+ this.log("hs::watchdog: start, cur equal times: "+this.keepalives_equal);
+ if (!this.watchable) {
+ do {
+ try{
+ if (typeof(this.ifra.contentWindow.xynt_streaming) == 'undefined')
+ break;
+ }
+ catch(b) {
+ break;
+ }
+
+ /*
+ on IE7 the the window frame scope is cleaned after the href is set, so we wait
+ for a well know variable value before assign this object value to it (OO is a passion)
+ */
+ if (this.ifra.contentWindow.xynt_streaming == "ready") {
+ this.ifra.contentWindow.xynt_streaming = this;
+ this.watchable = true;
+ this.watchdog_ct = 0;
+ this.log("hs::watchdog: watchable = yes");
+ }
+ } while (false);
+ }
+ if ( (this.watchdog_ct % this.watchdog_checktm) == 0) {
+ this.log("hs::watchdog: this.keepalive_old: "+this.keepalive_old+" this.keepalive_new: "+this.keepalive_new);
+ if (this.keepalive_old == this.keepalive_new) {
+ this.keepalives_equal++;
+ }
+ else {
+ this.keepalive_old = this.keepalive_new;
+ this.keepalives_equal = 0;
+ }
+
+ if (this.keepalives_equal > this.keepalives_eq_max) {
+ this.log("hs::watchdog: MAX ACHIEVED "+this.keepalives_equal);
+ this.reload();
+ // alert("watchdog return reload");
+ return;
+ }
+ }
+
+ // PICK COMMANDS FROM STREAM
+ do {
+ // alert("do--while begin ["+again+"]");
+ // CHECK: maybe again here isn't needed
+ again = 0;
+ try {
+ if (typeof(this.ifra.contentWindow.ctx_new) == 'undefined' ||
+ typeof(this.ifra.contentWindow.ctx_old_len) == 'undefined')
+ break;
+ }
+ catch(b) {
+ break;
+ }
+
+ ctx_new_len = this.ifra.contentWindow.ctx_new.length;
+ if (ctx_new_len <= this.ifra.contentWindow.ctx_old_len) {
+ break;
+ }
+ this.log("new: "+ ctx_new_len + " old: "+this.ifra.contentWindow.ctx_old_len);
+ this.keepalive_new++;
+ // alert("pre-loop 1");
+ for (i = this.ifra.contentWindow.ctx_old_len ; i < ctx_new_len ; i++) {
+ if (this.ifra.contentWindow.ctx_new.charAt(i) != '_') {
+ // this.log("ctx_new.char(i) != '_' ["+this.ifra.contentWindow.ctx_new.charAt(i)+"]");
+ break;
+ }
+ // else {
+ // this.log("ctx_new.charAt(i) == '_'");
+ // }
+ }
+ this.ifra.contentWindow.ctx_old_len = i;
+ if (i == ctx_new_len) {
+ this.log("old_len == i");
+ break;
+ }
+ else {
+ this.log("old_len != i: "+i);
+ }
+ // alert("do--while middle ["+this.ifra.contentWindow.ctx_old_len+"]");
+
+ comm_newpart = this.ifra.contentWindow.ctx_new.substr(this.ifra.contentWindow.ctx_old_len);
+ this.log("COM_NEWPART: ["+comm_newpart+"]");
+ comm_len = 0;
+ comm_arr = comm_newpart.match(this.comm_match);
+
+ // alert("do--while middle2 ["+again+"]");
+ if (comm_arr) {
+ var comm_arr_len = comm_arr.length;
+ for (i = 0 ; i < comm_arr_len ; i++) {
+ var temp = comm_arr[i].replace(this.comm_clean,"$1").split("|");
+ this.gst.comms = this.gst.comms.concat(temp);
+ comm_len += comm_arr[i].length;
+ }
+ again = 1;
+ }
+ this.ifra.contentWindow.ctx_old_len += comm_len;
+ this.ifra.contentWindow.script_clean = this.gst.st;
+ // alert("do--while end ["+again+"]");
+ } while (again);
+
+ // alert("post while");
+ // EXECUTION OF STREAM COMMANDS
+ do {
+ again = 0;
+ //MOP ?? xhrrestart = 0;
+ if (this.gst.st_loc < this.gst.st_loc_new) {
+ // there is some slow actions running
+ break;
+ }
+ else if (this.gst.comms.length > 0) {
+ var singlecomm;
+
+ singlecomm = this.gst.comms.shift();
+ // alert("EXE"+gugu);
+ // $("xhrdeltalog").innerHTML = "EVALL: "+singlecomm.replace("<", "<", "g"); +"<br>";
+ //xx this.hbit("+");
+
+ // alert("SINGLE: ["+singlecomm+"]");
+ this.cmdproc(singlecomm);
+ again = 1;
+ }
+ } while (again);
+ this.watchdog_ct++;
+ if (!this.the_end) {
+ this.watchdog_hdl = setTimeout(function(obj) { /* obj.log("tout2"); */ obj.watchdog(); }, this.watchdog_timeout, this);
+ }
+ // alert("watchdog return normal");
+
+ return;
+ },
+
+ //
+ // moved to xynt-streaming-ifra as push()
+ //
+ // keepalive: function (s) {
+ // this.log("hs::keepalive");
+ // if (s != null) {
+ // this.log(s);
+ // this.ifra.contentWindow.ctx_new += "@BEGIN@"+s+"@END@";
+ // }
+ // else {
+ // this.ifra.contentWindow.ctx_new += "_";
+ // }
+ // // this.keepalive_new++;
+ // },
+
+ abort: function () { /* public */
+ // this.log("PATH: "+this.ifra.contentWindow.location.protocol + "://" + this.ifra.contentWindow.location.host + "/" + this.ifra.contentWindow.location.pathname);
+
+ this.gst.abort();
+ if (this.watchdog_hdl != null) {
+ clearTimeout(this.watchdog_hdl);
+ this.watchdog_hdl = null;
+ }
+
+ this.restart_n++;
+ this.log("hs::reload");
+ this.watchable = false;
+ if (this.ifra != null) {
+ this.doc.body.removeChild(this.ifra);
+ delete this.ifra;
+ this.ifra = null;
+ }
+ },
+
+ reload: function () {
+ this.abort();
+ this.start(null);
+ },
+
+ log: function (s) {
+ if (this.console != null) {
+ return (this.console.log(s));
+ }
+ }
+}