5 this.comms = new Array;
15 sleep: function(delay) {
18 this.sleep_hdl = setTimeout(function(obj){ if (obj.st_loc_new > obj.st_loc) { obj.st_loc++; obj.sleep_hdl = null; }},
23 if (this.sleep_hdl != null) {
24 clearTimeout(this.sleep_hdl);
25 this.sleep_hdl = null;
30 function http_streaming(win, gst, sess, cons)
35 this.doc = win.document;
36 this.keepalive_old = -1;
37 this.keepalive_new = -1;
39 this.cmdproc = function(com){eval(com);}
42 http_streaming.prototype = {
54 watchdog_timeout: 100,
61 comm_match: /_*@BEGIN@(.*?)@END@/g,
62 comm_clean: /_*@BEGIN@(.*?)@END@/,
69 start: function(page) {
70 this.log("http_streaming:start restart: "+this.restart_n);
71 this.keepalives_equal = 0;
72 this.ifra = this.doc.createElement("iframe");
73 this.ifra.style.visibility = "hidden";
74 this.doc.body.appendChild(this.ifra);
77 this.page = url_append_args(this.page, "sess", this.sess, "st", this.gst.st);
80 // this.log(this.ifra);
81 this.ifra.contentWindow.location.href = this.page;
83 this.watchdog_hdl = setTimeout(function(obj) { obj.log("tout1"); obj.watchdog(); }, this.watchdog_timeout, this);
86 watchdog: function () {
88 var comm_newpart, comm_len, comm_arr;
90 // WATCHDOGING THE CONNECTION
91 if ( (this.watchdog_ct % this.watchdog_checktm) == 0 || !this.watchable) {
92 this.log("hs::watchdog: start, cur equal times: "+this.keepalives_equal);
93 if (!this.watchable) {
95 if (typeof(this.ifra.contentWindow.http_streaming) == 'undefined')
98 on IE7 the the window frame scope is cleaned after the href is set, so we wait
99 for a well know variable value before assign this object value to it (OO is a passion)
101 if (this.ifra.contentWindow.http_streaming == "ready") {
102 this.ifra.contentWindow.http_streaming = this;
103 this.watchable = true;
104 this.log("hs::watchdog: watchable = yes");
108 this.log("hs::watchdog: this.keepalive_old: "+this.keepalive_old+" this.keepalive_new: "+this.keepalive_new);
109 if (this.keepalive_old == this.keepalive_new) {
110 this.keepalives_equal++;
113 this.keepalive_old = this.keepalive_new;
114 this.keepalives_equal = 0;
117 if (this.keepalives_equal > this.keepalives_eq_max) {
118 this.log("hs::watchdog: MAX ACHIEVED "+this.keepalives_equal);
124 // PICK COMMANDS FROM STREAM
126 // CHECK: maybe again here isn't needed
128 if (typeof(this.ifra.contentWindow.ctx_new) == 'undefined')
130 if (this.ifra.contentWindow.ctx_new.length == this.ctx_old_len) {
131 // this.ctx_new = this.ctx_old = "";
132 // FIXME find a more robust clean method
135 this.log("new: "+ this.ifra.contentWindow.ctx_new.length + " old: "+this.ctx_old_len);
136 this.keepalive_new++;
137 for (i = this.ctx_old_len ; i < this.ifra.contentWindow.ctx_new.length ; i++) {
138 if (this.ifra.contentWindow.ctx_new[i] != '_')
141 if (i == this.ifra.contentWindow.ctx_new.length) {
142 this.ctx_old_len = i;
145 comm_newpart = this.ifra.contentWindow.ctx_new.substr(this.ctx_old_len);
147 comm_arr = comm_newpart.match(this.comm_match);
150 for (i = 0 ; i < comm_arr.length ; i++) {
151 var temp = comm_arr[i].replace(this.comm_clean,"$1").split("|");
153 this.gst.comms = this.gst.comms.concat(temp);
154 // XX alert("COMM_ARR["+i+"]: "+comm_arr[i]+" LEN:"+comm_arr[i].length);
155 comm_len += comm_arr[i].length;
157 this.ctx_old += comm_newpart.substr(0,comm_len);
160 this.ctx_old_len = this.ctx_old.length;
165 // EXECUTION OF STREAM COMMANDS
168 //MOP ?? xhrrestart = 0;
169 if (this.gst.st_loc < this.gst.st_loc_new) {
170 // there is some slow actions running
173 else if (this.gst.comms.length > 0) {
176 singlecomm = this.gst.comms.shift();
177 // alert("EXE"+gugu);
178 // $("xhrdeltalog").innerHTML = "EVALL: "+singlecomm.replace("<", "<", "g"); +"<br>";
181 this.cmdproc(singlecomm);
188 this.watchdog_hdl = setTimeout(function(obj) { /* obj.log("tout2"); */ obj.watchdog(); }, this.watchdog_timeout, this);
192 keepalive: function (s) {
193 this.log("hs::keepalive");
196 this.ifra.contentWindow.ctx_new += "@BEGIN@"+s+"@END@";
199 this.ifra.contentWindow.ctx_new += "_";
201 // this.keepalive_new++;
205 // this.log("PATH: "+this.ifra.contentWindow.location.protocol + "://" + this.ifra.contentWindow.location.host + "/" + this.ifra.contentWindow.location.pathname);
208 if (this.watchdog_hdl != null) {
209 clearTimeout(this.watchdog_hdl);
210 this.watchdog_hdl = null;
214 this.log("hs::reload");
215 this.watchable = false;
216 if (this.ifra != null) {
217 this.doc.body.removeChild(this.ifra);
222 this.ctx_old_len = 0;
225 reload: function () {
231 if (this.console != null) {
232 return (this.console.log(s));