diff --git a/Classes/Client/ClientManager.php b/Classes/Client/ClientManager.php index bb1b7df..1119bc9 100644 --- a/Classes/Client/ClientManager.php +++ b/Classes/Client/ClientManager.php @@ -78,7 +78,7 @@ class Client_ClientManager { } /** - * Main worker function. + * Main worker procedure. * Processes incoming data, calls clients and much more. * @return void */ @@ -121,6 +121,8 @@ class Client_ClientManager { //call the registered client if(isset($this->clientPool[$connectionHandler->getID()])) $outgoingData .= $this->clientPool[$connectionHandler->getID()]->processRawData($incomingData); + //i don't know what to do here... maybe call a connection bridge? + //output will be sent. if($outgoingData !== "") $connectionHandler->write($result); } @@ -196,9 +198,7 @@ class Client_ClientManager { */ public function getIDs() { $list = array(); - foreach($this->connectionPool->getConnectionHandlers() AS $connectionHandler) { - $list[] = $connectionHandler->getID(); - } + foreach($this->connectionPool->getConnectionHandlers() AS $connectionHandler) $list[] = $connectionHandler->getID(); return $list; } @@ -208,9 +208,7 @@ class Client_ClientManager { */ public function getGroups() { $list = array(); - foreach($this->connectionPool->getConnectionHandlers() AS $connectionHandler) { - $list[] = $connectionHandler->getGroup(); - } + foreach($this->connectionPool->getConnectionHandlers() AS $connectionHandler) $list[] = $connectionHandler->getGroup(); return $list; } @@ -240,6 +238,7 @@ class Client_ClientManager { $className = "Client_" . $protocol . "Client"; //look for the class if(class_exists($className)) { + //TODO: This looks ugly and wrong. Ideas, anyone? $client = new $className(); if(!$client instanceof Client_AbstractClient) throw new Exception_GeneralException("Class '" . $className . "' does not implement the AbstractClient-API!", 1294837055); return $client; @@ -299,6 +298,7 @@ class Client_ClientManager { } $client->injectClientManager($this); $protocolHandlerClass = "Protocol_".$protocol."ProtocolHandler"; + //TODO: This looks ugly, too. Is there a better way? $protocolHandler = new $protocolHandlerClass(); $client->injectProtocolHandler($protocolHandler); $client->setID($connectionHandler->getID()); diff --git a/Classes/Connection/ConnectionHandler.php b/Classes/Connection/ConnectionHandler.php index 6de0c23..555b2a9 100644 --- a/Classes/Connection/ConnectionHandler.php +++ b/Classes/Connection/ConnectionHandler.php @@ -1,6 +1,6 @@ connectionHandlers, $add_connectionHandler); + public function addConnectionHandler($addConnectionHandler) { + array_push($this->connectionHandlers, $addConnectionHandler); $this->nextID++; } /** * Removes a ConnectionHandler from the pool. - * @param Connection_ConnectionHandler $remove_connectionHandler + * @param Connection_ConnectionHandler $removeConnectionHandler * @return void */ - public function removeConnectionHandler($remove_connectionHandler) { + public function removeConnectionHandler($removeConnectionHandler) { foreach($this->connectionHandlers AS $key=>$connectionHandler) { - if($connectionHandler === $remove_connectionHandler) { - $this->socketPool->removeSocket($remove_connectionHandler->getSocket()); - $remove_connectionHandler->close(); + if($connectionHandler === $removeConnectionHandler) { + $this->socketPool->removeSocket($removeConnectionHandler->getSocket()); + $removeConnectionHandler->close(); unset($this->connectionHandlers[$key]); } } diff --git a/Classes/Socket/SocketPool.php b/Classes/Socket/SocketPool.php index 1980158..80b2a1f 100644 --- a/Classes/Socket/SocketPool.php +++ b/Classes/Socket/SocketPool.php @@ -39,22 +39,22 @@ class Socket_SocketPool { /** * Adds a socket to the pool - * @param ressource $add_socket + * @param ressource $addSocket * @return void */ - public function addSocket($add_socket) { - array_push($this->sockets, $add_socket); + public function addSocket($addSocket) { + array_push($this->sockets, $addSocket); } /** * Removes the given socket from the pool. * The socket will be shutdown. - * @param ressource $remove_socket + * @param ressource $removeSocket * @return void */ - public function removeSocket($remove_socket) { + public function removeSocket($removeSocket) { foreach($this->sockets AS $key=>$socket) { - if($socket !== $remove_socket) { + if($socket !== $removeSocket) { continue; } else { unset($socket);