*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
* @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, array $packageData) {
+ // Debug message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-RECIPIENT[' . __METHOD__ . ':' . __LINE__ . ']: recipient=' . $recipient . ' - CALLED!');
+
// 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
// "Discover" recipients by given package data
$recipients = $discoverInstance->resolveRecipientsByPackageData($packageData);
- $this->partialStub('Please implement this method. recipient=' . $recipient);
+ // Now "walk" through all elements and add them to the list
+ foreach ($recipients as $recipient) {
+ // These array elements must exist for this loop:
+ assert(!empty($recipient[NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_EXTERNAL_IP]));
+ assert(!empty($recipient[NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_LISTEN_PORT]));
+
+ // Put ip and port both together
+ $ipPort = $recipient[NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_EXTERNAL_IP] . ':' . $recipient[NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_LISTEN_PORT];
+
+ // Add it to the list
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-RECIPIENT[' . __METHOD__ . ':' . __LINE__ . ']: Calling listInstance->addEntry(' . $ipPort . ') ...');
+ $listInstance->addEntry('ip_port', $ipPort);
+ } // END - foreach
+
+ // Debug message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-RECIPIENT[' . __METHOD__ . ':' . __LINE__ . ']: recipient=' . $recipient . ' - EXIT!');
}
}