first http-streaming with iframe working on ff and ie
[xynt.git] / web / xynt / xynt-http-streaming.js
diff --git a/web/xynt/xynt-http-streaming.js b/web/xynt/xynt-http-streaming.js
new file mode 100644 (file)
index 0000000..cd31ead
--- /dev/null
@@ -0,0 +1,50 @@
+function http_streaming(doc)
+{
+    this.doc = doc;
+    this.keepalive_old = -1;
+    this.keepalive_new = -1;
+    this.keepalives_equal = 0;
+    this.ifra = doc.createElement("iframe");
+    this.ifra.style.visibility = "hidden";
+    doc.body.appendChild(this.ifra);
+    // this.ifra.contentWindow.onload = function () {
+    //     this.ifra.contentWindow.location.href = 'winstream_rdxxx.php';     
+    // }
+    
+}
+
+http_streaming.prototype = {
+    doc:               null,
+    ifra:              null,
+    keepalive_old:    -1,
+    keepalive_new:    -1,
+    keepalives_equal:  0,
+    keepalives_eq_max: 6,
+
+    start: function(page) {
+        this.ifra.contentWindow.location.href = page;
+    },
+
+    watchdog: function () {
+        /* +this.keepalives_equal */
+        console.log("watchdog ");
+        if (this.keepalive_old == this.keepalive_new) {
+            this.keepalives_equal++;
+        }
+        else {
+            this.keepalives_equal = 0;
+        }
+        
+        if (this.keepalives_equal > this.keepalives_eq_max) {
+            console.log("MAX ACHIEVED "+this.keepalives_equal);
+        }
+        else {
+            setTimeout(function(obj) { obj.watchdog() }, 2000, this);
+        }
+    },
+    
+    keepalive: function () {
+        this.keepalive_new++;
+    }
+    
+}
\ No newline at end of file