- // We do some rudimentary checks but this might be a bit ugly
- switch ($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT]) {
- // All upper hubs, these are currently the bootstrap nodes and later on prepended list-nodes
- case NetworkPackage::NETWORK_TARGET_UPPER_HUBS:
- // Get all bootstrap nodes
- foreach (explode(BaseHubSystem::BOOTSTRAP_NODES_SEPARATOR, $this->getConfigInstance()->getConfigEntry('hub_bootstrap_nodes')) as $node) {
- // Debug message
- /* DEBUG: */ $this->debugOutput('DISCOVERY: Adding node ' . $node . ' as recipient.');
-
- // Add the entry
- $this->getListInstance()->addEntry('ip_port', $node);
- } // END - foreach
- break;
-
- // The target 'self' is always the external IP address!
- case NetworkPackage::NETWORK_TARGET_SELF:
- // Determine IP or 'external_ip' if set
- $ip = HubTools::determineOwnExternalIp();
-
- // Get port and add it
- $ipPort = $ip . ':' . $this->getConfigInstance()->getConfigEntry('node_' . $this->determineProtocolByPackageData($packageData) . '_listen_port');
-
- // Add it to the list
- $this->getListInstance()->addEntry('ip_port', $ipPort);
- break;
-
- // This may be a direct recipient (node's session id)
- default:
- $this->partialStub('Please add code handling recipients ' . $packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT]);
- break;
- } // END - switch
+ // This must be available
+ assert($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT]);
+
+ // First try out the direct recipient (session id)
+ try {
+ // Get instance (should not break)
+ $recipientInstance = ObjectFactory::createObjectByConfiguredName('direct_recipient_class');
+
+ // Try to solve it
+ $recipientInstance->resolveRecipient($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT], $this->getListInstance());
+ } catch (FrameworkException $e) {
+ // Didn't work, so try the non-generic, depending recipient field itself (this may fail)
+ try {
+ // Try to find the right class
+ $recipientInstance = ObjectFactory::createObjectByConfiguredName(strtolower($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT]) . '_recipient_class');
+
+ // And try to solve again
+ $recipientInstance->resolveRecipient('', $this->getListInstance());
+ } catch (FrameworkException $e) {
+ // Could not find class, what ever failed
+ $this->debugInstance($e->getMessage());
+ }
+ }