diff --git a/Classes/Client/BotClient.php b/Classes/Client/BotClient.php index 5f5fae4..dfd1a58 100644 --- a/Classes/Client/BotClient.php +++ b/Classes/Client/BotClient.php @@ -20,6 +20,7 @@ class Client_BotClient extends Client_AbstractClient { * @return string */ public function processContentObject($contentObject) { + $return = ""; $data = $contentObject->rawData; if(strpos($data, "-") !== FALSE ) { $data = explode("-", $data); diff --git a/Classes/Client/ClientManager.php b/Classes/Client/ClientManager.php index 8296a5c..197f769 100644 --- a/Classes/Client/ClientManager.php +++ b/Classes/Client/ClientManager.php @@ -130,8 +130,8 @@ class Client_ClientManager { * @param string $className * @return void */ - public function registerProtocol($protocol, $className) { - $this->registeredProtocols[$protocol] = $className; + public function registerProtocol($protocol, $classNamePartial) { + $this->registeredProtocols[$protocol] = $classNamePartial; } /** @@ -152,10 +152,10 @@ class Client_ClientManager { */ protected function createClientForProtocol($protocol) { //look for the protocol - if(!isset($this->registeredProtocols[$protocol])) { + if(!in_array($protocol, $this->registeredProtocols)) { throw new Exception_GeneralException("No client registered for protocol: '" . $protocol . "'!", 1290271651); } - $className = $this->registeredProtocols[$protocol]; + $className = "Client_" . $protocol . "Client"; //look for the class if(class_exists($className)) { return new $className(); @@ -170,7 +170,7 @@ class Client_ClientManager { * @return void */ protected function addClientForConnectionHandler($connectionHandler) { - $protocol = $connectionHandler->getProtocol(); + $protocol = $this->registeredProtocols[$connectionHandler->getProtocol()]; //do not try this for raw connections if($protocol === "RAW") return; $client = $this->createClientForProtocol($protocol); @@ -178,8 +178,8 @@ class Client_ClientManager { $client->loadConfig($this->configPool[$connectionHandler->getID()]); } $client->injectClientManager($this); - $className = "Protocol_".$protocol."ProtocolHandler"; - $protocolHandler = new $className(); + $protocolHandlerClass = "Protocol_".$protocol."ProtocolHandler"; + $protocolHandler = new $protocolHandlerClass(); $client->injectProtocolHandler($protocolHandler); $client->setID($connectionHandler->getID()); $client->setGroup($connectionHandler->getGroup()); diff --git a/Classes/Client/IrcClient.php b/Classes/Client/IrcClient.php index 04dc713..9b06ced 100644 --- a/Classes/Client/IrcClient.php +++ b/Classes/Client/IrcClient.php @@ -33,7 +33,6 @@ class Client_IrcClient extends Client_AbstractClient { * @return string */ public function processContentObject($contentObject) { - var_dump($contentObject); $data = $contentObject->rawData; //echo "[RECV] ".$data; diff --git a/Classes/Protocol/BotProtocolContentObject.php b/Classes/Protocol/BotProtocolContentObject.php new file mode 100644 index 0000000..62cb46d --- /dev/null +++ b/Classes/Protocol/BotProtocolContentObject.php @@ -0,0 +1,10 @@ + \ No newline at end of file diff --git a/Classes/Protocol/BotProtocolHandler.php b/Classes/Protocol/BotProtocolHandler.php new file mode 100644 index 0000000..ea2f462 --- /dev/null +++ b/Classes/Protocol/BotProtocolHandler.php @@ -0,0 +1,17 @@ + \ No newline at end of file diff --git a/Testcode/Client/ClientManagerTest.php b/Testcode/Client/ClientManagerTest.php index f491433..9633785 100644 --- a/Testcode/Client/ClientManagerTest.php +++ b/Testcode/Client/ClientManagerTest.php @@ -1,9 +1,9 @@ registerProtocol("Irc", "Client_IrcClient"); -$clientManager->registerProtocol("jpt", "Client_BotClient"); +$clientManager->registerProtocol("irc", "Irc"); +$clientManager->registerProtocol("jpt", "Bot"); -$freenode = $clientManager->createTcpConnection("freenode", "Irc"); +$freenode = $clientManager->createTcpConnection("freenode", "irc"); $clientManager->attachConfig(array( "nick" => "Testinstanz", "userident" => "uzuguck", @@ -11,7 +11,7 @@ $clientManager->attachConfig(array( ), $freenode); $freenode->connect("irc.freenode.net", 6667); -$freenode = $clientManager->createTcpConnection("freenode", "Irc"); +$freenode = $clientManager->createTcpConnection("freenode", "irc"); $clientManager->attachConfig(array( "nick" => "Testinstanz2", "userident" => "uzuguck", @@ -30,9 +30,9 @@ $eloxoph = $clientManager->createTcpConnection("eloxoph", "irc"); $clientManager->attachConfig($config_eloxoph, $eloxoph); $eloxoph->connect("irc.eloxoph.com", 6667);*/ -/*$srv = $clientManager->createTcpConnection("srv", "jpt"); +$srv = $clientManager->createTcpConnection("srv", "jpt"); $srv->bind("localhost", 7777); -$srv->listen();*/ +$srv->listen(); while($clientManager->countConnections() > 0) { $clientManager->work();