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
/**
* 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
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());
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;
/**
* 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
*/
$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);
/**
* 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
$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);
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
* - 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
*/
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
// 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
* 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
* @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
// 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
* 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));
// 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;
* 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);
}
/**
// Please don't call this method
throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
}
-}
-// [EOF]
-?>
+}
// 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;
* 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);
}
/**
// Please don't call this method
throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
}
-}
-// [EOF]
-?>
+}
// 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;
* 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);
}
/**
// Please don't call this method
throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
}
-}
-// [EOF]
-?>
+}
// 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
* 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);
}
/**
// Please don't call this method
throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
}
-}
-// [EOF]
-?>
+}
// 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;
* 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);
}
/**
// Please don't call this method
throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
}
-}
-// [EOF]
-?>
+}
// 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;
/**
* 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);
}
/**
// Please don't call this method
throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
}
-}
-// [EOF]
-?>
+}
// 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;
* 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);
}
/**
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;
/**
* 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?
* 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');
$nodeInstance->getStateInstance()->nodeAnnouncementSuccessful();
// Prepare next message
- $this->prepareNextMessage($messageData, $packageInstance);
+ $this->prepareNextMessage($messageInstance, $packageInstance);
}
/**
* 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) {
/**
* 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) {
// 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;
/**
* 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]));
* 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);
}
/**
* 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
*/
/**
* 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
*/
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;
/**
* 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
*/
//* 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 ...');
* 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();
/*
* 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.');
/**
* 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
*/
//* 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();
* 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();
/*
* 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.');
/**
* 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);
* 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);
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;
/**
* 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
* 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) {
/**
* 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]);
* 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) {
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;
/**
* 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
* 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) {
/**
* 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
*/
* 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
*/
// Please don't call this method
throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
}
-}
-// [EOF]
-?>
+}
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;
/**
* 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
* 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) {
/**
* 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
*/
* 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
*/
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;
/**
* 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
* 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) {
/**
* 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
*/
* 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
*/
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
* - 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) {
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
*/
* Feed hash to miner by handling over the whole array as also the
* sender and tags are needed.
*/
- $packageInstance->feedHashToMiner($messageData);
+ $packageInstance->feedHashToMiner($messageInstance);
}
}
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;
/**
* 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
/*
* 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) {
/**
* 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
* 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) {
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;
/**
* 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
* 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) {
/**
* 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) {
// 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,
* 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) {
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;
/**
* 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
*/
} 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)));
}
}
* 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);
/**
* 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
*/
/**
* 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
*/
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;
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];
* 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
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];
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?
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)));
}
}
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;
/**
* 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) {
$helperInstance->setRecipientId($messageData[XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID]);
// Set message data
- $helperInstance->setMessageData($messageData);
+ $helperInstance->setMessageData($messageInstance);
// Return the prepared instance
return $helperInstance;
// 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
*/
abstract class BaseHubAnswerHelper extends BaseNodeHelper {
/**
- * Message data array
+ * Message instance
*/
- private $messageData = array();
+ private $messageInstance = NULL;
/**
* Protected constructor
/**
* 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;
}
}
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;
/**
* 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) {
$helperInstance->setRecipientId($messageData[XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_SESSION_ID]);
// Set message data
- $helperInstance->setMessageData($messageData);
+ $helperInstance->setMessageData($messageInstance);
// Return the prepared instance
return $helperInstance;
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;
/**
* 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) {
$helperInstance->setRecipientId($messageData[XmlRequestNodeListTemplateEngine::REQUEST_DATA_SESSION_ID]);
// Set message data
- $helperInstance->setMessageData($messageData);
+ $helperInstance->setMessageData($messageInstance);
// Return the prepared instance
return $helperInstance;
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;
/**
* 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';
$handlerInstance = ObjectFactory::createObjectByConfiguredName($classConfigEntry);
// Handle it there
- $handlerInstance->handleAnswerMessageData($messageData, $packageInstance);
+ $handlerInstance->handleAnswerMessageData($messageInstance, $packageInstance);
}
/**
// 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
/**
* 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
*/
/**
* 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
// 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;
* - 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
* 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
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
* @return void
*/
function postProcessMessage (Receivable $packageInstance);
-}
-// [EOF]
-?>
+}
// 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
// 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
/**
* 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
*/
/**
* 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
*/
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
// 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
* 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);