[Phpfreechat-svn] SF.net SVN: phpfreechat: [781] trunk/src/commands
Status: Beta
Brought to you by:
kerphi
From: <ke...@us...> - 2006-09-22 08:12:35
|
Revision: 781 http://svn.sourceforge.net/phpfreechat/?rev=781&view=rev Author: kerphi Date: 2006-09-22 01:12:22 -0700 (Fri, 22 Sep 2006) Log Message: ----------- -- 1 -- [en] CPU Optimization: since the new data model some operation were useless and CPU consuming. [fr] Optimisation du CPU : depuis la mise en place du nouveau datamodel certaines op?\195?\169rations n'?\195?\169taient plus necessaire et consommaient du CPU inutile. -- 2 -- [en] Bug fix: the /leave command was broken [fr] Bug fix : la commande /leave ne fonctionnait plus Modified Paths: -------------- trunk/src/commands/connect.class.php trunk/src/commands/getonlinenick.class.php trunk/src/commands/join.class.php trunk/src/commands/leave.class.php trunk/src/commands/update.class.php trunk/src/commands/updatemynick.class.php Modified: trunk/src/commands/connect.class.php =================================================================== --- trunk/src/commands/connect.class.php 2006-09-21 12:13:24 UTC (rev 780) +++ trunk/src/commands/connect.class.php 2006-09-22 08:12:22 UTC (rev 781) @@ -14,7 +14,7 @@ $c =& $this->c; $u =& $this->u; - $container =& $c->getContainerInstance(); + $ct =& $c->getContainerInstance(); // reset the message id indicator (see getnewmsg.class.php) // i.e. be ready to re-get all last posted messages @@ -31,7 +31,7 @@ $chanid = pfcCommand_join::GetRecipientId($channame); // reset the fromid flag $from_id_sid = "pfc_from_id_".$c->getId()."_".$clientid."_".$chanid; - $from_id = $container->getLastId($chanrecip)-$c->max_msg; + $from_id = $ct->getLastId($chanrecip)-$c->max_msg; $_SESSION[$from_id_sid] = ($from_id<0) ? 0 : $from_id; // reset the oldmsg flag $oldmsg_sid = "pfc_oldmsg_".$c->getId()."_".$clientid."_".$chanid; @@ -42,7 +42,7 @@ $isadmin = $c->isadmin; if (!$isadmin) { - $users = $container->getOnlineNick(NULL); + $users = $ct->getOnlineNick(NULL); if (isset($users["nickid"]) && count($users["nickid"]) == 0) $isadmin = true; } @@ -50,9 +50,16 @@ // setup some user meta $nickid = $u->nickid; // store the user ip - $container->setUserMeta($nickid, 'ip', $_SERVER["REMOTE_ADDR"]); + $ct->setUserMeta($nickid, 'ip', $_SERVER["REMOTE_ADDR"]); // store the admin flag - $container->setUserMeta($nickid, 'isadmin', $isadmin); + $ct->setUserMeta($nickid, 'isadmin', $isadmin); + + // register the user (and his metadata) in the allready joined channel + foreach( $u->channels as $id => $chan ) + $ct->createNick($chan["recipient"], $u->nick, $u->nickid); + foreach( $u->privmsg as $id => $pv ) + $ct->createNick($pv["recipient"], $u->nick, $u->nickid); + // connect to the server $xml_reponse->addScript("pfc.handleResponse('connect', 'ok', '');"); } Modified: trunk/src/commands/getonlinenick.class.php =================================================================== --- trunk/src/commands/getonlinenick.class.php 2006-09-21 12:13:24 UTC (rev 780) +++ trunk/src/commands/getonlinenick.class.php 2006-09-22 08:12:22 UTC (rev 781) @@ -22,9 +22,9 @@ // get the real nickname list $users = $container->getOnlineNick($recipient); $nicklist = array(); - if (isset($users["nickid"])) - foreach($users["nickid"] as $nid) - $nicklist[] = $container->getNickname($nid); + if (isset($users["nick"])) + foreach($users["nick"] as $n) + $nicklist[] = $n; sort($nicklist); if ($oldnicklist != $nicklist) // check if the nickname list must be updated on the client side Modified: trunk/src/commands/join.class.php =================================================================== --- trunk/src/commands/join.class.php 2006-09-21 12:13:24 UTC (rev 780) +++ trunk/src/commands/join.class.php 2006-09-22 08:12:22 UTC (rev 781) @@ -56,8 +56,12 @@ $cmdp["flag"] = 2; $cmd =& pfcCommand::Factory("notice"); $cmd->run($xml_reponse, $cmdp); + + // register the user (and his metadata) in the channel + $ct =& $c->getContainerInstance(); + $ct->createNick($chanrecip, $u->nick, $u->nickid); } - + // return ok to the client // then the client will create a new tab $xml_reponse->addScript("pfc.handleResponse('".$this->name."', 'ok', Array('".$chanid."','".addslashes($channame)."'));"); Modified: trunk/src/commands/leave.class.php =================================================================== --- trunk/src/commands/leave.class.php 2006-09-21 12:13:24 UTC (rev 780) +++ trunk/src/commands/leave.class.php 2006-09-22 08:12:22 UTC (rev 781) @@ -72,7 +72,7 @@ // remove the nickname from the channel/pv $container =& $c->getContainerInstance(); - $container->removeNick($chan, $u->nickid); + $container->removeNick($leave_recip, $u->nickid); // return ok to the client // then the client will remove the channel' tab Modified: trunk/src/commands/update.class.php =================================================================== --- trunk/src/commands/update.class.php 2006-09-21 12:13:24 UTC (rev 780) +++ trunk/src/commands/update.class.php 2006-09-22 08:12:22 UTC (rev 781) @@ -19,20 +19,8 @@ if ($u->active) { $cmdp = $p; - // update the user nickname timestamp + // update the user nickname timestamp on the server $cmd =& pfcCommand::Factory("updatemynick"); - foreach( $u->channels as $id => $chan ) - { - $cmdp["recipient"] = $chan["recipient"]; - $cmdp["recipientid"] = $id; - $cmd->run($xml_reponse, $cmdp); - } - foreach( $u->privmsg as $id => $pv ) - { - $cmdp["recipient"] = $pv["recipient"]; - $cmdp["recipientid"] = $id; - $cmd->run($xml_reponse, $cmdp); - } $cmdp["recipient"] = NULL; $cmdp["recipientid"] = NULL; $cmd->run($xml_reponse, $cmdp); Modified: trunk/src/commands/updatemynick.class.php =================================================================== --- trunk/src/commands/updatemynick.class.php 2006-09-21 12:13:24 UTC (rev 780) +++ trunk/src/commands/updatemynick.class.php 2006-09-22 08:12:22 UTC (rev 781) @@ -17,22 +17,6 @@ $container =& $c->getContainerInstance(); $container->updateNick($u->nickid); - - $was_there = ($container->isNickOnline($recipient, $nickid) >=0); - if (!$was_there) - { - // if the user were not in the list, it must be created in order to refresh his metadata - // because when the user is timeouted, his metadata are destroyed. - $container->createNick($recipient, $u->nick, $u->nickid); - - /* - @todo: write the timeout adjustment when the user object will be available - if ($c->debug) pxlog("Cmd_updateMyNick[".$c->sessionid."]: nick ".$u->nick." updated but was not there, adjust timeout to ".$c->timeout, "chat", $c->getId()); - // adjust the timeout value dynamicaly for this user - $c->timeout += $c->refresh_delay; - $c->saveInCache(); - */ - } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |