},
ctx_new_getchar: function(idx) { /* public */
- return (this.ifra.contentWindow.ctx_new.charAt(idx));
-
+ return (this.ifra.contentWindow.ctx_new.charAt(idx));
},
ctx_old_len_is_set: function () { /* public */
},
ctx_new_getchar: function(idx) { /* public */
- return (this.ifra.contentWindow.ctx_new.charAt(idx));
+ return (this.ifra.contentWindow.ctx_new.charAt(idx));
},
ctx_old_len_is_set: function () { /* public */
this.doc = win.document;
this.keepalive_old = -1;
this.keepalive_new = -1;
+
+ this.mon_errtime = this.keepalives_eq_max * this.watchdog_checktm * this.watchdog_timeout;
+ this.mon_wrntime = this.mon_errtime / 2;
+
+ this.mon_update();
+
}
xynt_streaming.prototype = {
stream: "",
the_end: false,
- w_stat_old: "",
- s_stat_old: "",
+ mon_time: -1,
+ mon_wrntime: 0,
+ mon_errtime: 0,
+
+ mon_stat_old: "",
+
+ mon_update: function()
+ {
+ var date = new Date();
+
+ this.mon_time = date.getTime();
+ },
+
+ /*
+ ping arrives at least every RD_KEEPALIVE_TOUT secs (currently 4 secs)
+
+ return values: 0 unknown
+ 1 ok
+ 2 warning
+ 3 error
+ */
+ mon_status: function()
+ {
+ var delta, date;
+
+ var date = new Date();
+
+ delta = date.getTime() - this.mon_time;
+
+ if (delta < this.mon_wrntime)
+ return 1;
+ else if (delta < this.mon_errtime)
+ return 2;
+ else
+ return 3;
+ },
start: function() { /* public */
if (this.the_end)
this.hbit = hbit;
},
+
hbit_status: function () {
- if (this.watchdog_hdl)
- w_stat = "g";
- else
- w_stat = "r";
+ var ret;
- if (this.transp.ctx_new_is_set() &&
- this.transp.ctx_new_curlen_get() > 0) {
- if (this.keepalives_equal == 0) {
- s_stat = "g";
- }
- else if (this.keepalives_equal < this.keepalives_eq_max) {
- s_stat = "y";
- }
- else {
- s_stat = "r";
- }
- }
- else {
- s_stat = "r";
+ ret = this.mon_status();
+ // console.log("mon_status: "+ret+" 0: "+this.mon_time);
+ switch (ret) {
+ case 0:
+ mon_stat = "b";
+ break;
+ case 1:
+ mon_stat = "g";
+ break;
+ case 2:
+ mon_stat = "y";
+ break;
+ case 3:
+ mon_stat = "r";
+ break;
}
- if (this.s_stat_old != s_stat ||
- this.w_stat_old != w_stat)
- this.hbit(s_stat, w_stat);
- this.s_stat_old = s_stat;
- this.w_stat_old = w_stat;
+ if (this.mon_stat_old != mon_stat) {
+ this.hbit(mon_stat);
+ this.mon_stat_old = mon_stat;
+ }
},
+
watchdog: function () {
// alert("watchdog");
var i, again;
var comm_newpart, comm_len, comm_arr;
var ctx_new_len;
- this.watchdog_hdl = null;
-
- this.hbit_status();
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 ( (this.watchdog_ct % this.watchdog_checktm) == 0) {
this.log("hs::watchdog: this.keepalive_old: "+this.keepalive_old+" this.keepalive_new: "+this.keepalive_new);
-
- // alert("qui "+this.transp.ctx_new_curlen_get()+" "+this.transp.ctx_old_len_get();
if (this.keepalive_old == this.keepalive_new) {
this.keepalives_equal++;
}
this.log("hs::watchdog: MAX ACHIEVED "+this.keepalives_equal);
this.reload();
// alert("watchdog return reload");
+ this.hbit_status();
return;
}
}
catch(b) {
break;
}
+
// ctx_new_len = this.ifra.contentWindow.ctx_new.length;
ctx_new_len = this.transp.ctx_new_curlen_get();
- this.log("new_len: "+ ctx_new_len);
// if (ctx_new_len <= this.ifra.contentWindow.ctx_old_len) {
if (ctx_new_len <= this.transp.ctx_old_len_get()) {
break;
this.keepalive_new++;
// alert("pre-loop 1");
for (i = this.transp.ctx_old_len_get() ; i < ctx_new_len ; i++) {
- // alert("ctx_new_getchar: "+this.transp.ctx_new_getchar(i));
-
+ // if (this.ifra.contentWindow.ctx_new.charAt(i) != '_') {
if (this.transp.ctx_new_getchar(i) != '_') {
// this.log("ctx_new.char(i) != '_' ["+this.ifra.contentWindow.ctx_new.charAt(i)+"]");
break;
}
+ this.mon_update();
+ this.hbit_status();
+
// else {
// this.log("ctx_new.charAt(i) == '_'");
// }
comm_len += comm_arr[i].length;
}
again = 1;
+ this.mon_update();
+ this.hbit_status();
}
// this.ifra.contentWindow.ctx_old_len += comm_len;
this.transp.ctx_old_len_add(comm_len);