From: Roland Häder Date: Mon, 12 Jan 2015 08:00:48 +0000 (+0100) Subject: Continued with refacturing: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=e68827851c52084ced0b6f03fc825dd4802647e3;p=hub.git Continued with refacturing: - Added missing method getConnectionType() + a few commented out debug lines Signed-off-by: Roland Häder --- diff --git a/application/hub/interfaces/helper/connections/class_ConnectionHelper.php b/application/hub/interfaces/helper/connections/class_ConnectionHelper.php index 6bf7b5cd3..1117f3188 100644 --- a/application/hub/interfaces/helper/connections/class_ConnectionHelper.php +++ b/application/hub/interfaces/helper/connections/class_ConnectionHelper.php @@ -48,6 +48,13 @@ interface ConnectionHelper extends HubHelper { */ function getConnectionPort (); + /** + * Getter for connection type + * + * @return $type Type of connection + */ + function getConnectionType (); + /** * Getter for IP address * diff --git a/application/hub/interfaces/listener/class_Listenable.php b/application/hub/interfaces/listener/class_Listenable.php index ec878cc53..652f03e64 100644 --- a/application/hub/interfaces/listener/class_Listenable.php +++ b/application/hub/interfaces/listener/class_Listenable.php @@ -67,6 +67,13 @@ interface Listenable extends FrameworkInterface { */ function getListenPort (); + /** + * Getter for connection type + * + * @return $connectionType Connection type for this listener + */ + function getConnectionType (); + /** * Getter for peer pool instance * diff --git a/application/hub/main/listener/class_BaseListener.php b/application/hub/main/listener/class_BaseListener.php index 2aa6c6a9e..13e6449e1 100644 --- a/application/hub/main/listener/class_BaseListener.php +++ b/application/hub/main/listener/class_BaseListener.php @@ -184,6 +184,16 @@ class BaseListener extends BaseHubSystem implements Visitable { return $this->poolInstance; } + /** + * Getter for connection type + * + * @return $connectionType Connection type for this listener + */ + public final function getConnectionType () { + // Wrap the real getter + return $this->getProtocolName(); + } + /** * Registeres the given socket resource for "this" listener instance. This * will be done in a seperate class to allow package writers to use it diff --git a/application/hub/main/listener/class_BaseListenerDecorator.php b/application/hub/main/listener/class_BaseListenerDecorator.php index e45a78111..bd09e8c74 100644 --- a/application/hub/main/listener/class_BaseListenerDecorator.php +++ b/application/hub/main/listener/class_BaseListenerDecorator.php @@ -56,6 +56,15 @@ class BaseListenerDecorator extends BaseDecorator implements Visitable { return $this->getListenerInstance()->getListenPort(); } + /** + * Getter for connection type + * + * @return $connectionType Connection type for this listener + */ + public final function getConnectionType () { + return $this->getListenerInstance()->getConnectionType(); + } + /** * Accepts the visitor to process the visit "request" * diff --git a/application/hub/main/pools/class_BasePool.php b/application/hub/main/pools/class_BasePool.php index 9090a8be6..a6befaa75 100644 --- a/application/hub/main/pools/class_BasePool.php +++ b/application/hub/main/pools/class_BasePool.php @@ -77,7 +77,8 @@ class BasePool extends BaseHubSystem implements Visitable { * @return void */ protected final function addInstance ($group, $poolName, Visitable $visitableInstance) { - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('POOL[' . __METHOD__ . ':' . __LINE__ . ']: group=' . $group . ',poolName=' . $poolName . ',visitableInstance=' . $visitableInstance->__toString() . ' - CALLED!'); + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('POOL[' . __METHOD__ . ':' . __LINE__ . ']: group=' . $group . ',poolName=' . $poolName . ',visitableInstance=' . $visitableInstance->__toString() . ' - CALLED!'); // Make sure the group is not 'invalid' assert($group != 'invalid'); @@ -90,6 +91,9 @@ class BasePool extends BaseHubSystem implements Visitable { // Add it to given pool group $this->getPoolEntriesInstance()->addInstance($group, $poolName, $visitableInstance); + + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('POOL[' . __METHOD__ . ':' . __LINE__ . ']: EXIT!'); } /** diff --git a/application/hub/main/registry/connection/class_ConnectionRegistry.php b/application/hub/main/registry/connection/class_ConnectionRegistry.php index 2caf8fc76..5d663f171 100644 --- a/application/hub/main/registry/connection/class_ConnectionRegistry.php +++ b/application/hub/main/registry/connection/class_ConnectionRegistry.php @@ -64,6 +64,9 @@ class ConnectionRegistry extends BaseRegistry implements Register, RegisterableC * @return $key A string representation of the socket for the registry */ private function getSubRegistryKey (ConnectionHelper $connectionInstance) { + // Debug message + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']: connectionInstance=' . $connectionInstance->__toString() . ' CALLED!'); + // Get connection type and port number and add both together $key = sprintf('%s:%s:%s', $connectionInstance->__toString(), @@ -71,6 +74,9 @@ class ConnectionRegistry extends BaseRegistry implements Register, RegisterableC $connectionInstance->getConnectionPort() ); + // Debug message + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']: key=' . $key . ' - EXIT!'); + // Return resulting key return $key; } diff --git a/application/hub/main/registry/socket/class_SocketRegistry.php b/application/hub/main/registry/socket/class_SocketRegistry.php index e20b0f98a..9b55d9cd7 100644 --- a/application/hub/main/registry/socket/class_SocketRegistry.php +++ b/application/hub/main/registry/socket/class_SocketRegistry.php @@ -64,6 +64,9 @@ class SocketRegistry extends BaseRegistry implements Register, RegisterableSocke * @return $key A string representation of the socket for the registry */ private function getSubRegistryKey (Listenable $connectionInstance) { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']: connectionInstance=' . $connectionInstance->__toString() . ' - ENTERED!'); + // Default address is invalid $address = '*invalid*'; $port = 0; @@ -83,6 +86,9 @@ class SocketRegistry extends BaseRegistry implements Register, RegisterableSocke $this->debugBackTrace('Unsupported connectionInstance=' . $connectionInstance->__toString() . ' detected. Please fix this!'); } + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']: address=' . $address . ',port=' . $port); + // Get connection type and port number and add both together $key = sprintf('%s:%s:%s:%s', $connectionInstance->__toString(), @@ -91,6 +97,9 @@ class SocketRegistry extends BaseRegistry implements Register, RegisterableSocke $port ); + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']: key=' . $key . ' - EXIT!'); + // Return resulting key return $key; } @@ -102,9 +111,15 @@ class SocketRegistry extends BaseRegistry implements Register, RegisterableSocke * @return $key A string representation of the listener for the registry */ private function getRegistryKeyFromListener (Listenable $listenerInstance) { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']: listenerInstance=' . $listenerInstance->__toString() . ' - ENTERED!'); + // Get the key $key = $listenerInstance->getConnectionType(); + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']: key=' . $key . ' - EXIT!'); + // Return resulting key return $key; }