first http-streaming with iframe working on ff and ie
[xynt.git] / web / xynt / xynt-http-streaming.js
1 function http_streaming(doc)
2 {
3     this.doc = doc;
4     this.keepalive_old = -1;
5     this.keepalive_new = -1;
6     this.keepalives_equal = 0;
7     this.ifra = doc.createElement("iframe");
8     this.ifra.style.visibility = "hidden";
9     doc.body.appendChild(this.ifra);
10     // this.ifra.contentWindow.onload = function () {
11     //     this.ifra.contentWindow.location.href = 'winstream_rdxxx.php';     
12     // }
13     
14 }
15
16 http_streaming.prototype = {
17     doc:               null,
18     ifra:              null,
19     keepalive_old:    -1,
20     keepalive_new:    -1,
21     keepalives_equal:  0,
22     keepalives_eq_max: 6,
23
24     start: function(page) {
25         this.ifra.contentWindow.location.href = page;
26     },
27
28     watchdog: function () {
29         /* +this.keepalives_equal */
30         console.log("watchdog ");
31         if (this.keepalive_old == this.keepalive_new) {
32             this.keepalives_equal++;
33         }
34         else {
35             this.keepalives_equal = 0;
36         }
37         
38         if (this.keepalives_equal > this.keepalives_eq_max) {
39             console.log("MAX ACHIEVED "+this.keepalives_equal);
40         }
41         else {
42             setTimeout(function(obj) { obj.watchdog() }, 2000, this);
43         }
44     },
45     
46     keepalive: function () {
47         this.keepalive_new++;
48     }
49     
50 }