]> git.mxchange.org Git - hub.git/blobdiff - application/hub/main/discovery/recipient/socket/class_PackageSocketDiscovery.php
Continued rewrite:
[hub.git] / application / hub / main / discovery / recipient / socket / class_PackageSocketDiscovery.php
index 7d2d8bfac9c6b44f2e8e95e46c82aa8d40c24504..f7724cffdadec7f2ed6c2bb080c4e5accb99fcc4 100644 (file)
@@ -51,13 +51,13 @@ class PackageSocketDiscovery extends BaseRecipientDiscovery implements Discovera
        /**
         * Tries to dicover the right listener instance
         *
-        * @param       $protocolName           Protocol name
+        * @param       $protocolInstance       An instance of a HandleableProtocol class
         * @param       $packageData            Raw package data
         * @return      $listenerInstance       An instance of a Listenable instance or null
         */
-       public function discoverListenerInstance ($protocolName, array $packageData) {
+       public function discoverListenerInstance (HandleableProtocol $protocolInstance, array $packageData) {
                // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-DISCOVERY[' . __METHOD__ . ':' . __LINE__ . ']: protocolName=' . $protocolName . ' - ENTERED!');
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-DISCOVERY[' . __METHOD__ . ':' . __LINE__ . ']: protocolInstance=' . $protocolInstance->__toString() . ' - ENTERED!');
 
                /*
                 * Get the listener pool instance, we need to lookup the matching
@@ -68,14 +68,23 @@ class PackageSocketDiscovery extends BaseRecipientDiscovery implements Discovera
                // Init listener instance
                $listenerInstance = NULL;
 
+               // Get handler name
+               $protocolName = $protocolInstance->getProtocolName();
+
+               // Debug message
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-DISCOVERY[' . __METHOD__ . ':' . __LINE__ . ']: protocolName=' . $protocolName . ',poolEntriesInstance=' . $poolInstance->getPoolEntriesInstance()->__toString());
+
                /*
                 * Now we need to choose again. It is whether we are speaking with a hub
                 * or with a client. So just handle it over to all listeners in this
                 * pool.
                 */
-               foreach ($poolInstance->getPoolEntriesInstance()->getArrayFromGroup($protocolName) as $listenerInstance) {
+               foreach ($poolInstance->getPoolEntriesInstance()->getArrayFromList($protocolName) as $listenerInstance) {
                        // Debug output
-                       //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-DISCOVERY[' . __METHOD__ . ':' . __LINE__ . ']: protocolName=' . $protocolName . ',listenerInstance=' . $listenerInstance->__toString());
+                       /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-DISCOVERY[' . __METHOD__ . ':' . __LINE__ . ']: protocolName=' . $protocolName . ',listenerInstance[' . gettype($listenerInstance) . ']=' . $listenerInstance);
+
+                       // Make sure the instance is valid
+                       assert($listenerInstance instanceof Listenable);
 
                        // Does the listener want that package?
                        if ($listenerInstance->ifListenerAcceptsPackageData($packageData)) {
@@ -121,7 +130,6 @@ class PackageSocketDiscovery extends BaseRecipientDiscovery implements Discovera
                        // Not valid, throw exception
                        throw new InvalidUnlException(array($this, $protocolInstance, $packageData), BaseHubSystem::EXCEPTION_INVALID_UNL);
                } // END - if
-               die(__METHOD__ . ':protocolInstance=' . $protocolInstance . ',packageData=' . print_r($packageData, TRUE));
 
                // Get the listener instance
                $listenerInstance = $this->discoverListenerInstance($protocolInstance, $packageData);