]> git.mxchange.org Git - hub.git/commitdiff
Added missing classes.
authorRoland Haeder <roland@mxchange.org>
Tue, 11 Feb 2014 21:39:38 +0000 (22:39 +0100)
committerRoland Haeder <roland@mxchange.org>
Tue, 11 Feb 2014 21:39:38 +0000 (22:39 +0100)
Signed-off-by: Roland Haeder <roland@mxchange.org>
application/hub/config.php
application/hub/interfaces/recipient/class_Recipient.php
application/hub/main/discovery/package/class_PackageRecipientDiscovery.php
application/hub/main/recipient/dht/class_DhtRecipient.php
application/hub/main/recipient/direct/class_DirectRecipient.php
application/hub/main/recipient/self/class_SelfRecipient.php
application/hub/main/recipient/upper/class_UpperRecipient.php

index 7f734fe38e94fbe1c5b4bda8b225f6ee9273697f..bd8f3a3b54019c8f1e93d5dd107391e7f6ea2397 100644 (file)
@@ -1,4 +1,3 @@
-<?php
 /**
  * Configuration entries for this application only
  *
index d5205b6c584bf0671e5f1f1a6cb450b8cd7ae305..2a6c03196c1bec468d913e83c2bbd7c68ef97602 100644 (file)
@@ -28,10 +28,11 @@ interface Recipient extends FrameworkInterface {
         *
         * @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
         */
-       function resolveRecipient ($recipient, Listable $listInstance);
+       function resolveRecipient ($recipient, Listable $listInstance, array $packageData);
 }
 
 // [EOF]
index bea97ed0687249290820f821ec4f3be39bd573b7..c468e3617a9a0a8712afa17940f176549ad00af6 100644 (file)
@@ -69,7 +69,7 @@ class PackageRecipientDiscovery extends BaseHubDiscovery implements Discoverable
                        $recipientInstance = ObjectFactory::createObjectByConfiguredName('direct_recipient_class');
 
                        // Try to solve it
-                       $recipientInstance->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());
index ffdaeba8cb5e9e384dad856278aa3d492ad17902..2e32f8158f1ad9ac1b772f8a222439b1ab139061 100644 (file)
@@ -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);
        }
 }
index d225fa5cbdb7803d7a0a5494f213f99d6da28259..a34ac747162791798dd2c9909bb535285355da99 100644 (file)
@@ -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);
 
index e66a2f4aa086a67480d059740a98944289d262d4..efedc12835962b062bc174fddc34e531f738d76b 100644 (file)
@@ -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);
index bea54b2d6706ba9b06e4a4e2eb8471c551add3f1..593ef5206355b38d4d7082cb4932d23d31caa7db 100644 (file)
@@ -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);