]> git.mxchange.org Git - hub.git/blobdiff - application/hub/main/registry/socket/class_SocketRegistry.php
Merge branch 'master' into refacuring/protocol_handler
[hub.git] / application / hub / main / registry / socket / class_SocketRegistry.php
index aa89bfd7792b96360bc160ee8d8eae6a38d6493e..4237e482c9560d7024128ef57efc59ae399e4c6a 100644 (file)
@@ -4,7 +4,7 @@
  *
  * @author             Roland Haeder <webmaster@shipsimu.org>
  * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
  * @license            GNU GPL 3.0 or any newer version
  * @link               http://www.shipsimu.org
  *
@@ -81,9 +81,9 @@ class SocketRegistry extends BaseRegistry implements Register, RegisterableSocke
                }
 
                // Get protocol and port number and add both together
-               $key = sprintf("%s:%s:%s:%s",
+               $key = sprintf('%s:%s:%s:%s',
                        $protocolInstance->__toString(),
-                       $protocolInstance->getProtocol(),
+                       $protocolInstance->getProtocolName(),
                        $address,
                        $protocolInstance->getPort()
                );
@@ -100,7 +100,7 @@ class SocketRegistry extends BaseRegistry implements Register, RegisterableSocke
         */
        private function getRegistryKeyFromProtocol (ProtocolHandler $protocolInstance) {
                // Get the key
-               $key = $protocolInstance->getProtocol();
+               $key = $protocolInstance->getProtocolName();
 
                // Return resulting key
                return $key;
@@ -114,7 +114,7 @@ class SocketRegistry extends BaseRegistry implements Register, RegisterableSocke
         */
        private function isProtocolRegistered (ProtocolHandler $protocolInstance) {
                // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__ . ':protocol=' . $protocolInstance->getProtocol() . ' - ENTERED!');
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']:protocol=' . $protocolInstance->getProtocolName() . ' - ENTERED!');
 
                // Get the key
                $key = $this->getRegistryKeyFromProtocol($protocolInstance);
@@ -123,7 +123,7 @@ class SocketRegistry extends BaseRegistry implements Register, RegisterableSocke
                $isRegistered = $this->instanceExists($key);
 
                // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__ . ':protocol=' . $protocolInstance->getProtocol() . ',isRegistered=' . intval($isRegistered) . ' - EXIT!');
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']:protocol=' . $protocolInstance->getProtocolName() . ',isRegistered=' . intval($isRegistered) . ' - EXIT!');
 
                // Return result
                return $isRegistered;
@@ -139,7 +139,7 @@ class SocketRegistry extends BaseRegistry implements Register, RegisterableSocke
         */
        public function isSocketRegistered (ProtocolHandler $protocolInstance, $socketResource) {
                // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__ . ':protocol=' . $protocolInstance->getProtocol() . ',socketResource[' . gettype($socketResource) . ']=' . $socketResource . ' - ENTERED!');
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']:protocol=' . $protocolInstance->getProtocolName() . ',socketResource[' . gettype($socketResource) . ']=' . $socketResource . ' - ENTERED!');
 
                // Default is not registered
                $isRegistered = FALSE;
@@ -150,7 +150,7 @@ class SocketRegistry extends BaseRegistry implements Register, RegisterableSocke
                        $key = $this->getRegistryKeyFromProtocol($protocolInstance);
 
                        // Debug message
-                       //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']: protocol=' . $protocolInstance->getProtocol() . ',socketResource[' . gettype($socketResource) . ']=' . $socketResource . ',key=' . $key . ' - Trying to get instance ...');
+                       //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']: protocol=' . $protocolInstance->getProtocolName() . ',socketResource[' . gettype($socketResource) . ']=' . $socketResource . ',key=' . $key . ' - Trying to get instance ...');
 
                        // Get the registry
                        $registryInstance = $this->getInstance($key);
@@ -159,7 +159,7 @@ class SocketRegistry extends BaseRegistry implements Register, RegisterableSocke
                        $socketKey = $this->getSubRegistryKey($protocolInstance);
 
                        // Debug message
-                       //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']: protocol=' . $protocolInstance->getProtocol() . ',socketResource[' . gettype($socketResource) . ']=' . $socketResource . ',key=' . $key . ',socketKey=' . $socketKey . ' - Checking existence ...');
+                       //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']: protocol=' . $protocolInstance->getProtocolName() . ',socketResource[' . gettype($socketResource) . ']=' . $socketResource . ',key=' . $key . ',socketKey=' . $socketKey . ' - Checking existence ...');
 
                        // Is it there?
                        if ($registryInstance->instanceExists($socketKey)) {
@@ -178,7 +178,7 @@ class SocketRegistry extends BaseRegistry implements Register, RegisterableSocke
                } // END - if
 
                // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__ . ':protocol=' . $protocolInstance->getProtocol() . ',socketResource[' . gettype($socketResource) . ']=' . $socketResource . ',isRegistered=' . intval($isRegistered) . ' - EXIT!');
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']:protocol=' . $protocolInstance->getProtocolName() . ',socketResource[' . gettype($socketResource) . ']=' . $socketResource . ',isRegistered=' . intval($isRegistered) . ' - EXIT!');
 
                // Return the result
                return $isRegistered;
@@ -195,7 +195,7 @@ class SocketRegistry extends BaseRegistry implements Register, RegisterableSocke
         */
        public function registerSocket (ProtocolHandler $protocolInstance, $socketResource, array $packageData = array()) {
                // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__ . ':protocol=' . $protocolInstance->getProtocol() . ',socketResource[' . gettype($socketResource) . ']=' . $socketResource . ' - ENTERED!');
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']:protocol=' . $protocolInstance->getProtocolName() . ',socketResource[' . gettype($socketResource) . ']=' . $socketResource . ' - ENTERED!');
 
                // Is the socket already registered?
                if ($this->isSocketRegistered($protocolInstance, $socketResource)) {
@@ -235,7 +235,7 @@ class SocketRegistry extends BaseRegistry implements Register, RegisterableSocke
         */
        public function getRegisteredSocketResource (ProtocolHandler $protocolInstance) {
                // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__ . ':protocol=' . $protocolInstance->getProtocol() . ' - ENTERED!');
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']:protocol=' . $protocolInstance->getProtocolName() . ' - ENTERED!');
 
                // The socket must be registered before we can return it
                if (!$this->isProtocolRegistered($protocolInstance)) {
@@ -256,7 +256,7 @@ class SocketRegistry extends BaseRegistry implements Register, RegisterableSocke
                $socketResource = $registryInstance->getInstance($socketKey)->getSocketResource();
 
                // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(__METHOD__ . ':protocol=' . $protocolInstance->getProtocol() . ',socketResource[' . gettype($socketResource) . ']=' . $socketResource . ' - EXIT!');
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']:protocol=' . $protocolInstance->getProtocolName() . ',socketResource[' . gettype($socketResource) . ']=' . $socketResource . ' - EXIT!');
 
                // Return the resource
                return $socketResource;