return $searchInstance;
}
- /**
- * Getter for result instance for unpublished entries
- *
- * @return $unpublishedEntriesInstance Result instance
- */
- public final function getUnpublishedEntriesInstance () {
- return $this->unpublishedEntriesInstance;
- }
-
/**
* Prepares a "local" instance of a StoreableCriteria class with all node
* data for insert/update queries. This data set contains data from *this*
return $dataSetInstance;
}
+ /**
+ * Getter for result instance for unpublished entries
+ *
+ * @return $unpublishedEntriesInstance Result instance
+ */
+ public final function getUnpublishedEntriesInstance () {
+ return $this->unpublishedEntriesInstance;
+ }
+
/**
* Checks whether the local (*this*) node is registered in the DHT by
* checking if the external address is found.
if ($helperInstance->getStateInstance() instanceof PeerStateable && $helperInstance->getPrintableState() !== $socketInstance->translateLastSocketErrorCodeToName()) {
// Resolve the peer's state (but ignore return value)
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-SOCKET-DISCOVERY: Going to resolve socket from peer state and given package data ...');
- PeerStateResolver::resolveStateByPackage($helperInstance, $packageInstance, $socketInstance);
+ PeerStateResolver::createStateByPackageInstance($helperInstance, $packageInstance, $socketInstance);
}
} catch (InvalidSocketException $e) {
// This cannot be fixed, so log it away
*/
public final function __toString () {
// Class name representation
- $class = self::getConnectionClassNameFromSocket($this->getSocketInstance(), parent::__toString());
+ $class = $this->getConnectionClassNameFromSocket();
// Return it
return $class;
}
- /**
- * Setter for isInitialized
- *
- * @param $isInitialized Name of used protocol in this connection
- * @return void
- */
- protected final function setIsInitialized ($isInitialized) {
- $this->isInitialized = $isInitialized;
- }
-
- /**
- * Getter for isInitialized (NOTE: no 'get' prefix for boolean attributes!)
- *
- * @return $isInitialized Name of used protocol in this connection
- */
- protected final function isInitialized () {
- return $this->isInitialized;
- }
-
/**
* Static "getter" for this connection class' name
*
- * @param $socketInstance An instance of a StorableSocket class
- * @param $className Name of calling class
* @return $class Expanded class name
*/
- public static function getConnectionClassNameFromSocket (StorableSocket $socketInstance, $className) {
+ private function getConnectionClassNameFromSocket () {
// Get recipient address/port
- $recipientAddress = $socketInstance->getSocketRecipientAddress();
- $recipientPort = $socketInstance->getSocketRecipientPort();
+ $recipientAddress = $this->getSocketInstance()->getSocketRecipientAddress();
+ $recipientPort = $this->getSocketInstance()->getSocketRecipientPort();
// Construct it
- $class = sprintf('%s:%d:%s', $recipientAddress, $recipientPort, $className);
+ $class = sprintf('%s:%d:%s', $recipientAddress, $recipientPort, parent::__toString());
// ... and return it
return $class;
return $rawData;
}
+ /**
+ * Setter for isInitialized
+ *
+ * @param $isInitialized Name of used protocol in this connection
+ * @return void
+ */
+ protected final function setIsInitialized ($isInitialized) {
+ $this->isInitialized = $isInitialized;
+ }
+
+ /**
+ * Getter for isInitialized (NOTE: no 'get' prefix for boolean attributes!)
+ *
+ * @return $isInitialized Name of used protocol in this connection
+ */
+ protected final function isInitialized () {
+ return $this->isInitialized;
+ }
+
/**
* "Accept" a visitor by simply calling it back
*
* @throws InvalidSocketException If socketResource, even from getSocketResource() is no valid resource
* @todo ~30% done
*/
- public static function resolveStateByPackage (ConnectionHelper $helperInstance, DeliverablePackage $packageInstance, StorableSocket $socketInstance) {
+ public static function createStateByPackageInstance (ConnectionHelper $helperInstance, DeliverablePackage $packageInstance, StorableSocket $socketInstance) {
// Get temporary resolver instance
$resolverInstance = self::createPeerStateResolver();
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
interface NodeDhtWrapper extends DatabaseWrapper {
- /**
- * Static getter for an array of all DHT database entries
- *
- * @return $elements All elements for the DHT dabase
- */
- static function getAllElements ();
-
/**
* Getter for result instance for unpublished entries
*
function registerLocalNode ();
/**
- * Updates local (*this*) node data in DHT, this is but not limited to the
+ * Updates local (*this*) node's data in DHT, this is but not limited to the
* session id, ip number (and/or hostname) and port number.
*
* @return void
function initEntryPublication ();
/**
- * Removes non-data from given array.
+ * Removes non-public data from given array.
*
- * @param $data An array with possible non-data that needs to be removed.
- * @return $data A cleaned up array with only data.
+ * @param $data An array with possible non-public data that needs to be removed.
+ * @return $data A cleaned up array with only public data.
*/
function removeNonPublicDataFromArray(array $data);
/**
- * Find recipients for given package data and returns it as a result instance
+ * Find recipients for given package data and exclude the sender
*
* @param $packageInstance An instance of a DeliverablePackage class
- * @return $recipients An indexed array with DHT recipients
+ * @return $recipients An indexed array with DHT recipients
*/
function getResultFromExcludedSender (DeliverablePackage $packageInstance);
*/
function doShutdown ();
- /**
- * Static "getter" for this connection class' name
- *
- * @param $socketInstance An instance of a StorableSocket class
- * @param $className Name of calling class
- * @return $class Expanded class name
- */
- static function getConnectionClassNameFromSocket (StorableSocket $socketInstance, $className);
-
/**
* Getter for shuttedDown
*
// Own namespace
namespace Org\Shipsimu\Hub\Resolver\State;
-// Import application-specific stuff
-use Org\Shipsimu\Hub\Container\Socket\StorableSocket;
-use Org\Shipsimu\Hub\Helper\Connection\ConnectionHelper;
-use Org\Shipsimu\Hub\Network\Package\DeliverablePackage;
-
// Import framework stuff
use Org\Mxchange\CoreFramework\Resolver\Resolver;
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
interface StateResolver extends Resolver {
- /**
- * Returns an state instance for a given package raw data and socket resource
- *
- * @param $helperInstance An instance of a ConnectionHelper class
- * @param $packageInstance An instance of a DeliverablePackage class
- * @param $socketInstance An instance of a StorableSocket class
- * @return $stateInstance An instance of a PeerStateable class
- */
- static function resolveStateByPackage (ConnectionHelper $helperInstance, DeliverablePackage $packageInstance, StorableSocket $socketInstance);
-
/**
* Checks whether the given state is valid
*