save/restore issue added
[brisk.git] / web / xynt-http-streaming.js
index 6b07966..fe325be 100644 (file)
@@ -37,11 +37,13 @@ http_streaming.prototype = {
     keepalive_old:    -1,
     keepalive_new:    -1,
     keepalives_equal:  0,
-    keepalives_eq_max: 6,
     /* NOTE: right watch_timeout value to 100, for devel reasons use 1000 or more */
+    // FIXME watchdog_timeout:  200,
+    /* restart after  3 * 40 * 100 millisec if server ping is missing => 12secs */
+    keepalives_eq_max: 3,
+    watchdog_checktm:  40,
     watchdog_timeout:  100,
     watchdog_ct:       0,
-    watchdog_checktm:  20,
     watchable:         false,
     restart_n:         0,
     comm_match:        /_*@BEGIN@(.*?)@END@/g, 
@@ -69,9 +71,10 @@ http_streaming.prototype = {
 
         // this.log(this.ifra);
         this.ifra.contentWindow.location.href = this.page;
+        // this.ifra.src = this.page;
         this.watchdog_ct  = 0;
         if (!this.the_end) {
-            this.watchdog_hdl = setTimeout(function(obj) { obj.log("tout1"); obj.watchdog(); }, 0, this);
+            this.watchdog_hdl = setTimeout(function(obj) { obj.log("tout1"); obj.watchdog(); }, this.watchdog_timeout, this);
         }
     },
 
@@ -92,35 +95,36 @@ http_streaming.prototype = {
 
         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 step = "+this.gst.st+" step_loc = "+this.gst.st_loc+" step_loc_new = "+this.gst.st_loc_new;          
+            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 (zug != this.sandbox.innerHTML)
                this.sandbox.innerHTML = zug;
         }
 
         // WATCHDOGING THE CONNECTION
         this.log("hs::watchdog: start, cur equal times: "+this.keepalives_equal);
-        if ( (this.watchdog_ct % this.watchdog_checktm) == 0 || !this.watchable) {
-            if (!this.watchable) {
-                do {
-                    try{
-                        if (typeof(this.ifra.contentWindow.http_streaming) == 'undefined')
-                            break;
-                    }
-                    catch(b) {
-                       break;
-                    }
+        if (!this.watchable) {
+            do {
+                try{
+                    if (typeof(this.ifra.contentWindow.http_streaming) == 'undefined')
+                        break;
+                }
+                catch(b) {
+                   break;
+                }
 
-                    /*
-                      on IE7 the the window frame scope is cleaned after the href is set, so we wait 
-                      for a well know variable value before assign this object value to it (OO is a passion)
-                    */
-                    if (this.ifra.contentWindow.http_streaming == "ready") {
-                        this.ifra.contentWindow.http_streaming = this;
-                        this.watchable = true;
-                        this.log("hs::watchdog: watchable = yes");
-                    }
-                } while (false);
-            }
+                /*
+                  on IE7 the the window frame scope is cleaned after the href is set, so we wait 
+                  for a well know variable value before assign this object value to it (OO is a passion)
+                */
+                if (this.ifra.contentWindow.http_streaming == "ready") {
+                    this.ifra.contentWindow.http_streaming = this;
+                    this.watchable = true;
+                    this.watchdog_ct = 0;
+                    this.log("hs::watchdog: watchable = yes");
+                }
+            } while (false);
+        }
+        if ( (this.watchdog_ct % this.watchdog_checktm) == 0) {
             this.log("hs::watchdog: this.keepalive_old: "+this.keepalive_old+" this.keepalive_new: "+this.keepalive_new);
             if (this.keepalive_old == this.keepalive_new) {
                 this.keepalives_equal++;
@@ -273,4 +277,4 @@ http_streaming.prototype = {
             return (this.console.log(s));
         }
     }
-}
\ No newline at end of file
+}