From d19a7117e6b2e345f5b7932afe1e68ade3ee1cb9 Mon Sep 17 00:00:00 2001 From: "Matteo Nastasi (mop)" Date: Mon, 2 Apr 2012 17:56:59 +0200 Subject: [PATCH] console argument passed to http_streaming constructor --- web/test-hs.php | 4 ++-- web/xynt/xynt-http-streaming.js | 20 +++++++++++++++----- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/web/test-hs.php b/web/test-hs.php index 5f48ac3..257d895 100644 --- a/web/test-hs.php +++ b/web/test-hs.php @@ -8,8 +8,8 @@ var allmythings="BEGIN"; window.onload = function () { var hs; - - hs = new http_streaming(document); + console.log("zugu"); + hs = new http_streaming(document, console); hs.start('test-hs-rd.php'); } diff --git a/web/xynt/xynt-http-streaming.js b/web/xynt/xynt-http-streaming.js index cd31ead..cb914e0 100644 --- a/web/xynt/xynt-http-streaming.js +++ b/web/xynt/xynt-http-streaming.js @@ -1,5 +1,6 @@ -function http_streaming(doc) +function http_streaming(doc, cons) { + this.console = cons; this.doc = doc; this.keepalive_old = -1; this.keepalive_new = -1; @@ -14,20 +15,24 @@ function http_streaming(doc) } http_streaming.prototype = { + console: null, doc: null, ifra: null, keepalive_old: -1, keepalive_new: -1, keepalives_equal: 0, keepalives_eq_max: 6, + watchdog_timeout: 2000, start: function(page) { + this.log("http_streaming:start"); this.ifra.contentWindow.location.href = page; + setTimeout(function(obj) { obj.watchdog(); }, this.watchdog_timeout, this); }, watchdog: function () { /* +this.keepalives_equal */ - console.log("watchdog "); + this.log("hs::watchdog: start"); if (this.keepalive_old == this.keepalive_new) { this.keepalives_equal++; } @@ -36,15 +41,20 @@ http_streaming.prototype = { } if (this.keepalives_equal > this.keepalives_eq_max) { - console.log("MAX ACHIEVED "+this.keepalives_equal); + this.log("hs::watchdog: MAX ACHIEVED "+this.keepalives_equal); } else { - setTimeout(function(obj) { obj.watchdog() }, 2000, this); + setTimeout(function(obj) { obj.watchdog() }, this.watchdog_timeout, this); } }, keepalive: function () { this.keepalive_new++; + }, + + log: function (s) { + if (this.console != null) { + return (this.console.log(s)); + } } - } \ No newline at end of file -- 2.17.1