[Phpfreechat-svn] SF.net SVN: phpfreechat: [942] trunk
Status: Beta
Brought to you by:
kerphi
From: <ke...@us...> - 2007-01-31 17:38:36
|
Revision: 942 http://svn.sourceforge.net/phpfreechat/?rev=942&view=rev Author: kerphi Date: 2007-01-31 09:37:29 -0800 (Wed, 31 Jan 2007) Log Message: ----------- fix problem with update process client side + add a new ping label Modified Paths: -------------- trunk/data/public/js/pfcclient.js trunk/src/commands/update.class.php trunk/themes/default/chat.html.tpl.php Modified: trunk/data/public/js/pfcclient.js =================================================================== --- trunk/data/public/js/pfcclient.js 2007-01-31 09:17:33 UTC (rev 941) +++ trunk/data/public/js/pfcclient.js 2007-01-31 17:37:29 UTC (rev 942) @@ -895,7 +895,7 @@ var rx = new RegExp('(^\/[^ ]+) *(.*)','ig'); if (!recipientid) recipientid = this.gui.getTabId(); cmd = cmd.replace(rx, '$1 '+this.clientid+' '+(recipientid==''?'0':recipientid)+' $2'); - return eval('pfc_handleRequest(cmd);'); + return pfc_handleRequest(cmd); //eval('pfc_handleRequest(cmd);'); }, /** @@ -906,20 +906,24 @@ clearTimeout(this.timeout); if (start) { + // calculate the ping and display it + this.ping = Math.abs(this.refresh_delay-(new Date().getTime() - this.last_refresh_time)); + $('pfc_ping').innerHTML = this.ping+'ms'; + var res = true; - if (this.canupdatenexttime || (new Date().getTime() - this.last_refresh_time) > this.max_refresh_delay) + if (this.canupdatenexttime) { + // the connection is ok res = this.sendRequest('/update'); - this.canupdatenexttime = false; // don't update since the 'ok' response is received + this.canupdatenexttime = false; // don't update if the last 'ok' response is not yet received } - // adjust the refresh_delay if the connection was lost - 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; - } - } + else if ((new Date().getTime() - this.last_refresh_time) > this.max_refresh_delay) + { + // the connection is probably closed or very slow + res = this.sendRequest('/update'); + this.canupdatenexttime = false; // don't update if the last 'ok' response is not yet received + this.last_refresh_time = new Date().getTime(); + } // setup the next update this.timeout = setTimeout('pfc.updateChat(true)', this.refresh_delay); } Modified: trunk/src/commands/update.class.php =================================================================== --- trunk/src/commands/update.class.php 2007-01-31 09:17:33 UTC (rev 941) +++ trunk/src/commands/update.class.php 2007-01-31 17:37:29 UTC (rev 942) @@ -69,8 +69,7 @@ $cmd->run($xml_reponse, $cmdp); } - // do not send ok response to save bandwidth - // $xml_reponse->script("pfc.handleResponse('update', 'ok', '');"); + $xml_reponse->script("pfc.handleResponse('update', 'ok', '');"); } else $xml_reponse->script("pfc.handleResponse('update', 'ko', '');"); Modified: trunk/themes/default/chat.html.tpl.php =================================================================== --- trunk/themes/default/chat.html.tpl.php 2007-01-31 09:17:33 UTC (rev 941) +++ trunk/themes/default/chat.html.tpl.php 2007-01-31 17:37:29 UTC (rev 942) @@ -36,7 +36,8 @@ </table> <div id="pfc_cmd_container"> - + <span id="pfc_ping"></span> + <?php if ($display_pfc_logo) { ?> <a href="http://www.phpfreechat.net" id="pfc_logo"<?php if($openlinknewwindow) echo ' onclick="window.open(this.href,\'_blank\');return false;"'; ?>> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |