// Output debug message
$discoveryInstance->debugOutput('RECIPIENT-DISCOVERY: Initialized.');
+ // Get recipients list instance and set it
+ $listInstance = RecipientListFactory::createRecipientListInstance();
+ $discoveryInstance->setListInstance($listInstance);
+
// Return the prepared instance
return $discoveryInstance;
}
* @return void
*/
public function discoverRecipients (array $packageData) {
- // Get recipients list instance
- $listInstance = RecipientListFactory::createRecipientListInstance();
-
// 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
/* DEBUG: */ $this->debugOutput('DISCOVERY: Adding node ' . $node . ' as recipient.');
// Add the entry
- $listInstance->addEntry('ip_port', $node);
+ $this->getListInstance()->addEntry('ip_port', $node);
} // END - foreach
break;
$ipPort = $ip . ':' . $this->getConfigInstance()->getConfigEntry('node_' . $this->determineProtocolByPackageData($packageData) . '_listen_port');
// Add it to the list
- $listInstance->addEntry('ip_port', $ipPort);
+ $this->getListInstance()->addEntry('ip_port', $ipPort);
break;
// This may be a direct recipient (node's session id)
* @return $iteratorInstance An instance of a Iterateable object
*/
public function getIterator () {
- // Get list instance
- $listInstance = RecipientListFactory::createRecipientListInstance();
-
// Get iterator from it
- $iteratorInstance = $listInstance->getIterator();
+ $iteratorInstance = $this->getListInstance()->getIterator();
// Return it
return $iteratorInstance;
}
+
+ /**
+ * Clears all recipients for e.g. another package to deliver. This method
+ * simply clears the inner list instance.
+ *
+ * @return void
+ */
+ public function clearRecipients () {
+ // Clear the list
+ $this->getListInstance()->clearList();
+ }
}
// [EOF]