From 8c67edd3d87a4d35ce8762e15e44d12c39fcd9a8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Thu, 29 Oct 2020 18:46:06 +0100 Subject: [PATCH] WIP-continued: - rewrites towards DeliverableMessage (not Package) interface MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- .../chains/class_PackageFilterChain.php | 5 ++-- ...odeDistributedHashTableDatabaseWrapper.php | 9 ++++--- .../classes/dht/node/class_NodeDhtFacade.php | 22 +++++++--------- .../classes/filter/class_BaseHubFilter.php | 9 ++----- ...ass_PackageAnnouncementAnswerTagFilter.php | 9 +++---- ...ass_PackageDhtBootstrapAnswerTagFilter.php | 9 +++---- ..._PackageRequestNodeListAnswerTagFilter.php | 9 +++---- .../class_PackageAnnouncementTagFilter.php | 9 +++---- .../class_PackageDhtBootstrapTagFilter.php | 9 +++---- .../class_PackageRequestNodeListTagFilter.php | 9 +++---- .../class_PackageSelfConnectTagFilter.php | 5 ++-- ...lass_NodeAnnouncementAnswerOkayHandler.php | 13 +++++----- ...class_RequestNodeListAnswerOkayHandler.php | 16 ++++++------ .../handler/data/class_BaseDataHandler.php | 21 ++++++++-------- .../class_NodeMessageAnnouncementHandler.php | 21 ++++++++-------- ...s_NodeMessageAnnouncementAnswerHandler.php | 21 ++++++++-------- ...s_NodeMessageDhtBootstrapAnswerHandler.php | 15 +++++------ ...odeMessageRequestNodeListAnswerHandler.php | 19 +++++++------- .../class_BaseMessageHandler.php | 9 ++++--- .../class_NodeMessageDhtBootstrapHandler.php | 25 ++++++++----------- ...lass_NodeMessageRequestNodeListHandler.php | 21 ++++++++-------- .../class_NodeMessageSelfConnectHandler.php | 13 +++++----- .../package/class_NetworkPackageHandler.php | 20 +++++---------- ...ss_NodeAnnouncementMessageAnswerHelper.php | 5 ++-- .../node/answer/class_BaseHubAnswerHelper.php | 17 +++++++------ ...ss_NodeDhtBootstrapMessageAnswerHelper.php | 5 ++-- ...NodeRequestNodeListMessageAnswerHelper.php | 5 ++-- .../hub/classes/nodes/class_BaseHubNode.php | 8 +++--- .../frontend/class_NodeDhtWrapper.php | 5 ++-- .../node/class_DistributableNode.php | 5 ++-- .../filter/class_FilterablePackage.php | 5 ++-- .../class_HandleableAnswerStatus.php | 1 + .../message-types/class_HandleableMessage.php | 5 ++-- .../hub/interfaces/nodes/class_Node.php | 1 + .../interfaces/receiver/class_Receivable.php | 3 ++- 35 files changed, 185 insertions(+), 198 deletions(-) diff --git a/application/hub/classes/chains/class_PackageFilterChain.php b/application/hub/classes/chains/class_PackageFilterChain.php index eda0e0ab9..6b02d776b 100644 --- a/application/hub/classes/chains/class_PackageFilterChain.php +++ b/application/hub/classes/chains/class_PackageFilterChain.php @@ -3,6 +3,7 @@ namespace Org\Shipsimu\Hub\FilterChain\Package; // Import application-specific stuff +use Org\Shipsimu\Hub\Network\Message\DeliverableMessage; use Org\Shipsimu\Hub\Network\Receive\Receivable; // Import framework stuff @@ -57,7 +58,7 @@ class PackageFilterChain extends FilterChain { /** * Processes the given raw message content through all filters * - * @param $messageData Raw message data array + * @param $messageInstance An instance of a DeliverableMessage class * @param $packageInstance An instance of a Receivable class * @return void * @todo This may be slow if a message with a lot tags arrived @@ -67,7 +68,7 @@ class PackageFilterChain extends FilterChain { foreach ($this->getFilters() as $filterInstance) { // Try to process it try { - $filterInstance->processMessage($messageData, $packageInstance); + $filterInstance->processMessage($messageInstance, $packageInstance); } catch (FilterChainException $e) { // This exception can be thrown to just skip any further processing self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('Failed to execute lase filter ' . $filterInstance->__toString() . ': ' . $e->getMessage()); diff --git a/application/hub/classes/database/frontend/node/class_NodeDistributedHashTableDatabaseWrapper.php b/application/hub/classes/database/frontend/node/class_NodeDistributedHashTableDatabaseWrapper.php index cc4b9f4a9..0fc3de48d 100644 --- a/application/hub/classes/database/frontend/node/class_NodeDistributedHashTableDatabaseWrapper.php +++ b/application/hub/classes/database/frontend/node/class_NodeDistributedHashTableDatabaseWrapper.php @@ -6,6 +6,7 @@ namespace Org\Shipsimu\Hub\Database\Frontend\Node\Dht; use Org\Shipsimu\Hub\Database\Frontend\BaseHubDatabaseWrapper; use Org\Shipsimu\Hub\Factory\Node\NodeObjectFactory; use Org\Shipsimu\Hub\Locator\Node\LocateableNode; +use Org\Shipsimu\Hub\Network\Message\DeliverableMessage; use Org\Shipsimu\Hub\Network\Package\DeliverablePackage; use Org\Shipsimu\Hub\Node\BaseHubNode; @@ -351,7 +352,7 @@ class NodeDistributedHashTableDatabaseWrapper extends BaseHubDatabaseWrapper imp /** * Registeres a node by given message data. * - * @param $messageData An array of all message data + * @param $messageInstance An instance of a DeliverableMessage class * @param $handlerInstance An instance of a HandleableDataSet class * @return void */ @@ -366,7 +367,7 @@ class NodeDistributedHashTableDatabaseWrapper extends BaseHubDatabaseWrapper imp $dataSetInstance->setUniqueKey(self::DB_COLUMN_SESSION_ID); // Add all array elements - $handlerInstance->addArrayToDataSet($dataSetInstance, $messageData); + $handlerInstance->addArrayToDataSet($dataSetInstance, $messageInstance); // Remove 'node_list' $dataSetInstance->unsetCriteria(self::DB_COLUMN_NODE_LIST); @@ -381,7 +382,7 @@ class NodeDistributedHashTableDatabaseWrapper extends BaseHubDatabaseWrapper imp /** * Updates an existing entry in node list * - * @param $messageData An array of all message data + * @param $messageInstance An instance of a DeliverableMessage class * @param $handlerInstance An instance of a HandleableDataSet class * @param $searchInstance An instance of LocalSearchCriteria class * @return void @@ -400,7 +401,7 @@ class NodeDistributedHashTableDatabaseWrapper extends BaseHubDatabaseWrapper imp $dataSetInstance->setUniqueKey(self::DB_COLUMN_SESSION_ID); // Add all array elements - $handlerInstance->addArrayToDataSet($dataSetInstance, $messageData); + $handlerInstance->addArrayToDataSet($dataSetInstance, $messageInstance); // Remove 'node_list' $dataSetInstance->unsetCriteria(self::DB_COLUMN_NODE_LIST); diff --git a/application/hub/classes/dht/node/class_NodeDhtFacade.php b/application/hub/classes/dht/node/class_NodeDhtFacade.php index 9f7391435..741db76e9 100644 --- a/application/hub/classes/dht/node/class_NodeDhtFacade.php +++ b/application/hub/classes/dht/node/class_NodeDhtFacade.php @@ -7,6 +7,7 @@ use Org\Shipsimu\Hub\Dht\BaseDht; use Org\Shipsimu\Hub\Dht\Distributable; use Org\Shipsimu\Hub\Generic\BaseHubSystem; use Org\Shipsimu\Hub\Locator\Node\LocateableNode; +use Org\Shipsimu\Hub\Network\Message\DeliverableMessage; use Org\Shipsimu\Hub\Network\Package\DeliverablePackage; // Import framework stuff @@ -231,7 +232,7 @@ class NodeDhtFacade extends BaseDht implements DistributableNode, Registerable { * - external-address (hostname or IP number) * - listen-port (TCP/UDP listen port for inbound connections) * - * @param $messageArray An array with all minimum message data + * @param $messageInstance An instance of a DeliverableMessage class * @param $handlerInstance An instance of a HandleableDataSet class * @param $forceUpdate Optionally force update, don't register (default: register if not found) * @return void @@ -239,7 +240,7 @@ class NodeDhtFacade extends BaseDht implements DistributableNode, Registerable { */ public function registerNodeByMessageInstance (DeliverableMessage $messageInstance, HandleableDataSet $handlerInstance, $forceUpdate = FALSE) { // Get a search criteria class - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NODE-DHT-FACADE: state=%s,messageData()=%d,handlerInstance=%s,forceUpdate=%d - CALLED', $this->getPrintableState(), count($messageData), $handlerInstance->__toString(), intval($forceUpdate))); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NODE-DHT-FACADE: state=%s,messageInstance=%s,handlerInstance=%s,forceUpdate=%d - CALLED', $this->getPrintableState(), $messageInstance->__toString(), $handlerInstance->__toString(), intval($forceUpdate))); $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class'); // Search for the node's session id and external address/hostname + TCP/UDP listen port @@ -266,16 +267,16 @@ class NodeDhtFacade extends BaseDht implements DistributableNode, Registerable { // Is there already an entry? if ($resultInstance->valid()) { // Entry found, so update it - $this->getWrapperInstance()->updateNodeByMessageInstance($messageData, $handlerInstance, $searchInstance); + $this->getWrapperInstance()->updateNodeByMessageInstance($messageInstance, $handlerInstance, $searchInstance); } elseif ($forceUpdate === FALSE) { // Nothing found, so register it - $this->getWrapperInstance()->registerNodeByMessageInstance($messageData, $handlerInstance); + $this->getWrapperInstance()->registerNodeByMessageInstance($messageInstance, $handlerInstance); } else { /* * Do not register non-existent nodes here. This is maybe fatal, * caused by "stolen" session id and/or not matching address. */ - throw new NodeSessionIdVerficationException(array($this, $messageData), BaseHubSystem::EXCEPTION_NODE_SESSION_ID_NOT_VERIFYING); + throw new NodeSessionIdVerficationException(array($this, $messageInstance), BaseHubSystem::EXCEPTION_NODE_SESSION_ID_NOT_VERIFYING); } // Save last exception @@ -286,7 +287,7 @@ class NodeDhtFacade extends BaseDht implements DistributableNode, Registerable { * Queries the local DHT data(base) for a node list with all supported * object types except the node by given session id. * - * @param $messageData An array with message data from a node_list request + * @param $messageInstance An instance of a DeliverableMessage class * @param $handlerInstance An instance of a HandleableDataSet class * @param $excludeKey Array key which should be excluded * @param $andKey Array of $separator-separated list of elements which all must match @@ -294,14 +295,9 @@ class NodeDhtFacade extends BaseDht implements DistributableNode, Registerable { * @return $nodeList An array with all found nodes */ public function queryLocalNodeListExceptByMessageInstance (DeliverableMessage $messageInstance, HandleableDataSet $handlerInstance, $excludeKey, $andKey, $separator) { - // Make sure both keys are there - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NODE-DHT-FACADE: messageData()=%d,handlerInstance=%s,excludeKey=%s,andKey=%s,separator=%s - CALLED!', count($messageData), $handlerInstance->__toString(), $excludeKey, $andKey, $separator)); - assert((isset($messageData[$excludeKey])) && (isset($messageData[$andKey]))); - - // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NODE-DHT-FACADE: state=' . $this->getPrintableState() . ',messageData=' . print_r($messageData, TRUE)); - // Get a search criteria class + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NODE-DHT-FACADE: messageInstance=%s,handlerInstance=%s,excludeKey=%s,andKey=%s,separator=%s - CALLED!', $messageInstance->__toString(), $handlerInstance->__toString(), $excludeKey, $andKey, $separator)); + /* PRINTR-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NODE-DHT-FACADE: state=%s,messageInstance=%s', $this->getPrintableState(), print_r($messageInstance, TRUE))); $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class'); // Add all keys diff --git a/application/hub/classes/filter/class_BaseHubFilter.php b/application/hub/classes/filter/class_BaseHubFilter.php index 9bd3f7acf..3eaf20163 100644 --- a/application/hub/classes/filter/class_BaseHubFilter.php +++ b/application/hub/classes/filter/class_BaseHubFilter.php @@ -4,6 +4,7 @@ namespace Org\Shipsimu\Hub\Filter; // Import application-specific stuff use Org\Shipsimu\Hub\Handler\Package\NetworkPackageHandler; +use Org\Shipsimu\Hub\Network\Message\DeliverableMessage; use Org\Shipsimu\Hub\Network\Receive\Receivable; // Import framework stuff @@ -61,18 +62,12 @@ abstract class BaseHubFilter extends BaseFilter { * well-formed * * @param $messageType Type of message - * @param $messageData Raw message data array + * @param $messageInstance An instance of a DeliverableMessage class * @param $packageInstance An instance of a Receivable class * @return void * @todo Exceptions from renderXmlContent() are currently unhandled */ protected function genericProcessMessage ($messageType, DeliverableMessage $messageInstance, Receivable $packageInstance) { - // Make sure the wanted element is there - assert(isset($messageData[NetworkPackageHandler::PACKAGE_CONTENT_MESSAGE])); - assert(isset($messageData[NetworkPackageHandler::PACKAGE_CONTENT_SENDER])); - assert(isset($messageData[NetworkPackageHandler::PACKAGE_CONTENT_HASH])); - assert(isset($messageData[NetworkPackageHandler::PACKAGE_CONTENT_TAGS])); - // Get a template instance from the factory $templateInstance = XmlTemplateEngineFactory::createXmlTemplateEngineInstance(sprintf('node_%s_template_class', $messageType)); diff --git a/application/hub/classes/filter/tags/answer/class_PackageAnnouncementAnswerTagFilter.php b/application/hub/classes/filter/tags/answer/class_PackageAnnouncementAnswerTagFilter.php index 20b3587ae..77158e470 100644 --- a/application/hub/classes/filter/tags/answer/class_PackageAnnouncementAnswerTagFilter.php +++ b/application/hub/classes/filter/tags/answer/class_PackageAnnouncementAnswerTagFilter.php @@ -5,6 +5,7 @@ namespace Org\Shipsimu\Hub\Filter\Tag\Network\Answer\Announcement; // Import application-specific stuff use Org\Shipsimu\Hub\Filter\Network\FilterablePackage; use Org\Shipsimu\Hub\Filter\Node\BaseNodeFilter; +use Org\Shipsimu\Hub\Network\Message\DeliverableMessage; use Org\Shipsimu\Hub\Network\Receive\Receivable; use Org\Shipsimu\Hub\Template\Engine\Xml\Answer\Announcement\XmlAnnouncementAnswerTemplateEngine; use Org\Shipsimu\Hub\Template\Engine\Xml\Network\Answer\BaseXmlAnswerTemplateEngine; @@ -88,13 +89,13 @@ class PackageAnnouncementAnswerTagFilter extends BaseNodeFilter implements Filte * Processes the given raw message content. The method renderXmlContent * may throw (not the method itself) several exceptions: * - * @param $messageData Raw message data array + * @param $messageInstance An instance of a DeliverableMessage class * @param $packageInstance An instance of a Receivable class * @return void */ public function processMessage (DeliverableMessage $messageInstance, Receivable $packageInstance) { // Process message in generic way - $this->genericProcessMessage('announcement_answer', $messageData, $packageInstance); + $this->genericProcessMessage('announcement_answer', $messageInstance, $packageInstance); } /** @@ -109,7 +110,5 @@ class PackageAnnouncementAnswerTagFilter extends BaseNodeFilter implements Filte // Please don't call this method throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); } -} -// [EOF] -?> +} diff --git a/application/hub/classes/filter/tags/answer/class_PackageDhtBootstrapAnswerTagFilter.php b/application/hub/classes/filter/tags/answer/class_PackageDhtBootstrapAnswerTagFilter.php index e10aec193..0adce5231 100644 --- a/application/hub/classes/filter/tags/answer/class_PackageDhtBootstrapAnswerTagFilter.php +++ b/application/hub/classes/filter/tags/answer/class_PackageDhtBootstrapAnswerTagFilter.php @@ -5,6 +5,7 @@ namespace Org\Shipsimu\Hub\Filter\Tag\Network\Answer\Dht\Bootstrap; // Import application-specific stuff use Org\Shipsimu\Hub\Filter\Network\FilterablePackage; use Org\Shipsimu\Hub\Filter\Node\BaseNodeFilter; +use Org\Shipsimu\Hub\Network\Message\DeliverableMessage; use Org\Shipsimu\Hub\Network\Receive\Receivable; use Org\Shipsimu\Hub\Template\Engine\Xml\Answer\Dht\Bootstrap\XmlDhtBootstrapAnswerTemplateEngine; use Org\Shipsimu\Hub\Template\Engine\Xml\Network\Answer\BaseXmlAnswerTemplateEngine; @@ -85,13 +86,13 @@ class PackageDhtBootstrapAnswerTagFilter extends BaseNodeFilter implements Filte * Processes the given raw message content. The method renderXmlContent * may throw (not the method itself) several exceptions: * - * @param $messageData Raw message data array + * @param $messageInstance An instance of a DeliverableMessage class * @param $packageInstance An instance of a Receivable class * @return void */ public function processMessage (DeliverableMessage $messageInstance, Receivable $packageInstance) { // Process message in generic way - $this->genericProcessMessage('dht_bootstrap_answer', $messageData, $packageInstance); + $this->genericProcessMessage('dht_bootstrap_answer', $messageInstance, $packageInstance); } /** @@ -106,7 +107,5 @@ class PackageDhtBootstrapAnswerTagFilter extends BaseNodeFilter implements Filte // Please don't call this method throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); } -} -// [EOF] -?> +} diff --git a/application/hub/classes/filter/tags/answer/class_PackageRequestNodeListAnswerTagFilter.php b/application/hub/classes/filter/tags/answer/class_PackageRequestNodeListAnswerTagFilter.php index 27d564528..cbb8932d5 100644 --- a/application/hub/classes/filter/tags/answer/class_PackageRequestNodeListAnswerTagFilter.php +++ b/application/hub/classes/filter/tags/answer/class_PackageRequestNodeListAnswerTagFilter.php @@ -5,6 +5,7 @@ namespace Org\Shipsimu\Hub\Filter\Tag\Network\Answer\Request\NodeList; // Import application-specific stuff use Org\Shipsimu\Hub\Filter\Network\FilterablePackage; use Org\Shipsimu\Hub\Filter\Node\BaseNodeFilter; +use Org\Shipsimu\Hub\Network\Message\DeliverableMessage; use Org\Shipsimu\Hub\Network\Receive\Receivable; use Org\Shipsimu\Hub\Template\Engine\Xml\Answer\Request\NodeList\XmlRequestNodeListAnswerTemplateEngine; use Org\Shipsimu\Hub\Template\Engine\Xml\Network\Answer\BaseXmlAnswerTemplateEngine; @@ -85,13 +86,13 @@ class PackageRequestNodeListAnswerTagFilter extends BaseNodeFilter implements Fi * Processes the given raw message content. The method renderXmlContent * may throw (not the method itself) several exceptions: * - * @param $messageData Raw message data array + * @param $messageInstance An instance of a DeliverableMessage class * @param $packageInstance An instance of a Receivable class * @return void */ public function processMessage (DeliverableMessage $messageInstance, Receivable $packageInstance) { // Process message in generic way - $this->genericProcessMessage('request_node_list_answer', $messageData, $packageInstance); + $this->genericProcessMessage('request_node_list_answer', $messageInstance, $packageInstance); } /** @@ -106,7 +107,5 @@ class PackageRequestNodeListAnswerTagFilter extends BaseNodeFilter implements Fi // Please don't call this method throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); } -} -// [EOF] -?> +} diff --git a/application/hub/classes/filter/tags/class_PackageAnnouncementTagFilter.php b/application/hub/classes/filter/tags/class_PackageAnnouncementTagFilter.php index a6e28e266..d832eef11 100644 --- a/application/hub/classes/filter/tags/class_PackageAnnouncementTagFilter.php +++ b/application/hub/classes/filter/tags/class_PackageAnnouncementTagFilter.php @@ -5,6 +5,7 @@ namespace Org\Shipsimu\Hub\Filter\Tag\Network\Announcement; // Import application-specific stuff use Org\Shipsimu\Hub\Filter\Network\FilterablePackage; use Org\Shipsimu\Hub\Filter\Node\BaseNodeFilter; +use Org\Shipsimu\Hub\Network\Message\DeliverableMessage; use Org\Shipsimu\Hub\Template\Engine\Xml\Announcement\XmlAnnouncementTemplateEngine; // Import framework stuff @@ -94,13 +95,13 @@ class PackageAnnouncementTagFilter extends BaseNodeFilter implements FilterableP * XmlParserException - If the XML message is damaged or not * well-formed * - * @param $messageData Raw message data array + * @param $messageInstance An instance of a DeliverableMessage class * @param $packageInstance An instance of a Receivable class * @return void */ public function processMessage (DeliverableMessage $messageInstance, Receivable $packageInstance) { // Process message generic - $this->genericProcessMessage('announcement', $messageData, $packageInstance); + $this->genericProcessMessage('announcement', $messageInstance, $packageInstance); } /** @@ -115,7 +116,5 @@ class PackageAnnouncementTagFilter extends BaseNodeFilter implements FilterableP // Please don't call this method throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); } -} -// [EOF] -?> +} diff --git a/application/hub/classes/filter/tags/class_PackageDhtBootstrapTagFilter.php b/application/hub/classes/filter/tags/class_PackageDhtBootstrapTagFilter.php index 22829a6da..966ef7a0c 100644 --- a/application/hub/classes/filter/tags/class_PackageDhtBootstrapTagFilter.php +++ b/application/hub/classes/filter/tags/class_PackageDhtBootstrapTagFilter.php @@ -5,6 +5,7 @@ namespace Org\Shipsimu\Hub\Filter\Tag\Network\Dht\Bootstrap; // Import application-specific stuff use Org\Shipsimu\Hub\Filter\Network\FilterablePackage; use Org\Shipsimu\Hub\Filter\Node\BaseNodeFilter; +use Org\Shipsimu\Hub\Network\Message\DeliverableMessage; use Org\Shipsimu\Hub\Network\Receive\Receivable; use Org\Shipsimu\Hub\Template\Engine\Xml\Dht\Bootstrap\XmlDhtBootstrapTemplateEngine; @@ -93,13 +94,13 @@ class PackageDhtBootstrapTagFilter extends BaseNodeFilter implements FilterableP * XmlParserException - If the XML message is damaged or not * well-formed * - * @param $messageData Raw message data array + * @param $messageInstance An instance of a DeliverableMessage class * @param $packageInstance An instance of a Receivable class * @return void */ public function processMessage (DeliverableMessage $messageInstance, Receivable $packageInstance) { // Process message generic - $this->genericProcessMessage('dht_bootstrap', $messageData, $packageInstance); + $this->genericProcessMessage('dht_bootstrap', $messageInstance, $packageInstance); } /** @@ -114,7 +115,5 @@ class PackageDhtBootstrapTagFilter extends BaseNodeFilter implements FilterableP // Please don't call this method throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); } -} -// [EOF] -?> +} diff --git a/application/hub/classes/filter/tags/class_PackageRequestNodeListTagFilter.php b/application/hub/classes/filter/tags/class_PackageRequestNodeListTagFilter.php index 62fd58ab7..93525df2c 100644 --- a/application/hub/classes/filter/tags/class_PackageRequestNodeListTagFilter.php +++ b/application/hub/classes/filter/tags/class_PackageRequestNodeListTagFilter.php @@ -5,6 +5,7 @@ namespace Org\Shipsimu\Hub\Filter\Tag\Network\Request\NodeList; // Import application-specific stuff use Org\Shipsimu\Hub\Filter\Network\FilterablePackage; use Org\Shipsimu\Hub\Filter\Node\BaseNodeFilter; +use Org\Shipsimu\Hub\Network\Message\DeliverableMessage; use Org\Shipsimu\Hub\Network\Receive\Receivable; use Org\Shipsimu\Hub\Template\Engine\Xml\Request\NodeList\XmlRequestNodeListTemplateEngine; @@ -82,13 +83,13 @@ class PackageRequestNodeListTagFilter extends BaseNodeFilter implements Filterab /** * Processes the given raw message content. * - * @param $messageData Raw message data array + * @param $messageInstance An instance of a DeliverableMessage class * @param $packageInstance An instance of a Receivable class * @return void */ public function processMessage (DeliverableMessage $messageInstance, Receivable $packageInstance) { // Process messasge generic - $this->genericProcessMessage('request_node_list', $messageData, $packageInstance); + $this->genericProcessMessage('request_node_list', $messageInstance, $packageInstance); } /** @@ -103,7 +104,5 @@ class PackageRequestNodeListTagFilter extends BaseNodeFilter implements Filterab // Please don't call this method throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); } -} -// [EOF] -?> +} diff --git a/application/hub/classes/filter/tags/class_PackageSelfConnectTagFilter.php b/application/hub/classes/filter/tags/class_PackageSelfConnectTagFilter.php index 32649f819..bc373090f 100644 --- a/application/hub/classes/filter/tags/class_PackageSelfConnectTagFilter.php +++ b/application/hub/classes/filter/tags/class_PackageSelfConnectTagFilter.php @@ -5,6 +5,7 @@ namespace Org\Shipsimu\Hub\Filter\Tag\Network\SelfConnect; // Import application-specific stuff use Org\Shipsimu\Hub\Filter\Network\FilterablePackage; use Org\Shipsimu\Hub\Filter\Node\BaseNodeFilter; +use Org\Shipsimu\Hub\Network\Message\DeliverableMessage; use Org\Shipsimu\Hub\Network\Receive\Receivable; use Org\Shipsimu\Hub\Tag\Tagable; use Org\Shipsimu\Hub\Template\Engine\Xml\SelfConnect\XmlSelfConnectTemplateEngine; @@ -91,13 +92,13 @@ class PackageSelfConnectTagFilter extends BaseNodeFilter implements FilterablePa * XmlParserException - If the XML message is damaged or not * well-formed * - * @param $messageData Raw message data array + * @param $messageInstance An instance of a DeliverableMessage class * @param $packageInstance An instance of a Receivable class * @return void */ public function processMessage (DeliverableMessage $messageInstance, Receivable $packageInstance) { // Process generic - $this->genericProcessMessage(Tagable::TAG_SELF_CONNECT, $messageData, $packageInstance); + $this->genericProcessMessage(Tagable::TAG_SELF_CONNECT, $messageInstance, $packageInstance); } /** diff --git a/application/hub/classes/handler/data/answer-status/announcement/class_NodeAnnouncementAnswerOkayHandler.php b/application/hub/classes/handler/data/answer-status/announcement/class_NodeAnnouncementAnswerOkayHandler.php index 097b0c30d..13ef618f1 100644 --- a/application/hub/classes/handler/data/answer-status/announcement/class_NodeAnnouncementAnswerOkayHandler.php +++ b/application/hub/classes/handler/data/answer-status/announcement/class_NodeAnnouncementAnswerOkayHandler.php @@ -7,6 +7,7 @@ use Org\Shipsimu\Hub\Database\Frontend\Node\Dht\NodeDistributedHashTableDatabase use Org\Shipsimu\Hub\Factory\Dht\DhtObjectFactory; use Org\Shipsimu\Hub\Factory\Node\NodeObjectFactory; use Org\Shipsimu\Hub\Handler\Message\HandleableMessage; +use Org\Shipsimu\Hub\Network\Message\DeliverableMessage; use Org\Shipsimu\Hub\Network\Receive\Receivable; use Org\Shipsimu\Hub\Node\BaseHubNode; use Org\Shipsimu\Hub\Template\Engine\Xml\Answer\Announcement\XmlAnnouncementAnswerTemplateEngine; @@ -73,7 +74,7 @@ class NodeAnnouncementAnswerOkayHandler extends BaseAnswerStatusHandler implemen /** * Handles given message data array * - * @param $messageData An array of message data + * @param $messageInstance An instance of a DeliverableMessage class * @param $packageInstance An instance of a Receivable class * @return void * @todo Do some more here: Handle karma, et cetera? @@ -83,7 +84,7 @@ class NodeAnnouncementAnswerOkayHandler extends BaseAnswerStatusHandler implemen * Query DHT and force update (which will throw an exception if the * node is not found). */ - DhtObjectFactory::createDhtInstance('node')->registerNodeByMessageInstance($messageData, $this, TRUE); + DhtObjectFactory::createDhtInstance('node')->registerNodeByMessageInstance($messageInstance, $this, TRUE); // Get handler instance $handlerInstance = GenericRegistry::getRegistry()->getInstance('task_handler'); @@ -102,7 +103,7 @@ class NodeAnnouncementAnswerOkayHandler extends BaseAnswerStatusHandler implemen $nodeInstance->getStateInstance()->nodeAnnouncementSuccessful(); // Prepare next message - $this->prepareNextMessage($messageData, $packageInstance); + $this->prepareNextMessage($messageInstance, $packageInstance); } /** @@ -120,7 +121,7 @@ class NodeAnnouncementAnswerOkayHandler extends BaseAnswerStatusHandler implemen * answer-status => OKAY * message_type => announcement_answer * - * @param $messageData An array with all message data + * @param $messageInstance An instance of a DeliverableMessage class * @return void */ protected function initMessageConfigurationData (DeliverableMessage $messageInstance) { @@ -137,9 +138,9 @@ class NodeAnnouncementAnswerOkayHandler extends BaseAnswerStatusHandler implemen /** * Removes configuration data with given message data array from global - * configuration. For content of $messageData see method comment above. + * configuration. For content of $messageInstance see method comment above. * - * @param $messageData An array with all message data + * @param $messageInstance An instance of a DeliverableMessage class * @return void */ protected function removeMessageConfigurationData (DeliverableMessage $messageInstance) { diff --git a/application/hub/classes/handler/data/answer-status/requests/class_RequestNodeListAnswerOkayHandler.php b/application/hub/classes/handler/data/answer-status/requests/class_RequestNodeListAnswerOkayHandler.php index e573ad4ca..4977bac57 100644 --- a/application/hub/classes/handler/data/answer-status/requests/class_RequestNodeListAnswerOkayHandler.php +++ b/application/hub/classes/handler/data/answer-status/requests/class_RequestNodeListAnswerOkayHandler.php @@ -5,6 +5,7 @@ namespace Org\Shipsimu\Hub\Handler\Answer\Okay\NodeList; // Import application-specific stuff use Org\Shipsimu\Hub\Factory\Dht\DhtObjectFactory; use Org\Shipsimu\Hub\Handler\Message\HandleableMessage; +use Org\Shipsimu\Hub\Network\Message\DeliverableMessage; use Org\Shipsimu\Hub\Network\Receive\Receivable; use Org\Shipsimu\Hub\Template\Engine\Xml\Answer\Request\NodeList\XmlRequestNodeListAnswerTemplateEngine; @@ -68,16 +69,13 @@ class RequestNodeListAnswerOkayHandler extends BaseAnswerStatusHandler implement /** * Handles given message data array * - * @param $messageData An array of message data + * @param $messageInstance An instance of a DeliverableMessage class * @param $packageInstance An instance of a Receivable class * @return void * @throws NodeSessionIdVerficationException If the provided session id is not matching * @todo Do some more here: Handle karma, et cetera? */ public function handleAnswerMessageData (DeliverableMessage $messageInstance, Receivable $packageInstance) { - // Make sure node-list is found in array - assert(isset($messageData[XmlRequestNodeListAnswerTemplateEngine::REQUEST_DATA_NODE_LIST])); - // Save node list $nodeList = json_decode(base64_decode($messageData[XmlRequestNodeListAnswerTemplateEngine::REQUEST_DATA_NODE_LIST])); @@ -94,10 +92,10 @@ class RequestNodeListAnswerOkayHandler extends BaseAnswerStatusHandler implement * Query DHT and force update (which will throw an exception if the * node is not found). */ - DhtObjectFactory::createDhtInstance('node')->registerNodeByMessageInstance($messageData, $this, TRUE); + DhtObjectFactory::createDhtInstance('node')->registerNodeByMessageInstance($messageInstance, $this, TRUE); // Prepare next message ("hello" message to all returned nodes) - //$this->prepareNextMessage($messageData, $packageInstance); + // @TODO $this->prepareNextMessage($messageInstance, $packageInstance); } /** @@ -110,7 +108,7 @@ class RequestNodeListAnswerOkayHandler extends BaseAnswerStatusHandler implement * answer-status => OKAY * message_type => request_node_list_answer * - * @param $messageData An array with all message data + * @param $messageInstance An instance of a DeliverableMessage class * @return void * @todo 0% done */ @@ -120,9 +118,9 @@ class RequestNodeListAnswerOkayHandler extends BaseAnswerStatusHandler implement /** * Removes configuration data with given message data array from global - * configuration. For content of $messageData see method comment above. + * configuration. For content of $messageInstance see method comment above. * - * @param $messageData An array with all message data + * @param $messageInstance An instance of a DeliverableMessage class * @return void * @todo 0% done */ diff --git a/application/hub/classes/handler/data/class_BaseDataHandler.php b/application/hub/classes/handler/data/class_BaseDataHandler.php index 75bffb707..48e04bc1c 100644 --- a/application/hub/classes/handler/data/class_BaseDataHandler.php +++ b/application/hub/classes/handler/data/class_BaseDataHandler.php @@ -7,6 +7,7 @@ use Org\Shipsimu\Hub\Factory\Node\NodeObjectFactory; use Org\Shipsimu\Hub\Generic\HubInterface; use Org\Shipsimu\Hub\Handler\BaseHubHandler; use Org\Shipsimu\Hub\Network\Delivery\Deliverable; +use Org\Shipsimu\Hub\Network\Message\DeliverableMessage; // Import framework stuff use Org\Mxchange\CoreFramework\Factory\ObjectFactory; @@ -103,7 +104,7 @@ abstract class BaseDataHandler extends BaseHubHandler implements HubInterface { /** * Prepares a message as answer for given message data for delivery. * - * @param $messageData An array with all message data + * @param $messageInstance An instance of a DeliverableMessage class * @param $packageInstance An instance of a Deliverable instance * @return void */ @@ -112,7 +113,7 @@ abstract class BaseDataHandler extends BaseHubHandler implements HubInterface { //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-DATA-HANDLER:Going to send an answer message for ' . $this->getHandlerName() . ' ...'); // Get a helper instance based on this handler's name - $helperInstance = ObjectFactory::createObjectByConfiguredName('node_answer_' . $this->getHandlerName() . '_helper_class', array($messageData)); + $helperInstance = ObjectFactory::createObjectByConfiguredName('node_answer_' . $this->getHandlerName() . '_helper_class', array($messageInstance)); // Get node instance /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-DATA-HANDLER: Creating node instance ...'); @@ -125,7 +126,7 @@ abstract class BaseDataHandler extends BaseHubHandler implements HubInterface { * Set missing (temporary) configuration data, mostly it needs to be * copied from message data array. */ - $this->initMessageConfigurationData($messageData); + $this->initMessageConfigurationData($messageInstance); // Compile any configuration variables $helperInstance->getTemplateInstance()->compileConfigInVariables(); @@ -137,7 +138,7 @@ abstract class BaseDataHandler extends BaseHubHandler implements HubInterface { /* * Remove temporary configuration */ - $this->removeMessageConfigurationData($messageData); + $this->removeMessageConfigurationData($messageInstance); // Debug message //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-DATA-HANDLER:Answer message has been prepared.'); @@ -146,7 +147,7 @@ abstract class BaseDataHandler extends BaseHubHandler implements HubInterface { /** * Prepares the next message * - * @param $messageData An array with all message data + * @param $messageInstance An instance of a DeliverableMessage class * @param $packageInstance An instance of a Deliverable instance * @return void */ @@ -155,7 +156,7 @@ abstract class BaseDataHandler extends BaseHubHandler implements HubInterface { //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-DATA-HANDLER:Going to send next message ...'); // Get a helper instance based on this handler's name - $helperInstance = ObjectFactory::createObjectByConfiguredName('node_next_' . $this->getHandlerName() . '_helper_class', array($messageData)); + $helperInstance = ObjectFactory::createObjectByConfiguredName('node_next_' . $this->getHandlerName() . '_helper_class', array($messageInstance)); // Get node instance $nodeInstance = NodeObjectFactory::createNodeInstance(); @@ -167,7 +168,7 @@ abstract class BaseDataHandler extends BaseHubHandler implements HubInterface { * Set missing (temporary) configuration data, mostly it needs to be * copied from message data array. */ - $this->initMessageConfigurationData($messageData); + $this->initMessageConfigurationData($messageInstance); // Compile any configuration variables $helperInstance->getTemplateInstance()->compileConfigInVariables(); @@ -179,7 +180,7 @@ abstract class BaseDataHandler extends BaseHubHandler implements HubInterface { /* * Remove temporary configuration */ - $this->removeMessageConfigurationData($messageData); + $this->removeMessageConfigurationData($messageInstance); // Debug message //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-DATA-HANDLER:Next message has been prepared.'); @@ -188,7 +189,7 @@ abstract class BaseDataHandler extends BaseHubHandler implements HubInterface { /** * Initializes configuration data from given message data array * - * @param $messageData An array with all message data + * @param $messageInstance An instance of a DeliverableMessage class * @return void */ abstract protected function initMessageConfigurationData (DeliverableMessage $messageInstance); @@ -197,7 +198,7 @@ abstract class BaseDataHandler extends BaseHubHandler implements HubInterface { * Removes configuration data with given message data array from global * configuration * - * @param $messageData An array with all message data + * @param $messageInstance An instance of a DeliverableMessage class * @return void */ abstract protected function removeMessageConfigurationData (DeliverableMessage $messageInstance); diff --git a/application/hub/classes/handler/data/message-types/announcement/class_NodeMessageAnnouncementHandler.php b/application/hub/classes/handler/data/message-types/announcement/class_NodeMessageAnnouncementHandler.php index 300ac8970..d583bfd6c 100644 --- a/application/hub/classes/handler/data/message-types/announcement/class_NodeMessageAnnouncementHandler.php +++ b/application/hub/classes/handler/data/message-types/announcement/class_NodeMessageAnnouncementHandler.php @@ -8,6 +8,7 @@ use Org\Shipsimu\Hub\Factory\Node\NodeObjectFactory; use Org\Shipsimu\Hub\Generic\BaseHubSystem; use Org\Shipsimu\Hub\Handler\Message\BaseMessageHandler; use Org\Shipsimu\Hub\Handler\Message\HandleableMessage; +use Org\Shipsimu\Hub\Network\Message\DeliverableMessage; use Org\Shipsimu\Hub\Network\Receive\Receivable; use Org\Shipsimu\Hub\Template\Engine\Xml\Announcement\XmlAnnouncementTemplateEngine; use Org\Shipsimu\Hub\Template\Engine\Xml\Answer\Announcement\XmlAnnouncementAnswerTemplateEngine; @@ -102,7 +103,7 @@ class NodeMessageAnnouncementHandler extends BaseMessageHandler implements Handl /** * Handles data array of the message * - * @param $messageData An array with message data to handle + * @param $messageInstance An instance of a DeliverableMessage class * @param $packageInstance An instance of a Receivable class * @return void * @throws AnnouncementNotAcceptedException If this node does not accept announcements @@ -118,26 +119,26 @@ class NodeMessageAnnouncementHandler extends BaseMessageHandler implements Handl * This node is not accepting announcements, then someone wants to * announce his node to a non-bootstrap and non-master node. */ - throw new AnnouncementNotAcceptedException(array($this, $nodeInstance, $messageData), BaseHubSystem::EXCEPTION_ANNOUNCEMENT_NOT_ACCEPTED); + throw new AnnouncementNotAcceptedException(array($this, $nodeInstance, $messageInstance), BaseHubSystem::EXCEPTION_ANNOUNCEMENT_NOT_ACCEPTED); } // END - if // Register the announcing node with this node - $this->registerNodeByMessageInstance($messageData); + $this->registerNodeByMessageInstance($messageInstance); // Prepare answer message to be delivered back to the other node - $this->prepareAnswerMessage($messageData, $packageInstance); + $this->prepareAnswerMessage($messageInstance, $packageInstance); } /** * Adds all required elements from given array into data set instance * * @param $dataSetInstance An instance of a StoreableCriteria class - * @param $messageData An array with all message data + * @param $messageInstance An instance of a DeliverableMessage class * @return void */ public function addArrayToDataSet (StoreableCriteria $dataSetInstance, DeliverableMessage $messageInstance) { // Add generic first - parent::addArrayToDataSet($dataSetInstance, $messageData); + parent::addArrayToDataSet($dataSetInstance, $messageInstance); // Add all ements foreach ($this->messageDataElements as $key) { @@ -153,14 +154,12 @@ class NodeMessageAnnouncementHandler extends BaseMessageHandler implements Handl /** * Initializes configuration data from given message data array * - * @param $messageData An array with all message data + * @param $messageInstance An instance of a DeliverableMessage class * @return void */ protected function initMessageConfigurationData (DeliverableMessage $messageInstance) { - // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('ANNOUNCEMENT-HANDLER: messageData=' . print_r($messageData, TRUE)); - // "Walk" throught the translation array + /* PRINTR-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('ANNOUNCEMENT-HANDLER: messageInstance=' . print_r($messageInstance, TRUE)); foreach ($this->messageToConfig as $messageKey => $configKey) { // Debug message /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('ANNOUNCEMENT-HANDLER: Setting messageKey=' . $messageKey . ',configKey=' . $configKey . ':' . $messageData[$messageKey]); @@ -189,7 +188,7 @@ class NodeMessageAnnouncementHandler extends BaseMessageHandler implements Handl * Removes configuration data with given message data array from global * configuration * - * @param $messageData An array with all message data + * @param $messageData An instance of a DeliverableMessage class * @return void */ protected function removeMessageConfigurationData (DeliverableMessage $messageInstance) { diff --git a/application/hub/classes/handler/data/message-types/answer/class_NodeMessageAnnouncementAnswerHandler.php b/application/hub/classes/handler/data/message-types/answer/class_NodeMessageAnnouncementAnswerHandler.php index 6b0413e91..b489a9593 100644 --- a/application/hub/classes/handler/data/message-types/answer/class_NodeMessageAnnouncementAnswerHandler.php +++ b/application/hub/classes/handler/data/message-types/answer/class_NodeMessageAnnouncementAnswerHandler.php @@ -6,6 +6,7 @@ namespace Org\Shipsimu\Hub\Handler\Node\Answer\Announcement; use Org\Shipsimu\Hub\Factory\Node\NodeObjectFactory; use Org\Shipsimu\Hub\Handler\Message\BaseMessageHandler; use Org\Shipsimu\Hub\Handler\Message\HandleableMessage; +use Org\Shipsimu\Hub\Network\Message\DeliverableMessage; use Org\Shipsimu\Hub\Network\Receive\Receivable; use Org\Shipsimu\Hub\Template\Engine\Xml\Announcement\XmlAnnouncementTemplateEngine; use Org\Shipsimu\Hub\Template\Engine\Xml\Answer\Announcement\XmlAnnouncementAnswerTemplateEngine; @@ -104,7 +105,7 @@ class NodeMessageAnnouncementAnswerHandler extends BaseMessageHandler implements /** * Handles data array of the message * - * @param $messageData An array with message data to handle + * @param $messageInstance An instance of a DeliverableMessage class * @param $packageInstance An instance of a Receivable class * @return void * @throws NoAnnouncementAttemptedException If this node has not attempted to announce itself @@ -120,26 +121,26 @@ class NodeMessageAnnouncementAnswerHandler extends BaseMessageHandler implements * This node has never announced itself, so it doesn't expect * announcement answer messages. */ - throw new NoAnnouncementAttemptedException(array($this, $nodeInstance, $messageData), self::EXCEPTION_ANNOUNCEMENT_NOT_ATTEMPTED); + throw new NoAnnouncementAttemptedException(array($this, $nodeInstance, $messageInstance), self::EXCEPTION_ANNOUNCEMENT_NOT_ATTEMPTED); } // END - if // Register the announcing node with this node - $this->registerNodeByMessageInstance($messageData); + $this->registerNodeByMessageInstance($messageInstance); // Handle the answer status element - $nodeInstance->handleAnswerStatusByMessageInstance($messageData, $packageInstance); + $nodeInstance->handleAnswerStatusByMessageInstance($messageInstance, $packageInstance); } /** * Adds all required elements from given array into data set instance * * @param $dataSetInstance An instance of a StoreableCriteria class - * @param $messageData An array with all message data + * @param $messageInstance An instance of a DeliverableMessage class * @return void */ public function addArrayToDataSet (StoreableCriteria $dataSetInstance, DeliverableMessage $messageInstance) { // Add generic first - parent::addArrayToDataSet($dataSetInstance, $messageData); + parent::addArrayToDataSet($dataSetInstance, $messageInstance); // Add all ements foreach ($this->messageDataElements as $key) { @@ -157,7 +158,7 @@ class NodeMessageAnnouncementAnswerHandler extends BaseMessageHandler implements /** * Initializes configuration data from given message data array * - * @param $messageData An array with all message data + * @param $messageInstance An instance of a DeliverableMessage class * @return void * @throws UnsupportedOperationException If this method is called */ @@ -170,7 +171,7 @@ class NodeMessageAnnouncementAnswerHandler extends BaseMessageHandler implements * Removes configuration data with given message data array from global * configuration * - * @param $messageData An array with all message data + * @param $messageInstance An instance of a DeliverableMessage class * @return void * @throws UnsupportedOperationException If this method is called */ @@ -178,7 +179,5 @@ class NodeMessageAnnouncementAnswerHandler extends BaseMessageHandler implements // Please don't call this method throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); } -} -// [EOF] -?> +} diff --git a/application/hub/classes/handler/data/message-types/answer/class_NodeMessageDhtBootstrapAnswerHandler.php b/application/hub/classes/handler/data/message-types/answer/class_NodeMessageDhtBootstrapAnswerHandler.php index 856de438f..078a3cc5d 100644 --- a/application/hub/classes/handler/data/message-types/answer/class_NodeMessageDhtBootstrapAnswerHandler.php +++ b/application/hub/classes/handler/data/message-types/answer/class_NodeMessageDhtBootstrapAnswerHandler.php @@ -6,6 +6,7 @@ namespace Org\Shipsimu\Hub\Handler\Answer\Node\DhtBootstrap; use Org\Shipsimu\Hub\Factory\Dht\DhtObjectFactory; use Org\Shipsimu\Hub\Handler\Message\BaseMessageHandler; use Org\Shipsimu\Hub\Handler\Message\HandleableMessage; +use Org\Shipsimu\Hub\Network\Message\DeliverableMessage; use Org\Shipsimu\Hub\Network\Receive\Receivable; use Org\Shipsimu\Hub\Template\Engine\Xml\Answer\Dht\Bootstrap\XmlDhtBootstrapAnswerTemplateEngine; use Org\Shipsimu\Hub\Template\Engine\Xml\Dht\Bootstrap\XmlDhtBootstrapTemplateEngine; @@ -101,7 +102,7 @@ class NodeMessageDhtBootstrapAnswerHandler extends BaseMessageHandler implements /** * Handles data array of the message * - * @param $messageData An array with message data to handle + * @param $messageInstance An instance of a DeliverableMessage class * @param $packageInstance An instance of a Receivable class * @return void * @throws NoDhtBootstrapAttemptedException If this DHT has not attempted to bootstrap @@ -117,23 +118,23 @@ class NodeMessageDhtBootstrapAnswerHandler extends BaseMessageHandler implements * This DHT has never bootstrapped, so it doesn't expect * announcement answer messages. */ - throw new NoDhtBootstrapAttemptedException(array($this, $dhtInstance, $messageData), self::EXCEPTION_DHT_BOOTSTRAP_NOT_ATTEMPTED); + throw new NoDhtBootstrapAttemptedException(array($this, $dhtInstance, $messageInstance), self::EXCEPTION_DHT_BOOTSTRAP_NOT_ATTEMPTED); } // END - if // Unfinished - $this->partialStub('UNHANDLED: messageData=' . print_r($messageData, TRUE)); + $this->partialStub('UNHANDLED: messageInstance=' . print_r($messageInstance, TRUE)); } /** * Adds all required elements from given array into data set instance * * @param $dataSetInstance An instance of a StoreableCriteria class - * @param $messageData An array with all message data + * @param $messageInstance An instance of a DeliverableMessage class * @return void */ public function addArrayToDataSet (StoreableCriteria $dataSetInstance, DeliverableMessage $messageInstance) { // Add generic first - parent::addArrayToDataSet($dataSetInstance, $messageData); + parent::addArrayToDataSet($dataSetInstance, $messageInstance); // Add all ements foreach ($this->messageDataElements as $key) { @@ -151,7 +152,7 @@ class NodeMessageDhtBootstrapAnswerHandler extends BaseMessageHandler implements /** * Initializes configuration data from given message data array * - * @param $messageData An array with all message data + * @param $messageInstance An instance of a DeliverableMessage class * @return void * @throws UnsupportedOperationException If this method is called */ @@ -164,7 +165,7 @@ class NodeMessageDhtBootstrapAnswerHandler extends BaseMessageHandler implements * Removes configuration data with given message data array from global * configuration * - * @param $messageData An array with all message data + * @param $messageInstance An instance of a DeliverableMessage class * @return void * @throws UnsupportedOperationException If this method is called */ diff --git a/application/hub/classes/handler/data/message-types/answer/class_NodeMessageRequestNodeListAnswerHandler.php b/application/hub/classes/handler/data/message-types/answer/class_NodeMessageRequestNodeListAnswerHandler.php index 8cfaacb3a..dbc65a5a1 100644 --- a/application/hub/classes/handler/data/message-types/answer/class_NodeMessageRequestNodeListAnswerHandler.php +++ b/application/hub/classes/handler/data/message-types/answer/class_NodeMessageRequestNodeListAnswerHandler.php @@ -6,6 +6,7 @@ namespace Org\Shipsimu\Hub\Handler\Node\Answer\Request\NodeList; use Org\Shipsimu\Hub\Factory\Node\NodeObjectFactory; use Org\Shipsimu\Hub\Handler\Message\BaseMessageHandler; use Org\Shipsimu\Hub\Handler\Message\HandleableMessage; +use Org\Shipsimu\Hub\Network\Message\DeliverableMessage; use Org\Shipsimu\Hub\Network\Receive\Receivable; use Org\Shipsimu\Hub\Template\Engine\Xml\Answer\Request\NodeList\XmlRequestNodeListAnswerTemplateEngine; use Org\Shipsimu\Hub\Template\Engine\Xml\Network\Answer\BaseXmlAnswerTemplateEngine; @@ -87,7 +88,7 @@ class NodeMessageRequestNodeListAnswerHandler extends BaseMessageHandler impleme /** * Handles data array of the message * - * @param $messageData An array with message data to handle + * @param $messageInstance An instance of a DeliverableMessage class * @param $packageInstance An instance of a Receivable class * @return void * @throws NoRequestNodeListAttemptedException If this node has not attempted to announce itself @@ -103,29 +104,29 @@ class NodeMessageRequestNodeListAnswerHandler extends BaseMessageHandler impleme * This node has never announced itself, so it doesn't expect * request-node-list answer messages. */ - throw new NoRequestNodeListAttemptedException(array($this, $nodeInstance, $messageData), self::EXCEPTION_ANNOUNCEMENT_NOT_ATTEMPTED); + throw new NoRequestNodeListAttemptedException(array($this, $nodeInstance, $messageInstance), self::EXCEPTION_ANNOUNCEMENT_NOT_ATTEMPTED); } // END - if // Register the announcing node with this node - $this->registerNodeByMessageInstance($messageData); + $this->registerNodeByMessageInstance($messageInstance); // Handle the answer status element - $nodeInstance->handleAnswerStatusByMessageInstance($messageData, $packageInstance); + $nodeInstance->handleAnswerStatusByMessageInstance($messageInstance, $packageInstance); } /** * Adds all required elements from given array into data set instance * * @param $dataSetInstance An instance of a StoreableCriteria class - * @param $messageData An array with all message data + * @param $messageInstance An instance of a DeliverableMessage class * @return void */ public function addArrayToDataSet (StoreableCriteria $dataSetInstance, DeliverableMessage $messageInstance) { // Add generic first - parent::addArrayToDataSet($dataSetInstance, $messageData); + parent::addArrayToDataSet($dataSetInstance, $messageInstance); // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('ANSWER-HANDLER: messageData=' . print_r($messageData, TRUE)); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('ANSWER-HANDLER: messageInstance=' . print_r($messageInstance, TRUE)); // Add all ements foreach ($this->messageDataElements as $key) { @@ -146,7 +147,7 @@ class NodeMessageRequestNodeListAnswerHandler extends BaseMessageHandler impleme /** * Initializes configuration data from given message data array * - * @param $messageData An array with all message data + * @param $messageInstance An instance of a DeliverableMessage class * @return void * @throws UnsupportedOperationException If this method is called */ @@ -159,7 +160,7 @@ class NodeMessageRequestNodeListAnswerHandler extends BaseMessageHandler impleme * Removes configuration data with given message data array from global * configuration * - * @param $messageData An array with all message data + * @param $messageInstance An instance of a DeliverableMessage class * @return void * @throws UnsupportedOperationException If this method is called */ diff --git a/application/hub/classes/handler/data/message-types/class_BaseMessageHandler.php b/application/hub/classes/handler/data/message-types/class_BaseMessageHandler.php index e6c451171..742f3791b 100644 --- a/application/hub/classes/handler/data/message-types/class_BaseMessageHandler.php +++ b/application/hub/classes/handler/data/message-types/class_BaseMessageHandler.php @@ -6,6 +6,7 @@ namespace Org\Shipsimu\Hub\Handler\Message; use Org\Shipsimu\Hub\Factory\Dht\DhtObjectFactory; use Org\Shipsimu\Hub\Generic\BaseHubSystem; use Org\Shipsimu\Hub\Handler\Data\BaseDataHandler; +use Org\Shipsimu\Hub\Network\Message\DeliverableMessage; use Org\Shipsimu\Hub\Network\Receive\Receivable; // Import framework stuff @@ -73,7 +74,7 @@ abstract class BaseMessageHandler extends BaseDataHandler { * - external-address (hostname or IP number) * - listen-port (TCP/UDP listen port for inbound connections) * - * @param $messageArray An array with all minimum message data + * @param $messageInstance An instance of a DeliverableMessage class * @return void */ protected function registerNodeByMessageInstance (DeliverableMessage $messageInstance) { @@ -81,13 +82,13 @@ abstract class BaseMessageHandler extends BaseDataHandler { assert(count($this->getSearchData()) > 0); // Let the DHT facade do the work - DhtObjectFactory::createDhtInstance('node')->registerNodeByMessageInstance($messageData, $this); + DhtObjectFactory::createDhtInstance('node')->registerNodeByMessageInstance($messageInstance, $this); } /** * Posty-handles data array of the message * - * @param $messageData An array with message data to handle + * @param $messageInstance An instance of a DeliverableMessage class * @param $packageInstance An instance of a Receivable class * @return void */ @@ -96,7 +97,7 @@ abstract class BaseMessageHandler extends BaseDataHandler { * Feed hash to miner by handling over the whole array as also the * sender and tags are needed. */ - $packageInstance->feedHashToMiner($messageData); + $packageInstance->feedHashToMiner($messageInstance); } } diff --git a/application/hub/classes/handler/data/message-types/dht/class_NodeMessageDhtBootstrapHandler.php b/application/hub/classes/handler/data/message-types/dht/class_NodeMessageDhtBootstrapHandler.php index 9c1a4b473..f4950bf57 100644 --- a/application/hub/classes/handler/data/message-types/dht/class_NodeMessageDhtBootstrapHandler.php +++ b/application/hub/classes/handler/data/message-types/dht/class_NodeMessageDhtBootstrapHandler.php @@ -8,6 +8,7 @@ use Org\Shipsimu\Hub\Factory\Dht\DhtObjectFactory; use Org\Shipsimu\Hub\Factory\Node\NodeObjectFactory; use Org\Shipsimu\Hub\Handler\Message\BaseMessageHandler; use Org\Shipsimu\Hub\Handler\Message\HandleableMessage; +use Org\Shipsimu\Hub\Network\Message\DeliverableMessage; use Org\Shipsimu\Hub\Network\Receive\Receivable; use Org\Shipsimu\Hub\Template\Engine\Xml\Answer\Dht\Bootstrap\XmlDhtBootstrapAnswerTemplateEngine; use Org\Shipsimu\Hub\Template\Engine\Xml\Dht\Bootstrap\XmlDhtBootstrapTemplateEngine; @@ -97,7 +98,7 @@ class NodeMessageDhtBootstrapHandler extends BaseMessageHandler implements Handl /** * Handles data array of the message * - * @param $messageData An array with message data to handle + * @param $messageInstance An instance of a DeliverableMessage class * @param $packageInstance An instance of a Receivable class * @return void * @throws DhtBootstrapNotAcceptedException If this node does not accept DHT bootstrap requests @@ -109,26 +110,26 @@ class NodeMessageDhtBootstrapHandler extends BaseMessageHandler implements Handl /* * This node is not accepting DHT bootstrap requests. */ - throw new DhtBootstrapNotAcceptedException(array($this, $messageData), self::EXCEPTION_DHT_BOOTSTRAP_NOT_ACCEPTED); + throw new DhtBootstrapNotAcceptedException(array($this, $messageInstance), self::EXCEPTION_DHT_BOOTSTRAP_NOT_ACCEPTED); } // END - if // Register the DHT bootstrap requesting node with this node - $this->registerNodeByMessageInstance($messageData); + $this->registerNodeByMessageInstance($messageInstance); // Prepare answer message to be delivered back to the other node - $this->prepareAnswerMessage($messageData, $packageInstance); + $this->prepareAnswerMessage($messageInstance, $packageInstance); } /** * Adds all required elements from given array into data set instance * * @param $dataSetInstance An instance of a StoreableCriteria class - * @param $messageData An array with all message data + * @param $messageInstance An instance of a DeliverableMessage class * @return void */ public function addArrayToDataSet (StoreableCriteria $dataSetInstance, DeliverableMessage $messageInstance) { // Add generic first - parent::addArrayToDataSet($dataSetInstance, $messageData); + parent::addArrayToDataSet($dataSetInstance, $messageInstance); // Add all ements foreach ($this->messageDataElements as $key) { @@ -143,19 +144,15 @@ class NodeMessageDhtBootstrapHandler extends BaseMessageHandler implements Handl /** * Initializes configuration data from given message data array * - * @param $messageData An array with all message data + * @param $messageInstance An instance of a DeliverableMessage class * @return void */ protected function initMessageConfigurationData (DeliverableMessage $messageInstance) { - // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-BOOTSTRAP-HANDLER: messageData=' . print_r($messageData, TRUE)); - // "Walk" throught the translation array + /* PRINTR-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-BOOTSTRAP-HANDLER: messageInstance=' . print_r($messageInstance, TRUE)); foreach ($this->messageToConfig as $messageKey => $configKey) { - // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-BOOTSTRAP-HANDLER: Setting messageKey=' . $messageKey . ',configKey=' . $configKey . ':' . $messageData[$messageKey]); - // Set the element in configuration + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-BOOTSTRAP-HANDLER: Setting messageKey=' . $messageKey . ',configKey=' . $configKey . ':' . $messageData[$messageKey]); $this->getConfigInstance()->setConfigEntry($configKey, $messageData[$messageKey]); } // END - foreach @@ -193,7 +190,7 @@ class NodeMessageDhtBootstrapHandler extends BaseMessageHandler implements Handl * Removes configuration data with given message data array from global * configuration * - * @param $messageData An array with all message data + * @param $messageInstance An instance of a DeliverableMessage class * @return void */ protected function removeMessageConfigurationData (DeliverableMessage $messageInstance) { diff --git a/application/hub/classes/handler/data/message-types/requests/class_NodeMessageRequestNodeListHandler.php b/application/hub/classes/handler/data/message-types/requests/class_NodeMessageRequestNodeListHandler.php index 0f7624d2e..9c08b8c5a 100644 --- a/application/hub/classes/handler/data/message-types/requests/class_NodeMessageRequestNodeListHandler.php +++ b/application/hub/classes/handler/data/message-types/requests/class_NodeMessageRequestNodeListHandler.php @@ -8,6 +8,7 @@ use Org\Shipsimu\Hub\Factory\Dht\DhtObjectFactory; use Org\Shipsimu\Hub\Factory\Node\NodeObjectFactory; use Org\Shipsimu\Hub\Handler\Message\BaseMessageHandler; use Org\Shipsimu\Hub\Handler\Message\HandleableMessage; +use Org\Shipsimu\Hub\Network\Message\DeliverableMessage; use Org\Shipsimu\Hub\Network\Receive\Receivable; use Org\Shipsimu\Hub\Node\BaseHubNode; use Org\Shipsimu\Hub\Template\Engine\Xml\Request\NodeList\XmlRequestNodeListTemplateEngine; @@ -82,7 +83,7 @@ class NodeMessageRequestNodeListHandler extends BaseMessageHandler implements Ha /** * Handles data array of the message * - * @param $messageData An array with message data to handle + * @param $messageInstance An instance of a DeliverableMessage class * @param $packageInstance An instance of a Receivable class * @return void * @throws RequestNotAcceptedException If this node does not accept this request @@ -98,26 +99,26 @@ class NodeMessageRequestNodeListHandler extends BaseMessageHandler implements Ha * This node is not accepting node list requests. Throw an * exception to abort any further processing. */ - throw new RequestNotAcceptedException(array($this, $nodeInstance, $messageData), self::EXCEPTION_REQUEST_NOT_ACCEPTED); + throw new RequestNotAcceptedException(array($this, $nodeInstance, $messageInstance), self::EXCEPTION_REQUEST_NOT_ACCEPTED); } // END - if // Register the announcing node with this node - $this->registerNodeByMessageInstance($messageData); + $this->registerNodeByMessageInstance($messageInstance); // Prepare answer message to be delivered back to the other node - $this->prepareAnswerMessage($messageData, $packageInstance); + $this->prepareAnswerMessage($messageInstance, $packageInstance); } /** * Adds all required elements from given array into data set instance * * @param $dataSetInstance An instance of a StoreableCriteria class - * @param $messageData An array with all message data + * @param $messageInstance An instance of a DeliverableMessage class * @return void */ public function addArrayToDataSet (StoreableCriteria $dataSetInstance, DeliverableMessage $messageInstance) { // Add generic first - parent::addArrayToDataSet($dataSetInstance, $messageData); + parent::addArrayToDataSet($dataSetInstance, $messageInstance); // Add all ements foreach ($this->messageDataElements as $key) { @@ -132,12 +133,12 @@ class NodeMessageRequestNodeListHandler extends BaseMessageHandler implements Ha /** * Initializes configuration data from given message data array * - * @param $messageData An array with all message data + * @param $messageInstance An instance of a DeliverableMessage class * @return void */ protected function initMessageConfigurationData (DeliverableMessage $messageInstance) { // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('REQUEST-HANDLER: messageData=' . print_r($messageData, TRUE)); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('REQUEST-HANDLER: messageInstance=' . print_r($messageInstance, TRUE)); // "Walk" throught the config-copy array foreach ($this->configCopy as $targetKey => $sourceKey) { @@ -150,7 +151,7 @@ class NodeMessageRequestNodeListHandler extends BaseMessageHandler implements Ha // Query local DHT for nodes except given session id $nodeList = DhtObjectFactory::createDhtInstance('node')->queryLocalNodeListExceptByMessageInstance( - $messageData, + $messageInstance, $this, XmlRequestNodeListTemplateEngine::REQUEST_DATA_SESSION_ID, XmlRequestNodeListTemplateEngine::REQUEST_DATA_ACCEPTED_OBJECT_TYPES, @@ -174,7 +175,7 @@ class NodeMessageRequestNodeListHandler extends BaseMessageHandler implements Ha * Removes configuration data with given message data array from global * configuration * - * @param $messageData An array with all message data + * @param $messageInstance An instance of a DeliverableMessage class * @return void */ protected function removeMessageConfigurationData (DeliverableMessage $messageInstance) { diff --git a/application/hub/classes/handler/data/message-types/self-connect/class_NodeMessageSelfConnectHandler.php b/application/hub/classes/handler/data/message-types/self-connect/class_NodeMessageSelfConnectHandler.php index d419a8d37..f7981a763 100644 --- a/application/hub/classes/handler/data/message-types/self-connect/class_NodeMessageSelfConnectHandler.php +++ b/application/hub/classes/handler/data/message-types/self-connect/class_NodeMessageSelfConnectHandler.php @@ -6,6 +6,7 @@ namespace Org\Shipsimu\Hub\Handler\Node\Message\SelfConnect; use Org\Shipsimu\Hub\Factory\Node\NodeObjectFactory; use Org\Shipsimu\Hub\Handler\Message\BaseMessageHandler; use Org\Shipsimu\Hub\Handler\Message\HandleableMessage; +use Org\Shipsimu\Hub\Network\Message\DeliverableMessage; use Org\Shipsimu\Hub\Network\Receive\Receivable; use Org\Shipsimu\Hub\Template\Engine\Xml\SelfConnect\XmlSelfConnectTemplateEngine; @@ -66,7 +67,7 @@ class NodeMessageSelfConnectHandler extends BaseMessageHandler implements Handle /** * Handles data array of the message * - * @param $messageData An array with message data to handle + * @param $messageInstance An instance of a DeliverableMessage class * @param $packageInstance An instance of a Receivable class * @return void */ @@ -85,7 +86,7 @@ class NodeMessageSelfConnectHandler extends BaseMessageHandler implements Handle } else { // Something really horrible happened // @TODO Throw an exception here instead of dying - $this->debugInstance(sprintf('[%s:%d]: ids mismatching! messageData=%s', __METHOD__, __LINE__, print_r($messageData, TRUE))); + $this->debugInstance(sprintf('[%s:%d]: ids mismatching! messageInstance=%s', __METHOD__, __LINE__, print_r($messageInstance, TRUE))); } } @@ -93,13 +94,13 @@ class NodeMessageSelfConnectHandler extends BaseMessageHandler implements Handle * Adds all required elements from given array into data set instance * * @param $dataSetInstance An instance of a StoreableCriteria class - * @param $messageData An array with all message data + * @param $messageInstance An instance of a DeliverableMessage class * @return void * @throws UnsupportedOperationException If this method is called */ public function addArrayToDataSet (StoreableCriteria $dataSetInstance, DeliverableMessage $messageInstance) { // Add generic first - parent::addArrayToDataSet($dataSetInstance, $messageData); + parent::addArrayToDataSet($dataSetInstance, $messageInstance); // Please don't call this method! throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); @@ -108,7 +109,7 @@ class NodeMessageSelfConnectHandler extends BaseMessageHandler implements Handle /** * Initializes configuration data from given message data array * - * @param $messageData An array with all message data + * @param $messageInstance An instance of a DeliverableMessage class * @return void * @throws UnsupportedOperationException If this method is called */ @@ -120,7 +121,7 @@ class NodeMessageSelfConnectHandler extends BaseMessageHandler implements Handle /** * Removes configuration data with given message data array from global configuration * - * @param $messageData An array with all message data + * @param $messageInstance An instance of a DeliverableMessage class * @return void * @throws UnsupportedOperationException If this method is called */ diff --git a/application/hub/classes/handler/package/class_NetworkPackageHandler.php b/application/hub/classes/handler/package/class_NetworkPackageHandler.php index 7a9b00cd3..548078ff5 100644 --- a/application/hub/classes/handler/package/class_NetworkPackageHandler.php +++ b/application/hub/classes/handler/package/class_NetworkPackageHandler.php @@ -21,6 +21,7 @@ use Org\Shipsimu\Hub\Helper\Connection\ConnectionHelper; use Org\Shipsimu\Hub\Helper\HubHelper; use Org\Shipsimu\Hub\Information\ShareableInfo; use Org\Shipsimu\Hub\Network\Delivery\Deliverable; +use Org\Shipsimu\Hub\Network\Message\DeliverableMessage; use Org\Shipsimu\Hub\Network\Networkable; use Org\Shipsimu\Hub\Network\Package\DeliverablePackage; use Org\Shipsimu\Hub\Network\Package\Delivery\Fragment\PackageFragmenter; @@ -1554,7 +1555,7 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei public function handleProcessedMessage () { // Get it from the stacker, it is the full array with the processed message /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: CALLED!'); - $messageArray = $this->getStackInstance()->popNamed(self::STACKER_NAME_PROCESSED_MESSAGE); + $messageInstance = $this->getStackInstance()->popNamed(self::STACKER_NAME_PROCESSED_MESSAGE); // Add type for later easier handling $messageArray[self::MESSAGE_ARRAY_DATA][self::MESSAGE_ARRAY_TYPE] = $messageArray[self::MESSAGE_ARRAY_TYPE]; @@ -1581,15 +1582,13 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei * leads to an endless loop. You may wish to run the miner to get some * reward ("Hubcoins") for "mining" this hash. * - * @param $messageData Array with message data + * @param $messageInstance An instance of a DeliverableMessage class * @return void * @todo ~10% done? */ public function feedHashToMiner (DeliverableMessage $messageInstance) { - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: messageData()=%d - CALLED!', count($messageData))); - // Is the feature enabled? + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: messageInstance=%s - CALLED!', $messageInstance->__toString())); if (!FrameworkFeature::isFeatureAvailable('hubcoin_reward')) { /* * Feature is not enabled, don't feed the hash to the miner as it @@ -1598,11 +1597,6 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei return; } // END - if - // Make sure the required elements are there - assert(isset($messageData[self::MESSAGE_ARRAY_SENDER])); - assert(isset($messageData[self::MESSAGE_ARRAY_HASH])); - assert(isset($messageData[self::MESSAGE_ARRAY_DATA][self::MESSAGE_ARRAY_DATA_NODE_ID])); - // Copy node id $messageData[self::MESSAGE_ARRAY_DATA_NODE_ID] = $messageData[self::MESSAGE_ARRAY_DATA][self::MESSAGE_ARRAY_DATA_NODE_ID]; @@ -1610,10 +1604,8 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei unset($messageData[self::MESSAGE_ARRAY_TYPE]); unset($messageData[self::MESSAGE_ARRAY_DATA]); - // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: messageData=' . print_r($messageData, TRUE)); - // Resolve session id ('sender' is a session id) into node id + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: messageData=' . print_r($messageData, TRUE)); $nodeId = HubTools::resolveNodeIdBySessionId($messageData[self::MESSAGE_ARRAY_SENDER]); // Is 'claim_reward' the message type? @@ -1629,7 +1621,7 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei unset($messageData[self::MESSAGE_ARRAY_TAGS]); // Unfinished stuff: - $this->partialStub(sprintf('[%s:%d]: @TODO nodeId=%s,messageData=%s', __METHOD__, __LINE__, $nodeId, print_r($messageData, TRUE))); + $this->partialStub(sprintf('[%s:%d]: @TODO nodeId=%s,messageInstance=%s', __METHOD__, __LINE__, $nodeId, print_r($messageInstance, TRUE))); } } diff --git a/application/hub/classes/helper/node/answer/announcement/class_NodeAnnouncementMessageAnswerHelper.php b/application/hub/classes/helper/node/answer/announcement/class_NodeAnnouncementMessageAnswerHelper.php index 4727af384..f7a671fc3 100644 --- a/application/hub/classes/helper/node/answer/announcement/class_NodeAnnouncementMessageAnswerHelper.php +++ b/application/hub/classes/helper/node/answer/announcement/class_NodeAnnouncementMessageAnswerHelper.php @@ -7,6 +7,7 @@ use Org\Shipsimu\Hub\Factory\Handler\Network\NetworkPackageHandlerFactory; use Org\Shipsimu\Hub\Factory\Network\NetworkPackageFactory; use Org\Shipsimu\Hub\Handler\Package\NetworkPackageHandler; use Org\Shipsimu\Hub\Helper\Node\HelpableNode; +use Org\Shipsimu\Hub\Network\Message\DeliverableMessage; use Org\Shipsimu\Hub\Node\Node; use Org\Shipsimu\Hub\Template\Engine\Xml\Announcement\XmlAnnouncementTemplateEngine; @@ -53,7 +54,7 @@ class NodeAnnouncementMessageAnswerHelper extends BaseHubAnswerHelper implements /** * Creates the helper class * - * @param $messageData An array with all message data + * @param $messageInstance An instance of a DeliverableMessage class * @return $helperInstance A prepared instance of this helper */ public final static function createNodeAnnouncementMessageAnswerHelper (DeliverableMessage $messageInstance) { @@ -65,7 +66,7 @@ class NodeAnnouncementMessageAnswerHelper extends BaseHubAnswerHelper implements $helperInstance->setRecipientId($messageData[XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID]); // Set message data - $helperInstance->setMessageData($messageData); + $helperInstance->setMessageData($messageInstance); // Return the prepared instance return $helperInstance; diff --git a/application/hub/classes/helper/node/answer/class_BaseHubAnswerHelper.php b/application/hub/classes/helper/node/answer/class_BaseHubAnswerHelper.php index f4c1dbe3e..46fe7d598 100644 --- a/application/hub/classes/helper/node/answer/class_BaseHubAnswerHelper.php +++ b/application/hub/classes/helper/node/answer/class_BaseHubAnswerHelper.php @@ -4,6 +4,7 @@ namespace Helper\Node\Answer; // Import application-specific stuff use Org\Shipsimu\Hub\Helper\Node\BaseNodeHelper; +use Org\Shipsimu\Hub\Network\Message\DeliverableMessage; /** * A general hub message answer helper class @@ -29,9 +30,9 @@ use Org\Shipsimu\Hub\Helper\Node\BaseNodeHelper; */ abstract class BaseHubAnswerHelper extends BaseNodeHelper { /** - * Message data array + * Message instance */ - private $messageData = array(); + private $messageInstance = NULL; /** * Protected constructor @@ -47,19 +48,19 @@ abstract class BaseHubAnswerHelper extends BaseNodeHelper { /** * Setter for message data * - * @return $messageData An array with message data + * @return $messageInstance An instance of a DeliverableMessage class */ - protected final function setMessageData (DeliverableMessage $messageInstance) { - $this->messageData = $messageData; + protected final function setMessageInstance (DeliverableMessage $messageInstance) { + $this->messageInstance = $messageInstance; } /** * Getter for message data * - * @return $messageData An array with message data + * @return $messageInstance An instance of a DeliverableMessage class */ - public final function getMessageData () { - return $this->messageData; + public final function getMessageInstance () { + return $this->messageInstance; } } diff --git a/application/hub/classes/helper/node/answer/dht/class_NodeDhtBootstrapMessageAnswerHelper.php b/application/hub/classes/helper/node/answer/dht/class_NodeDhtBootstrapMessageAnswerHelper.php index 17742a1cb..936cc7c12 100644 --- a/application/hub/classes/helper/node/answer/dht/class_NodeDhtBootstrapMessageAnswerHelper.php +++ b/application/hub/classes/helper/node/answer/dht/class_NodeDhtBootstrapMessageAnswerHelper.php @@ -7,6 +7,7 @@ use Org\Shipsimu\Hub\Factory\Handler\Network\NetworkPackageHandlerFactory; use Org\Shipsimu\Hub\Factory\Network\NetworkPackageFactory; use Org\Shipsimu\Hub\Handler\Package\NetworkPackageHandler; use Org\Shipsimu\Hub\Helper\Node\HelpableNode; +use Org\Shipsimu\Hub\Network\Message\DeliverableMessage; use Org\Shipsimu\Hub\Node\Node; use Org\Shipsimu\Hub\Template\Engine\Xml\Dht\Bootstrap\XmlDhtBootstrapTemplateEngine; @@ -53,7 +54,7 @@ class NodeDhtBootstrapMessageAnswerHelper extends BaseHubAnswerHelper implements /** * Creates the helper class * - * @param $messageData An array with all message data + * @param $messageInstance An instance of a DeliverableMessage class * @return $helperInstance A prepared instance of this helper */ public final static function createNodeDhtBootstrapMessageAnswerHelper (DeliverableMessage $messageInstance) { @@ -65,7 +66,7 @@ class NodeDhtBootstrapMessageAnswerHelper extends BaseHubAnswerHelper implements $helperInstance->setRecipientId($messageData[XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_SESSION_ID]); // Set message data - $helperInstance->setMessageData($messageData); + $helperInstance->setMessageData($messageInstance); // Return the prepared instance return $helperInstance; diff --git a/application/hub/classes/helper/node/answer/requests/class_NodeRequestNodeListMessageAnswerHelper.php b/application/hub/classes/helper/node/answer/requests/class_NodeRequestNodeListMessageAnswerHelper.php index 41bdfb70f..8f7fe52b0 100644 --- a/application/hub/classes/helper/node/answer/requests/class_NodeRequestNodeListMessageAnswerHelper.php +++ b/application/hub/classes/helper/node/answer/requests/class_NodeRequestNodeListMessageAnswerHelper.php @@ -7,6 +7,7 @@ use Org\Shipsimu\Hub\Factory\Handler\Network\NetworkPackageHandlerFactory; use Org\Shipsimu\Hub\Factory\Network\NetworkPackageFactory; use Org\Shipsimu\Hub\Handler\Package\NetworkPackageHandler; use Org\Shipsimu\Hub\Helper\Node\HelpableNode; +use Org\Shipsimu\Hub\Network\Message\DeliverableMessage; use Org\Shipsimu\Hub\Node\Node; use Org\Shipsimu\Hub\Template\Engine\Xml\Request\NodeList\XmlRequestNodeListTemplateEngine; @@ -53,7 +54,7 @@ class NodeRequestNodeListMessageAnswerHelper extends BaseHubAnswerHelper impleme /** * Creates the helper class * - * @param $messageData An array with all message data + * @param $messageInstance An instance of a DeliverableMessage class * @return $helperInstance A prepared instance of this helper */ public final static function createNodeRequestNodeListMessageAnswerHelper (DeliverableMessage $messageInstance) { @@ -65,7 +66,7 @@ class NodeRequestNodeListMessageAnswerHelper extends BaseHubAnswerHelper impleme $helperInstance->setRecipientId($messageData[XmlRequestNodeListTemplateEngine::REQUEST_DATA_SESSION_ID]); // Set message data - $helperInstance->setMessageData($messageData); + $helperInstance->setMessageData($messageInstance); // Return the prepared instance return $helperInstance; diff --git a/application/hub/classes/nodes/class_BaseHubNode.php b/application/hub/classes/nodes/class_BaseHubNode.php index d83b0054f..88a432b1f 100644 --- a/application/hub/classes/nodes/class_BaseHubNode.php +++ b/application/hub/classes/nodes/class_BaseHubNode.php @@ -10,6 +10,7 @@ use Org\Shipsimu\Hub\Factory\State\Node\NodeStateFactory; use Org\Shipsimu\Hub\Locator\Node\LocateableNode; use Org\Shipsimu\Hub\Generic\BaseHubSystem; use Org\Shipsimu\Hub\Handler\Package\NetworkPackageHandler; +use Org\Shipsimu\Hub\Network\Message\DeliverableMessage; use Org\Shipsimu\Hub\Network\Receive\Receivable; use Org\Shipsimu\Hub\Template\Engine\Xml\Network\Answer\BaseXmlAnswerTemplateEngine; use Org\Shipsimu\Hub\Template\Engine\Xml\ObjectRegistry\XmlObjectRegistryTemplateEngine; @@ -799,15 +800,12 @@ abstract class BaseHubNode extends BaseHubSystem implements Updateable, AddableC /** * Handles message answer by given data array * - * @param $messageData A valid answer message data array + * @param $messageInstance An instance of a DeliverableMessage class * @param $packageInstance An instance of a Receivable class * @return void * @todo Handle thrown exception */ public function handleAnswerStatusByMessageInstance (DeliverableMessage $messageInstance, Receivable $packageInstance) { - // Is it not empty? - assert(!empty($messageData[BaseXmlAnswerTemplateEngine::ANSWER_STATUS])); - // Construct configuration entry for handling class' name $classConfigEntry = strtolower($messageData[NetworkPackageHandler::MESSAGE_ARRAY_TYPE] . '_status_' . $messageData[BaseXmlAnswerTemplateEngine::ANSWER_STATUS]) . '_handler_class'; @@ -815,7 +813,7 @@ abstract class BaseHubNode extends BaseHubSystem implements Updateable, AddableC $handlerInstance = ObjectFactory::createObjectByConfiguredName($classConfigEntry); // Handle it there - $handlerInstance->handleAnswerMessageData($messageData, $packageInstance); + $handlerInstance->handleAnswerMessageData($messageInstance, $packageInstance); } /** diff --git a/application/hub/interfaces/database/frontend/class_NodeDhtWrapper.php b/application/hub/interfaces/database/frontend/class_NodeDhtWrapper.php index acbd2b18d..2949a8b25 100644 --- a/application/hub/interfaces/database/frontend/class_NodeDhtWrapper.php +++ b/application/hub/interfaces/database/frontend/class_NodeDhtWrapper.php @@ -4,6 +4,7 @@ namespace Org\Shipsimu\Hub\Database\Frontend\Node\Dht; // Import application-specific stuff use Org\Shipsimu\Hub\Locator\Node\LocateableNode; +use Org\Shipsimu\Hub\Network\Message\DeliverableMessage; use Org\Shipsimu\Hub\Network\Package\DeliverablePackage; // Import framework stuff @@ -83,7 +84,7 @@ interface NodeDhtWrapper extends DatabaseWrapper { /** * Registeres a node by given message data. * - * @param $messageData An array of all message data + * @param $messageInstance An instance of a DeliverableMessage class * @param $handlerInstance An instance of a HandleableDataSet class * @return void */ @@ -92,7 +93,7 @@ interface NodeDhtWrapper extends DatabaseWrapper { /** * Updates an existing entry in node list * - * @param $messageData An array of all message data + * @param $messageInstance An instance of a DeliverableMessage class * @param $handlerInstance An instance of a HandleableDataSet class * @param $searchInstance An instance of LocalSearchCriteria class * @return void diff --git a/application/hub/interfaces/distributable/node/class_DistributableNode.php b/application/hub/interfaces/distributable/node/class_DistributableNode.php index a8af1d62d..0699f318c 100644 --- a/application/hub/interfaces/distributable/node/class_DistributableNode.php +++ b/application/hub/interfaces/distributable/node/class_DistributableNode.php @@ -5,6 +5,7 @@ namespace Org\Shipsimu\Hub\Dht\Node; // Import application-specific stuff use Org\Shipsimu\Hub\Dht\Distributable; use Org\Shipsimu\Hub\Locator\Node\LocateableNode; +use Org\Shipsimu\Hub\Network\Message\DeliverableMessage; // Import framework stuff use Org\Mxchange\CoreFramework\Handler\DataSet\HandleableDataSet; @@ -56,7 +57,7 @@ interface DistributableNode extends Distributable { * - external-address (hostname or IP number) * - listen-port (TCP/UDP listen port for inbound connections) * - * @param $messageData An array with all minimum message data + * @param $messageData An instance of a DeliverableMessage class * @param $handlerInstance An instance of a HandleableDataSet class * @param $forceUpdate Optionally force update, don't register (default: register if not found) * @return void @@ -67,7 +68,7 @@ interface DistributableNode extends Distributable { * Queries the local DHT data(base) for a node list with all supported * object types except the node by given session id. * - * @param $messageData An array with message data from a node_list request + * @param $messageData An instance of a DeliverableMessage class * @param $handlerInstance An instance of a HandleableDataSet class * @param $excludeKey Array key which should be excluded * @param $andKey Array of $separator-separated list of elements which all must match diff --git a/application/hub/interfaces/filter/class_FilterablePackage.php b/application/hub/interfaces/filter/class_FilterablePackage.php index 53a3501e0..fd27add69 100644 --- a/application/hub/interfaces/filter/class_FilterablePackage.php +++ b/application/hub/interfaces/filter/class_FilterablePackage.php @@ -3,6 +3,7 @@ namespace Org\Shipsimu\Hub\Filter\Network; // Import application-specific stuff +use Org\Shipsimu\Hub\Network\Message\DeliverableMessage; use Org\Shipsimu\Hub\Network\Receive\Receivable; // Import framework stuff @@ -48,7 +49,5 @@ interface FilterablePackage extends Filterable { * @return void */ function postProcessMessage (Receivable $packageInstance); -} -// [EOF] -?> +} diff --git a/application/hub/interfaces/handler/answer-status/class_HandleableAnswerStatus.php b/application/hub/interfaces/handler/answer-status/class_HandleableAnswerStatus.php index f3883719f..58c94f383 100644 --- a/application/hub/interfaces/handler/answer-status/class_HandleableAnswerStatus.php +++ b/application/hub/interfaces/handler/answer-status/class_HandleableAnswerStatus.php @@ -4,6 +4,7 @@ namespace Org\Shipsimu\Hub\AnswerStatus\Node; // Import application-specific stuff use Org\Shipsimu\Hub\Generic\HubInterface; +use Org\Shipsimu\Hub\Network\Message\DeliverableMessage; use Org\Shipsimu\Hub\Network\Receive\Receivable; // Import framework stuff diff --git a/application/hub/interfaces/handler/message-types/class_HandleableMessage.php b/application/hub/interfaces/handler/message-types/class_HandleableMessage.php index 0f3859200..74042102b 100644 --- a/application/hub/interfaces/handler/message-types/class_HandleableMessage.php +++ b/application/hub/interfaces/handler/message-types/class_HandleableMessage.php @@ -4,6 +4,7 @@ namespace Org\Shipsimu\Hub\Handler\Message; // Import application-specific stuff use Org\Shipsimu\Hub\Generic\HubInterface; +use Org\Shipsimu\Hub\Network\Message\DeliverableMessage; use Org\Shipsimu\Hub\Network\Receive\Receivable; // Import framework stuff @@ -35,7 +36,7 @@ interface HandleableMessage extends HandleableDataSet, HubInterface { /** * Handles data array of the message * - * @param $messageData An array with message data to handle + * @param $messageData An instance of a DeliverableMessage class * @param $packageInstance An instance of a Receivable class * @return void */ @@ -44,7 +45,7 @@ interface HandleableMessage extends HandleableDataSet, HubInterface { /** * Posty-handles data array of the message * - * @param $messageData An array with message data to handle + * @param $messageData An instance of a DeliverableMessage class * @param $packageInstance An instance of a Receivable class * @return void */ diff --git a/application/hub/interfaces/nodes/class_Node.php b/application/hub/interfaces/nodes/class_Node.php index 9c3b976a6..807f122e9 100644 --- a/application/hub/interfaces/nodes/class_Node.php +++ b/application/hub/interfaces/nodes/class_Node.php @@ -3,6 +3,7 @@ namespace Org\Shipsimu\Hub\Node; // Import application-specific stuff +use Org\Shipsimu\Hub\Network\Message\DeliverableMessage; use Org\Shipsimu\Hub\Network\Receive\Receivable; // Import framework stuff diff --git a/application/hub/interfaces/receiver/class_Receivable.php b/application/hub/interfaces/receiver/class_Receivable.php index 14554adc6..efaa98af9 100644 --- a/application/hub/interfaces/receiver/class_Receivable.php +++ b/application/hub/interfaces/receiver/class_Receivable.php @@ -4,6 +4,7 @@ namespace Org\Shipsimu\Hub\Network\Receive; // Import application-specific stuff use Org\Shipsimu\Hub\Network\Networkable; +use Org\Shipsimu\Hub\Network\Message\DeliverableMessage; use Org\Shipsimu\Hub\Network\Package\DeliverablePackage; // Import application-specific stuff @@ -151,7 +152,7 @@ interface Receivable extends HubInterface { * leads to an endless loop. You may wish to run the miner to get some * reward ("Hubcoins") for "mining" this hash. * - * @param $messageData Array with message data + * @param $messageInstance An instance of a DeliverableMessage class * @return void */ function feedHashToMiner (DeliverableMessage $messageInstance); -- 2.39.5