]> git.mxchange.org Git - hub.git/blobdiff - application/hub/main/registry/socket/class_SocketRegistry.php
Continued on development of 'hub' project with many refactorings/addings:
[hub.git] / application / hub / main / registry / socket / class_SocketRegistry.php
index 60c8059711eb0ca8fb0e89b640d6dd24fa2e291b..bc72879d039b4419abf11d7bf20b69fc5e42f5f2 100644 (file)
@@ -4,7 +4,7 @@
  *
  * @author             Roland Haeder <webmaster@ship-simu.org>
  * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009, 2010 Hub Developer Team
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2011 Hub Developer Team
  * @license            GNU GPL 3.0 or any newer version
  * @link               http://www.ship-simu.org
  *
@@ -28,7 +28,7 @@ class SocketRegistry extends BaseRegistry implements Register, RegisterableSocke
        /**
         * Instance of this class
         */
-       private static $registryInstance = null;
+       private static $registryInstance = NULL;
 
        /**
         * Protected constructor
@@ -45,7 +45,7 @@ class SocketRegistry extends BaseRegistry implements Register, RegisterableSocke
         *
         * @return      $registryInstance       An instance of this class
         */
-       public final static function createSocketRegistry () {
+       public static final function createSocketRegistry () {
                // Is an instance there?
                if (is_null(self::$registryInstance)) {
                        // Not yet, so create one
@@ -150,7 +150,7 @@ class SocketRegistry extends BaseRegistry implements Register, RegisterableSocke
                // Is the socket already registered?
                if ($this->isSocketRegistered($protocolInstance, $socketResource)) {
                        // Throw the exception
-                       throw new SocketAlreadyRegisteredException($protocolInstance, BaseListener::EXCEPTION_SOCKET_ALREADY_REGISTERED);
+                       throw new SocketAlreadyRegisteredException(array($protocolInstance, $socketResource), BaseListener::EXCEPTION_SOCKET_ALREADY_REGISTERED);
                } // END - if
 
                // Does the instance exist?
@@ -172,6 +172,7 @@ class SocketRegistry extends BaseRegistry implements Register, RegisterableSocke
                $socketInstance = ObjectFactory::CreateObjectByConfiguredName('socket_container_class', array($socketResource, $protocolInstance, $packageData));
 
                // We have a sub-registry, the socket key and the socket, now we need to put all together
+               /* DEBUG: */ $this->debugOutput('SOCKET-REGISTRY: socketKey=' . $socketKey . ',socketResource=' . $socketResource . ' - adding socket container instance ...');
                $registryInstance->addInstance($socketKey, $socketInstance);
        }
 
@@ -213,15 +214,15 @@ class SocketRegistry extends BaseRegistry implements Register, RegisterableSocke
         */
        public function getHandlerInstanceFromPackageData (array $packageData) {
                // Init protocol instance
-               $protocolInstance = null;
+               $protocolInstance = NULL;
 
                // Get all keys and check them
                foreach ($this->getInstanceRegistry() as $key=>$registryInstance) {
                        // This is always a SubRegistry instance
                        foreach ($registryInstance->getInstanceRegistry() as $subKey=>$containerInstance) {
                                // This is a SocketContainer instance, so does the recipient match?
-                               if ($containerInstance->ifAddressMatches($packageData['recipient'])) {
-                                       // Found one, so get the protocol instance and abort
+                               if ($containerInstance->ifAddressMatches($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT])) {
+                                       // Found one, so get the protocol instance and abort any further search
                                        $protocolInstance = $containerInstance->getProtocolInstance();
                                        break;
                                } // END - if