[Phpfreechat-svn] SF.net SVN: phpfreechat: [837] trunk/src
Status: Beta
Brought to you by:
kerphi
From: <ke...@us...> - 2006-10-20 20:15:35
|
Revision: 837 http://svn.sourceforge.net/phpfreechat/?rev=837&view=rev Author: kerphi Date: 2006-10-20 13:15:12 -0700 (Fri, 20 Oct 2006) Log Message: ----------- [en] Now the client keep in memory the last update timestamp in order to automaticaly reconnect one request is lost. ex: when server is down. (thanks to bcc) [30min] [fr] Maintenant le client garde en m?\195?\169moire la date de la derniere mise ?\195?\160 jour du chat ainsi il se reconnect automatiquement si la connexion vennait ?\195?\160 ?\195?\170tre coup?\195?\169e. (merci ?\195?\160 bcc) [30min] Modified Paths: -------------- trunk/src/client/chat.js.tpl.php trunk/src/client/pfcclient.js trunk/src/pfcglobalconfig.class.php Modified: trunk/src/client/chat.js.tpl.php =================================================================== --- trunk/src/client/chat.js.tpl.php 2006-10-19 07:21:18 UTC (rev 836) +++ trunk/src/client/chat.js.tpl.php 2006-10-20 20:15:12 UTC (rev 837) @@ -10,6 +10,7 @@ var pfc_clientid = <?php echo $json->encode(md5(uniqid(rand(), true))); ?>; var pfc_title = <?php echo $json->encode($title); ?>; var pfc_refresh_delay = <?php echo $json->encode($refresh_delay); ?>; +var pfc_max_refresh_delay = <?php echo $json->encode($max_refresh_delay); ?>; var pfc_start_minimized = <?php echo $json->encode($start_minimized); ?>; var pfc_nickmarker = <?php echo $json->encode($nickmarker); ?>; var pfc_clock = <?php echo $json->encode($clock); ?>; Modified: trunk/src/client/pfcclient.js =================================================================== --- trunk/src/client/pfcclient.js 2006-10-19 07:21:18 UTC (rev 836) +++ trunk/src/client/pfcclient.js 2006-10-20 20:15:12 UTC (rev 837) @@ -41,6 +41,8 @@ this.timeout = null; this.refresh_delay = pfc_refresh_delay; + this.max_refresh_delay = pfc_max_refresh_delay; + this.last_refresh_time = 0; /* unique client id for each windows used to identify a open window * this id is passed every time the JS communicate with server * (2 clients can use the same session: then only the nickname is shared) */ @@ -310,6 +312,11 @@ else if (cmd == "update") { this.canupdatenexttime = true; + // if the first ever refresh request never makes it back then the chat will keep + // trying to refresh as usual + // this only helps if we temporarily lose connection in the middle of an established + // chat session + this.last_refresh_time = new Date().getTime(); } else if (cmd == "version") { @@ -844,13 +851,19 @@ if (start) { var res = true; - if (this.canupdatenexttime) + if (this.canupdatenexttime || (new Date().getTime() - this.last_refresh_time) > this.max_refresh_delay) { res = this.sendRequest('/update'); this.canupdatenexttime = false; // don't update since the 'ok' response is received } // adjust the refresh_delay if the connection was lost - if (res == false) { this.refresh_delay = this.refresh_delay * 2; } + if (res == false) { + this.refresh_delay = this.refresh_delay * 2; + if(this.refresh_delay > this.max_refresh_delay) + { + this.refresh_delay = this.max_refresh_delay; + } + } // setup the next update this.timeout = setTimeout('pfc.updateChat(true)', this.refresh_delay); } Modified: trunk/src/pfcglobalconfig.class.php =================================================================== --- trunk/src/pfcglobalconfig.class.php 2006-10-19 07:21:18 UTC (rev 836) +++ trunk/src/pfcglobalconfig.class.php 2006-10-20 20:15:12 UTC (rev 837) @@ -64,6 +64,7 @@ var $max_nick_len = 15; var $max_text_len = 400; var $refresh_delay = 5000; // in mili-seconds (5 seconds) + var $max_refresh_delay = 60000; // in mili-seconds (60 seconds) var $timeout = 20000; // in mili-seconds (20 seconds) var $max_msg = 20; var $quit_on_closedwindow = true; // could be annoying because the reload event is the same as a close event This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |