[TASK] Changed behaviour of protocol register.

This commit is contained in:
Jan Philipp Timme
2010-11-28 02:45:25 +00:00
parent 4bbb9bf548
commit b318595783
6 changed files with 41 additions and 14 deletions
+7 -7
View File
@@ -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());