<?php
/**
- * A PackageRecipient discovery class
+ * A general node discovery class
*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
protected function __construct ($className) {
// Call parent constructor
parent::__construct($className);
-
- /*
- * Get recipients list instance and set it here for all discovery
- * implementations.
- */
- $listInstance = RecipientListFactory::createRecipientListInstance();
- $this->setListInstance($listInstance);
- }
-
- /**
- * Determines the protoctol name
- *
- * @param $packageData Valid package data
- * @return $protocolInstance An instance of a ProtocolHandler class
- */
- protected function determineProtocolByPackageData (array $packageData) {
- // First we need a tags instance
- $tagsInstance = PackageTagsFactory::createPackageTagsInstance();
-
- /*
- * We need to decide here which socket (TCP or UDP) should be used for
- * the actual data transmission. In this process we will find out if
- * the recipient of this package has already a known (registered) socket
- * and if so we can re-use it. If there is no socket registered, we try
- * to make a new connection to the given universal node locator.
- */
- $protocolInstance = $tagsInstance->chooseProtocolFromPackageData($packageData);
-
- // Return it
- return $protocolInstance;
- }
-
- /**
- * "Getter" for recipient iterator
- *
- * @return$iteratorInstance An instance of a Iterateable object
- */
- public final function getIterator () {
- // Get iterator from it
- $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 final function clearRecipients () {
- // Clear the list
- $this->getListInstance()->clearList();
- }
-
- /**
- * Checks whether the recipient list is empty
- *
- * @return $isEmpty Whether the recipient list is empty
- */
- public final function isRecipientListEmpty () {
- // Check it ...
- $isEmpty = ($this->getListInstance()->count() == 0);
-
- // Return it
- return $isEmpty;
}
}