[Zmx-cvs-commit] zmx ZMX_XML.as,1.41,1.42
Brought to you by:
sspickle
|
From: Steve S. <ssp...@us...> - 2005-03-20 02:04:46
|
Update of /cvsroot/zmx/zmx In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8185 Modified Files: ZMX_XML.as Log Message: added networkAvailableStatus messages. Index: ZMX_XML.as =================================================================== RCS file: /cvsroot/zmx/zmx/ZMX_XML.as,v retrieving revision 1.41 retrieving revision 1.42 diff -C2 -d -r1.41 -r1.42 *** ZMX_XML.as 3 Mar 2005 17:54:23 -0000 1.41 --- ZMX_XML.as 20 Mar 2005 02:04:35 -0000 1.42 *************** *** 105,108 **** --- 105,134 ---- p = c.prototype = new Object(); + + p.attemptConnection = function() { + if (this.xmlc != null) { + this.xmlc.close(); + } + else + { + this.xmlc = new AsyncSocket( this ); + } + + this.xmlc.connect(this.config.xmlhost,this.config.xmlport); + + if (this.config.configDelay != null) { + var delayAmount = 1000; + if (typeof(this.config.configDelay)=='number') { + delayAmount = this.config.configDelay*1000.0; + } + this.registerInterval = SetInterval( this, "registerConnection", delayAmount); + return false; + } + else { + this.send(this.config); + return true; + } + } + p.configSuccess = function( config ) { *************** *** 128,143 **** else { ! this.xmlc = new AsyncSocket( this ); ! this.xmlc.connect(this.config.xmlhost,this.config.xmlport); ! if (this.config.configDelay != null) { ! this.registerInterval = SetInterval( this, "registerConnection", 1000); ! } ! else { ! this.send(this.config); this.proxy.asyncConfigured( this.config ); } } } - delete this.configHelper; } --- 154,175 ---- else { ! if (this.attemptConnection()) { this.proxy.asyncConfigured( this.config ); } + + if (this.config.send_ping != null) { + // + // we're expecting pings... so set up an interval to check. + // + this.networkAvailable = true; + this.ping_interval = 15000.0; // default interval of 15 seconds.. + if (typeof(this.config.send_ping) == 'number') { + this.ping_interval = 1500.0*this.config.send_ping; // 1.5 times the ping time. + } + this.gotXMLSinceLastPing = false; + this.ping_interval_id = SetInterval( this, "checkPingSuccess", this.ping_interval); + } } } delete this.configHelper; } *************** *** 151,154 **** --- 183,207 ---- } + p.checkPingSuccess = function() { + + trace("checking ping success.."); + if (this.networkAvailable && !this.gotXMLSinceLastPing) { + this.networkAvailable = false; + this.proxy.networkAvailableStatus( this.networkAvailable) + trace("network no longer available.. "); + } + else if (!this.networkAvailable) { + if (this.gotXMLSinceLastPing) { + this.networkAvailable = true; + this.proxy.networkAvailableStatus( this.networkAvailable) + } + else + { + this.attemptConnection(); + } + } + this.gotXMLSinceLastPing = false; + } + p.send = function( theArgs, theMethod ) { // *************** *** 494,497 **** --- 547,553 ---- var target_id = argObj.params[0].target_id; var sender_id = argObj.params[0].sender_id; + + this.parentObj.gotXMLSinceLastPing = true; + if (argObj.methodCall) { if (this.filterLocally && (target_id != null)) { |