From f3b1354aa21b61ccb967e71bad8678d8bae7a835 Mon Sep 17 00:00:00 2001 From: Jan Philipp Timme Date: Sat, 27 Nov 2010 19:59:11 +0000 Subject: [PATCH] [TASK] Cleanup in the ClientManager and added an AbstractProtocolHandler. --- Classes/Client/ClientManager.php | 22 +++++--------------- Classes/Protocol/AbstractProtocolHandler.php | 19 +++++++++++++++++ 2 files changed, 24 insertions(+), 17 deletions(-) create mode 100644 Classes/Protocol/AbstractProtocolHandler.php diff --git a/Classes/Client/ClientManager.php b/Classes/Client/ClientManager.php index aa4d20b..6865f58 100644 --- a/Classes/Client/ClientManager.php +++ b/Classes/Client/ClientManager.php @@ -6,6 +6,7 @@ * @author jpt * @package Client * @depends Connection + * TODO: implement routing with some more detailed rules, remove hardcoded client-based routing. */ class Client_ClientManager { @@ -23,7 +24,7 @@ class Client_ClientManager { /** * @var array */ - protected $rawRoutingRules; + protected $routingRules; /** * An array that contains all protocols we have clients for. @@ -47,7 +48,7 @@ class Client_ClientManager { $this->connectionPool = new Connection_ConnectionPool($linebreak); $this->clientPool = array(); $this->registeredProtocols = array(); - $this->rawRoutingRules = array(); + $this->routingRules = array(); $this->configPool = array(); } @@ -81,18 +82,15 @@ class Client_ClientManager { if($connectionHandler->isConnected() === FALSE && $connectionHandler->isListening() === FALSE) { $this->removeClientForConnectionHandler($connectionHandler); } - - //ne warte mal, das geht nicht...oder so + //handle accepted sockets, adopt them and treat them with care :-) if($connectionHandler->isListening() === TRUE) { $this->addClientForConnectionHandler($connectionHandler); } - //create a client for a connection without one. if(!isset($this->clientPool[$connectionHandler->getID()])) { $this->addClientForConnectionHandler($connectionHandler); } - - + //call the registered client if(isset($this->clientPool[$connectionHandler->getID()])) { //let the client process the data, send the results back. while($data = $connectionHandler->read()) { @@ -102,19 +100,9 @@ class Client_ClientManager { } } } - } } - /** - * TODO: implement this! - * @param unknown_type $from - * @param unknown_type $to - */ - public function addRawRouting($from, $to) { - $this->rawRoutingRules[] = array(""); - } - /** * Calls ConnectionPool in order to create a simple connection. * @see Connection_ConnectionPool diff --git a/Classes/Protocol/AbstractProtocolHandler.php b/Classes/Protocol/AbstractProtocolHandler.php new file mode 100644 index 0000000..fe5885c --- /dev/null +++ b/Classes/Protocol/AbstractProtocolHandler.php @@ -0,0 +1,19 @@ + \ No newline at end of file