|
From: <ma...@us...> - 2010-11-28 17:44:24
|
Revision: 172
http://openautomation.svn.sourceforge.net/openautomation/?rev=172&view=rev
Author: mayerch
Date: 2010-11-28 17:44:18 +0000 (Sun, 28 Nov 2010)
Log Message:
-----------
Sanity check to avoid the
this.xhr.abort is not a function
error
Modified Paths:
--------------
CometVisu/trunk/visu/lib/cometvisu-client.js
Modified: CometVisu/trunk/visu/lib/cometvisu-client.js
===================================================================
--- CometVisu/trunk/visu/lib/cometvisu-client.js 2010-11-28 17:26:04 UTC (rev 171)
+++ CometVisu/trunk/visu/lib/cometvisu-client.js 2010-11-28 17:44:18 UTC (rev 172)
@@ -137,7 +137,7 @@
this.stop = function()
{
this.running = false;
- this.xhr.abort();
+ if( this.xhr.abort ) this.xhr.abort();
//alert('this.stop');
};
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ma...@us...> - 2011-03-06 12:09:32
|
Revision: 314
http://openautomation.svn.sourceforge.net/openautomation/?rev=314&view=rev
Author: mayerch
Date: 2011-03-06 12:09:26 +0000 (Sun, 06 Mar 2011)
Log Message:
-----------
New Feature: added a watchdog that makes sure that the connection stays fresh
This handles e.g. a browser on a system that goes to sleep and wakes up later. Or bad networks.
Modified Paths:
--------------
CometVisu/trunk/visu/lib/cometvisu-client.js
Modified: CometVisu/trunk/visu/lib/cometvisu-client.js
===================================================================
--- CometVisu/trunk/visu/lib/cometvisu-client.js 2011-03-05 14:44:58 UTC (rev 313)
+++ CometVisu/trunk/visu/lib/cometvisu-client.js 2011-03-06 12:09:26 UTC (rev 314)
@@ -20,6 +20,7 @@
*/
function CometVisu( urlPrefix )
{
+ var thisCometVisu = this;
this.urlPrefix = (null == urlPrefix) ? '' : urlPrefix; // the address of the service
this.addresses = []; // the subscribed addresses
this.filters = []; // the subscribed filters
@@ -28,6 +29,8 @@
this.device = ''; // the current device ID
this.running = false; // is the communication running at the moment?
this.xhr = false; // the ongoing AJAX request
+ this.watchdogTimer = 5; // in Seconds - the alive check intervall of the watchdog
+ this.maxConnectionAge = 60; // in Seconds - restart if last read is older
/**
* This function gets called once the communication is established and session information is available
@@ -55,6 +58,7 @@
if( this.running )
{ // retry initial request
this.xhr = $.ajax( {url:this.urlPrefix + 'r',dataType: 'json',context:this,data:this.buildRequest()+'&t=0', success:this.handleRead ,error:this.handleError/*,complete:this.handleComplete*/ } );
+ watchdog.ping();
}
return;
}
@@ -66,6 +70,7 @@
if( this.running )
{ // keep the requests going
this.xhr = $.ajax( {url:this.urlPrefix + 'r',dataType: 'json',context:this,data:this.buildRequest()+'&i='+lastIndex, success:this.handleRead ,error:this.handleError/*,complete:this.handleComplete*/ } );
+ watchdog.ping();
}
};
@@ -149,6 +154,34 @@
var request = 'a=' + address + '&v=' + value;
$.ajax( {url:this.urlPrefix + 'w',dataType: 'json',context:this,data:request} );
}
+
+ /**
+ * Restart the read request, e.g. when the watchdog kicks in
+ */
+ this.restart = function()
+ {
+ if( this.xhr.abort ) this.xhr.abort();
+ this.handleRead(); // restart
+ }
+
+ /**
+ * The watchdog to recreate a read request when it stopped somehow
+ */
+ var watchdog = (function(){
+ var last = new Date();
+ var aliveCheckFunction = function(){
+ var now = new Date();
+ if( now - last < thisCometVisu.maxConnectionAge * 1000 ) return;
+ thisCometVisu.restart();
+ last = now;
+ };
+ var aliveHandler = setInterval( aliveCheckFunction, thisCometVisu.watchdogTimer * 1000 );
+ return {
+ ping: function(){
+ last = new Date();
+ }
+ };
+ })();
};
CometVisu.prototype.update = function( json ) {}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ma...@us...> - 2011-12-12 17:23:21
|
Revision: 569
http://openautomation.svn.sourceforge.net/openautomation/?rev=569&view=rev
Author: mayerch
Date: 2011-12-12 17:23:11 +0000 (Mon, 12 Dec 2011)
Log Message:
-----------
Fix error message that is caused by the fact that the AJAX connection will be on unload canceled before(!) the .unload() event will be triggered!?!
I'm using the check suggested at http://stackoverflow.com/questions/1370322/jquery-ajax-fires-error-callback-on-window-unload
Modified Paths:
--------------
CometVisu/trunk/visu/lib/cometvisu-client.js
Modified: CometVisu/trunk/visu/lib/cometvisu-client.js
===================================================================
--- CometVisu/trunk/visu/lib/cometvisu-client.js 2011-12-12 14:05:51 UTC (rev 568)
+++ CometVisu/trunk/visu/lib/cometvisu-client.js 2011-12-12 17:23:11 UTC (rev 569)
@@ -81,7 +81,7 @@
*/
this.handleError=function(xhr,str,excptObj)
{
- if( this.running && xhr.readyState != 4 && !this.doRestart) // ignore error when connection is irrelevant
+ if( this.running && xhr.readyState != 4 && !this.doRestart && xhr.status!==0 ) // ignore error when connection is irrelevant
{
var readyState = 'UNKNOWN';
switch( xhr.readyState )
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ma...@us...> - 2012-01-02 22:00:37
|
Revision: 626
http://openautomation.svn.sourceforge.net/openautomation/?rev=626&view=rev
Author: mayerch
Date: 2012-01-02 22:00:31 +0000 (Mon, 02 Jan 2012)
Log Message:
-----------
Bug fix for #3468526: Initial read is repeated after COMET Timeout
Modified Paths:
--------------
CometVisu/trunk/visu/lib/cometvisu-client.js
Modified: CometVisu/trunk/visu/lib/cometvisu-client.js
===================================================================
--- CometVisu/trunk/visu/lib/cometvisu-client.js 2012-01-02 12:08:29 UTC (rev 625)
+++ CometVisu/trunk/visu/lib/cometvisu-client.js 2012-01-02 22:00:31 UTC (rev 626)
@@ -32,6 +32,7 @@
this.xhr = false; // the ongoing AJAX request
this.watchdogTimer = 5; // in Seconds - the alive check intervall of the watchdog
this.maxConnectionAge = 60; // in Seconds - restart if last read is older
+ this.lastIndex = 0; // index returned by the last request
/**
* This function gets called once the communication is established and session information is available
@@ -54,7 +55,7 @@
*/
this.handleRead = function( json )
{
- if( !json )
+ if( !json && !this.doRestart )
{
if( this.running )
{ // retry initial request
@@ -64,13 +65,16 @@
return;
}
- var lastIndex = json.i;
- var data = json.d;
- this.update( data );
+ if( !this.doRestart )
+ {
+ this.lastIndex = json.i;
+ var data = json.d;
+ this.update( data );
+ }
if( this.running )
{ // keep the requests going
- this.xhr = $.ajax( {url:this.urlPrefix + 'r',dataType: 'json',context:this,data:this.buildRequest()+'&i='+lastIndex, success:this.handleRead ,error:this.handleError/*,complete:this.handleComplete*/ } );
+ this.xhr = $.ajax( {url:this.urlPrefix + 'r',dataType: 'json',context:this,data:this.buildRequest()+'&i='+this.lastIndex, success:this.handleRead ,error:this.handleError/*,complete:this.handleComplete*/ } );
watchdog.ping();
}
};
@@ -168,8 +172,8 @@
{
this.doRestart = true;
if( this.xhr.abort ) this.xhr.abort();
+ this.handleRead(); // restart
this.doRestart = false;
- this.handleRead(); // restart
}
/**
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ma...@us...> - 2012-01-03 18:03:30
|
Revision: 631
http://openautomation.svn.sourceforge.net/openautomation/?rev=631&view=rev
Author: mayerch
Date: 2012-01-03 18:03:24 +0000 (Tue, 03 Jan 2012)
Log Message:
-----------
Force full reload before index might overflow during long periods without interesting bus traffic
Modified Paths:
--------------
CometVisu/trunk/visu/lib/cometvisu-client.js
Modified: CometVisu/trunk/visu/lib/cometvisu-client.js
===================================================================
--- CometVisu/trunk/visu/lib/cometvisu-client.js 2012-01-03 15:39:57 UTC (rev 630)
+++ CometVisu/trunk/visu/lib/cometvisu-client.js 2012-01-03 18:03:24 UTC (rev 631)
@@ -32,7 +32,9 @@
this.xhr = false; // the ongoing AJAX request
this.watchdogTimer = 5; // in Seconds - the alive check intervall of the watchdog
this.maxConnectionAge = 60; // in Seconds - restart if last read is older
- this.lastIndex = 0; // index returned by the last request
+ this.maxDataAge = 3200; // in Seconds - reload all data when last successfull read is older
+ // (should be faster than the index overflow at max data rate, i.e. 2^16 @ 20 tps for KNX TP)
+ this.lastIndex = -1; // index returned by the last request
/**
* This function gets called once the communication is established and session information is available
@@ -55,7 +57,7 @@
*/
this.handleRead = function( json )
{
- if( !json && !this.doRestart )
+ if( !json && (-1 == this.lastIndex) )
{
if( this.running )
{ // retry initial request
@@ -181,9 +183,11 @@
*/
var watchdog = (function(){
var last = new Date();
+ var hardLast = last;
var aliveCheckFunction = function(){
var now = new Date();
if( now - last < thisCometVisu.maxConnectionAge * 1000 ) return;
+ if( now - hardLast > thisCometVisu.maxDataAge * 1000 ) thisCometVisu.lastIndex = -1; // reload all data
thisCometVisu.restart();
last = now;
};
@@ -191,6 +195,8 @@
return {
ping: function(){
last = new Date();
+ if( !thisCometVisu.doRestart )
+ hardLast = last;
}
};
})();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|