]> git.mxchange.org Git - hub.git/blobdiff - application/hub/main/discovery/package/class_PackageRecipientDiscovery.php
Added line numbers to debug lines as this will become the 'norm'
[hub.git] / application / hub / main / discovery / package / class_PackageRecipientDiscovery.php
index 5567d36ed280b68c6afa7794e2f4c7aa38f5bc76..ce5d075a76a04a4a8ca3e470b6705f42806c115c 100644 (file)
@@ -46,7 +46,7 @@ class PackageRecipientDiscovery extends BaseHubDiscovery implements Discoverable
                $discoveryInstance->setListInstance($listInstance);
 
                // Output debug message
-               self::createDebugInstance(__CLASS__)->debugOutput('RECIPIENT-DISCOVERY: Initialized.');
+               self::createDebugInstance(__CLASS__)->debugOutput('RECIPIENT-DISCOVERY[' . __LINE__ . ']: Initialized.');
 
                // Return the prepared instance
                return $discoveryInstance;
@@ -59,6 +59,9 @@ class PackageRecipientDiscovery extends BaseHubDiscovery implements Discoverable
         * @return      void
         */
        public function discoverRecipients (array $packageData) {
+               // This must be available
+               assert(isset($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT]));
+
                // First try out the direct recipient (session id)
                try {
                        // Get instance (should not break)
@@ -73,7 +76,7 @@ class PackageRecipientDiscovery extends BaseHubDiscovery implements Discoverable
                                $recipientInstance = ObjectFactory::createObjectByConfiguredName(strtolower($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT]) . '_recipient_class');
 
                                // And try to solve again
-                               $recipientInstance->resolveRecipient('', $this->getListInstance());
+                               $recipientInstance->resolveRecipient($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT], $this->getListInstance());
                        } catch (FrameworkException $e) {
                                // Could not find class, what ever failed
                                $this->debugInstance($e->getMessage());
@@ -90,6 +93,9 @@ class PackageRecipientDiscovery extends BaseHubDiscovery implements Discoverable
         * @todo        The if() does only check for TCP, not UDP, e.g. try to get a $handlerInstance here
         */
        public function discoverRawRecipients (array $decodedData) {
+               // This must be available
+               assert(isset($decodedData[NetworkPackage::PACKAGE_DATA_RECIPIENT]));
+
                // First clear all recipients
                $this->clearRecipients();
 
@@ -105,10 +111,10 @@ class PackageRecipientDiscovery extends BaseHubDiscovery implements Discoverable
                         */
 
                        // Debug output (may flood)
-                       /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('RECIPIENT-DISCOVERY: Recipient ' . $recipient[0] . ' matches own ip (' .  HubTools::determineOwnExternalIp() . ' or ' . $this->getConfigInstance()->getServerAddress() . ')');
+                       /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('RECIPIENT-DISCOVERY[' . __LINE__ . ']: Recipient ' . $recipient[0] . ' matches own ip (' .  HubTools::determineOwnExternalIp() . ' or ' . $this->getConfigInstance()->getServerAddress() . ')');
                } else {
                        // Debug output (may flood)
-                       /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('RECIPIENT-DISCOVERY: Recipient ' . $recipient[0] . ' is different than own external ip (' .  HubTools::determineOwnExternalIp() . ') nor internal ip (' . $this->getConfigInstance()->getServerAddress() . '), need to forward (not yet implemented)!');
+                       /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('RECIPIENT-DISCOVERY[' . __LINE__ . ']: Recipient ' . $recipient[0] . ' is different than own external ip (' .  HubTools::determineOwnExternalIp() . ') nor internal ip (' . $this->getConfigInstance()->getServerAddress() . '), need to forward (not yet implemented)!');
 
                        // This package is to be delivered to someone else, so add it
                        $this->getListInstance()->addEntry('ip_port', $decodedData[NetworkPackage::PACKAGE_DATA_RECIPIENT]);