[TASK] Finalized modifications on ClientManager.

[TASK] Added support for further class paths to ClassLoader.
[TASK] Started to implement the irc client dispatcher. (partially works now)
This commit is contained in:
Jan Philipp Timme
2011-12-03 20:58:08 +01:00
parent 16ff75eb1d
commit e702124895
7 changed files with 90 additions and 54 deletions
@@ -99,7 +99,7 @@ class ClientManager {
foreach($this->connectionPool->getConnectionHandlers() AS $connectionHandler) {
if(isset($this->clientDispatcherPool[$connectionHandler->getID()])) continue;
//new connections might need a client, so we'll create one here.
$this->addClientForConnectionHandler($connectionHandler);
$this->addClientDispatcherForConnectionHandler($connectionHandler);
//allow client to send initial stuff right after connecting to the server.
$this->initializeClientForConnectionHandler($connectionHandler);
}
@@ -120,7 +120,7 @@ class ClientManager {
}
//handle accepted sockets, adopt them and treat them with care :-)
if($connectionHandler->isListening() === TRUE) {
$this->addClientForConnectionHandler($connectionHandler);
$this->addClientDispatcherForConnectionHandler($connectionHandler);
$this->initializeClientForConnectionHandler($connectionHandler);
}
@@ -233,7 +233,7 @@ class ClientManager {
}
/**
* Calls Connection_Pool.
* Calls \JPT\SocketFramework\Connection\ConnectionPool.
*
* @see \JPT\SocketFramework\Connection\ConnectionPool
* @param string $group
@@ -254,8 +254,8 @@ class ClientManager {
*/
protected function createClientDispatcherForProtocol($protocolIdentifier) {
//look for the protocol
if(!in_array($protocolIdentifier, $this->registeredClientDispatchers)) {
throw new \JPT\SocketFramework\Exception\GeneralException("No client dispatcher is registered for protocol: '" . $protocol . "'!", 1290271651);
if(isset($this->registeredClientDispatchers[$protocolIdentifier]) === FALSE) {
throw new \JPT\SocketFramework\Exception\GeneralException("No client dispatcher is registered for protocol: '" . $protocolIdentifier . "'!", 1290271651);
}
$className = $this->registeredClientDispatchers[$protocolIdentifier];
//look for the class
@@ -265,7 +265,7 @@ class ClientManager {
if(!$clientDispatcher instanceof \JPT\SocketFramework\Client\AbstractClientDispatcher) throw new \JPT\SocketFramework\Exception\GeneralException("Class '" . $className . "' does not implement the AbstractClientDispatcher-API!", 1294837055);
return $clientDispatcher;
} else {
throw new \JPT\SocketFramework\Exception\GeneralException("Registered class name '" . $className . "' does not exist for protocol: '" . $protocol . "'!", 1290271773);
throw new \JPT\SocketFramework\Exception\GeneralException("Registered class name '" . $className . "' does not exist for protocol: '" . $protocolIdentifier . "'!", 1290271773);
}
}
@@ -277,6 +277,7 @@ class ClientManager {
* @return void
*/
protected function initializeClientForConnectionHandler($connectionHandler) {
if(!isset($this->clientDispatcherPool[$connectionHandler->getID()])) return;
$this->clientDispatcherPool[$connectionHandler->getID()]->initializeConnection();
//after initializing, have it process an empty string in order to get stuff to write. >.<
$result = $this->clientDispatcherPool[$connectionHandler->getID()]->processRawData("");
@@ -315,7 +316,7 @@ class ClientManager {
* @return void
*/
protected function addClientDispatcherForConnectionHandler($connectionHandler) {
$protocolIdentifier = $this->registeredProtocols[$connectionHandler->getProtocol()];
$protocolIdentifier = $connectionHandler->getProtocol();
//do not try this for "RAW" connections - might or might not be useful.
if($protocolIdentifier === "RAW") return;
$clientDispatcher = $this->createClientDispatcherForProtocol($protocolIdentifier);