1 function http_streaming(win, cons)
4 this.doc = win.document;
5 this.keepalive_old = -1;
6 this.keepalive_new = -1;
7 this.keepalives_equal = 0;
8 this.ifra = this.doc.createElement("iframe");
9 this.ifra.style.visibility = "hidden";
10 this.doc.body.appendChild(this.ifra);
13 http_streaming.prototype = {
23 watchdog_timeout: 2000,
27 start: function(page) {
28 this.log("http_streaming:start restart: "+this.restart_n);
30 this.ifra.contentWindow.location.href = page;
31 this.wd_handle = setTimeout(function(obj) { obj.log("tout1"); obj.watchdog(); }, this.watchdog_timeout, this);
34 watchdog: function () {
35 /* +this.keepalives_equal */
36 this.log("hs::watchdog: start, cur equal times: "+this.keepalives_equal);
37 if (!this.watchable) {
39 if (typeof(this.ifra.contentWindow.http_streaming) == 'undefined')
42 on IE7 the the window frame scope is cleaned after the href is set, so we wait
43 for a well know variable value before assign this object value to it (OO is a passion)
45 if (this.ifra.contentWindow.http_streaming == "ready") {
46 this.ifra.contentWindow.http_streaming = this;
47 this.watchable = true;
51 this.log("hs::watchdog: this.keepalive_old: "+this.keepalive_old+" this.keepalive_new: "+this.keepalive_new);
52 if (this.keepalive_old == this.keepalive_new) {
53 this.keepalives_equal++;
56 this.keepalive_old = this.keepalive_new;
57 this.keepalives_equal = 0;
60 if (this.keepalives_equal > this.keepalives_eq_max) {
61 this.log("hs::watchdog: MAX ACHIEVED "+this.keepalives_equal);
66 this.wd_handle = setTimeout(function(obj) { obj.log("tout2"); obj.watchdog(); }, this.watchdog_timeout, this);
70 keepalive: function () {
71 this.log("hs::keepalive");
76 clearTimeout(this.wd_handle);
78 this.log("hs::reload");
79 this.watchable = false;
85 this.keepalives_equal = 0;
86 this.ifra = this.doc.createElement("iframe");
87 this.ifra.style.visibility = "hidden";
88 this.doc.body.appendChild(this.ifra);
89 this.start(this.page);
93 if (this.console != null) {
94 return (this.console.log(s));