From 8900cef1465393b15da7a8f80cc19de7bd052dbc Mon Sep 17 00:00:00 2001 From: Roland Haeder Date: Tue, 11 Feb 2014 22:39:38 +0100 Subject: [PATCH] Added missing classes. Signed-off-by: Roland Haeder --- application/hub/config.php | 1 - .../hub/interfaces/recipient/class_Recipient.php | 3 ++- .../package/class_PackageRecipientDiscovery.php | 4 ++-- .../main/recipient/dht/class_DhtRecipient.php | 16 +++++++++++++--- .../recipient/direct/class_DirectRecipient.php | 3 ++- .../main/recipient/self/class_SelfRecipient.php | 3 ++- .../recipient/upper/class_UpperRecipient.php | 3 ++- 7 files changed, 23 insertions(+), 10 deletions(-) diff --git a/application/hub/config.php b/application/hub/config.php index 7f734fe38..bd8f3a3b5 100644 --- a/application/hub/config.php +++ b/application/hub/config.php @@ -1,4 +1,3 @@ -resolveRecipient($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT], $this->getListInstance()); + $recipientInstance->resolveRecipient($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT], $this->getListInstance(), $packageData); } catch (FrameworkException $e) { // Didn't work, so try the non-generic, depending recipient field itself (this may fail) try { @@ -77,7 +77,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($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT], $this->getListInstance()); + $recipientInstance->resolveRecipient($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT], $this->getListInstance(), $packageData); } catch (FrameworkException $e) { // Could not find class, what ever failed $this->debugInstance($e->getMessage()); diff --git a/application/hub/main/recipient/dht/class_DhtRecipient.php b/application/hub/main/recipient/dht/class_DhtRecipient.php index ffdaeba8c..2e32f8158 100644 --- a/application/hub/main/recipient/dht/class_DhtRecipient.php +++ b/application/hub/main/recipient/dht/class_DhtRecipient.php @@ -47,18 +47,28 @@ class DhtRecipient extends BaseRecipient implements Recipient { /** * Tries to resolve given recipient into session ids or ip:port combination - * depending on implementation (hint: Template Method Pattern) + * depending on implementation (hint: Template Method Pattern). This + * implementation will add more than one recipient to the list as a DHT is + * distributed and the package might go to more than one recipient. * * @param $recipient Recipient to resolve (e.g. could be a virtual recipient or direct session id) * @param $listInstance An instance of a Listable class - * @return $resolved Resolved recipient or VOID if only the set list has been filled + * @param $packageData Valid package data array + * @return void * @throws FrameworkException Could throw different exceptions depending on implementation * @todo 0% done */ - public function resolveRecipient ($recipient, Listable $listInstance) { + public function resolveRecipient ($recipient, Listable $listInstance, array $packageData) { // Make sure the recipient is valid //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-RECIPIENT: recipient=' . $recipient); assert($recipient == NetworkPackage::NETWORK_TARGET_DHT); + + // Get recipient discovery instance + $discoverInstance = ObjectFactory::createObjectByConfiguredName('dht_recipient_discovery_class'); + + // "Discover" recipients by given package data + $recipients = $discoverInstance->resolveRecipientsByPackageData($packageData); + $this->partialStub('Please implement this method. recipient=' . $recipient); } } diff --git a/application/hub/main/recipient/direct/class_DirectRecipient.php b/application/hub/main/recipient/direct/class_DirectRecipient.php index d225fa5cb..a34ac7471 100644 --- a/application/hub/main/recipient/direct/class_DirectRecipient.php +++ b/application/hub/main/recipient/direct/class_DirectRecipient.php @@ -51,10 +51,11 @@ class DirectRecipient extends BaseRecipient implements Recipient { * * @param $recipient Recipient to resolve (e.g. could be a virtual recipient or direct session id) * @param $listInstance An instance of a Listable class + * @param $packageData Valid package data array * @return $resolved Resolved recipient or VOID if only the set list has been filled * @throws FrameworkException Could throw different exceptions depending on implementation */ - public function resolveRecipient ($recipient, Listable $listInstance = NULL) { + public function resolveRecipient ($recipient, Listable $listInstance, array $packageData) { // Debug message //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DIRECT-RECIPIENT: recipient=' . $recipient); diff --git a/application/hub/main/recipient/self/class_SelfRecipient.php b/application/hub/main/recipient/self/class_SelfRecipient.php index e66a2f4aa..efedc1283 100644 --- a/application/hub/main/recipient/self/class_SelfRecipient.php +++ b/application/hub/main/recipient/self/class_SelfRecipient.php @@ -51,10 +51,11 @@ class SelfRecipient extends BaseRecipient implements Recipient { * * @param $recipient Recipient to resolve (e.g. could be a virtual recipient or direct session id) * @param $listInstance An instance of a Listable class + * @param $packageData Valid package data array * @return $resolved Resolved recipient or VOID if only the set list has been filled * @throws FrameworkException Could throw different exceptions depending on implementation */ - public function resolveRecipient ($recipient, Listable $listInstance) { + public function resolveRecipient ($recipient, Listable $listInstance, array $packageData) { // Make sure the recipient is valid //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SELF-RECIPIENT: recipient=' . $recipient); assert($recipient == NetworkPackage::NETWORK_TARGET_SELF); diff --git a/application/hub/main/recipient/upper/class_UpperRecipient.php b/application/hub/main/recipient/upper/class_UpperRecipient.php index bea54b2d6..593ef5206 100644 --- a/application/hub/main/recipient/upper/class_UpperRecipient.php +++ b/application/hub/main/recipient/upper/class_UpperRecipient.php @@ -51,10 +51,11 @@ class UpperRecipient extends BaseRecipient implements Recipient { * * @param $recipient Recipient to resolve (e.g. could be a virtual recipient or direct session id) * @param $listInstance An instance of a Listable class + * @param $packageData Valid package data array * @return $resolved Resolved recipient or VOID if only the set list has been filled * @throws FrameworkException Could throw different exceptions depending on implementation */ - public function resolveRecipient ($recipient, Listable $listInstance) { + public function resolveRecipient ($recipient, Listable $listInstance, array $packageData) { // Make sure the recipient is valid //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('UPPER-RECIPIENT: recipient=' . $recipient); assert($recipient == NetworkPackage::NETWORK_TARGET_UPPER); -- 2.39.5