From: Roland Häder Date: Thu, 14 Feb 2013 22:21:13 +0000 (+0000) Subject: Renamed/moved classes, added DHT bootstrap (very early): X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=2bd4df2e5d50173c1f8fa2fddc8bf8f93b437afb;hp=d881b2f4a7fa73f602827188f5c83e8c9315b008;p=hub.git Renamed/moved classes, added DHT bootstrap (very early): - Added very early and untested code for DHT bootstrap - To make things easier, more HubFooBar classes has been renamed to NodeFooBar - Also they have to be moved to a new place to fit class prefix --- diff --git a/.gitattributes b/.gitattributes index 6a9d5e874..e74efdf52 100644 --- a/.gitattributes +++ b/.gitattributes @@ -81,10 +81,14 @@ application/hub/interfaces/handler/task/.htaccess -text svneol=unset#text/plain application/hub/interfaces/handler/task/class_HandleableTask.php svneol=native#text/plain application/hub/interfaces/helper/.htaccess -text svneol=unset#text/plain application/hub/interfaces/helper/connections/.htaccess -text +application/hub/interfaces/helper/dht/.htaccess -text svneol=unset#text/plain +application/hub/interfaces/helper/dht/class_HelpableDht.php svneol=native#text/plain application/hub/interfaces/helper/hub/.htaccess -text svneol=unset#text/plain application/hub/interfaces/helper/hub/class_HelpableHub.php svneol=native#text/plain application/hub/interfaces/helper/messages/.htaccess svneol=native#text/plain application/hub/interfaces/helper/messages/class_MessageHelper.php svneol=native#text/plain +application/hub/interfaces/helper/node/.htaccess -text svneol=unset#text/plain +application/hub/interfaces/helper/node/class_HelpableNode.php svneol=native#text/plain application/hub/interfaces/helper/nodes/.htaccess -text svneol=unset#text/plain application/hub/interfaces/helper/nodes/class_NodeHelper.php svneol=native#text/plain application/hub/interfaces/listener/.htaccess -text svneol=unset#text/plain @@ -393,12 +397,16 @@ application/hub/main/handler/network/udp/class_UdpRawDataHandler.php svneol=nati application/hub/main/handler/tasks/.htaccess -text svneol=unset#text/plain application/hub/main/handler/tasks/class_TaskHandler.php svneol=native#text/plain application/hub/main/helper/.htaccess -text svneol=unset#text/plain +application/hub/main/helper/class_ svneol=native#text/plain +application/hub/main/helper/class_BaseHubSystemHelper.php svneol=native#text/plain application/hub/main/helper/connection/.htaccess -text svneol=unset#text/plain application/hub/main/helper/connection/class_BaseConnectionHelper.php svneol=native#text/plain application/hub/main/helper/connection/tcp/.htaccess -text svneol=unset#text/plain application/hub/main/helper/connection/tcp/class_TcpConnectionHelper.php svneol=native#text/plain application/hub/main/helper/connection/udp/.htaccess -text svneol=unset#text/plain application/hub/main/helper/connection/udp/class_UdpConnectionHelper.php svneol=native#text/plain +application/hub/main/helper/dht/.htaccess -text svneol=unset#text/plain +application/hub/main/helper/dht/class_DhtBootstrapHelper.php svneol=native#text/plain application/hub/main/helper/hub/.htaccess -text svneol=unset#text/plain application/hub/main/helper/hub/announcement/.htaccess -text svneol=unset#text/plain application/hub/main/helper/hub/announcement/class_HubAnnouncementHelper.php svneol=native#text/plain @@ -419,6 +427,21 @@ application/hub/main/helper/messages/.htaccess svneol=native#text/plain application/hub/main/helper/messages/class_BaseMessageHelper.php svneol=native#text/plain application/hub/main/helper/messages/crypto/.htaccess svneol=native#text/plain application/hub/main/helper/messages/crypto/class_CryptoRandomUnitMessageHelper.php svneol=native#text/plain +application/hub/main/helper/node/.htaccess -text svneol=unset#text/plain +application/hub/main/helper/node/announcement/.htaccess -text svneol=unset#text/plain +application/hub/main/helper/node/announcement/class_NodeAnnouncementHelper.php svneol=native#text/plain +application/hub/main/helper/node/answer/.htaccess -text svneol=unset#text/plain +application/hub/main/helper/node/answer/announcement/.htaccess -text svneol=unset#text/plain +application/hub/main/helper/node/answer/announcement/class_NodeAnnouncementMessageAnswerHelper.php svneol=native#text/plain +application/hub/main/helper/node/answer/class_BaseHubAnswerHelper.php svneol=native#text/plain +application/hub/main/helper/node/answer/requests/.htaccess -text svneol=unset#text/plain +application/hub/main/helper/node/answer/requests/class_NodeRequestNodeListMessageAnswerHelper.php svneol=native#text/plain +application/hub/main/helper/node/class_ svneol=native#text/plain +application/hub/main/helper/node/class_BaseNodeHelper.php svneol=native#text/plain +application/hub/main/helper/node/connection/.htaccess -text svneol=unset#text/plain +application/hub/main/helper/node/connection/class_NodeSelfConnectHelper.php svneol=native#text/plain +application/hub/main/helper/node/requests/.htaccess -text svneol=unset#text/plain +application/hub/main/helper/node/requests/class_NodeRequestNodeListHelper.php svneol=native#text/plain application/hub/main/helper/work_units/.htaccess svneol=native#text/plain application/hub/main/helper/work_units/class_BaseWorkUnitHelper.php svneol=native#text/plain application/hub/main/helper/work_units/cruncher/.htaccess svneol=native#text/plain @@ -656,6 +679,8 @@ application/hub/main/template/announcement/class_XmlAnnouncementTemplateEngine.p application/hub/main/template/answer/.htaccess -text svneol=unset#text/plain application/hub/main/template/answer/announcement/.htaccess -text svneol=unset#text/plain application/hub/main/template/answer/requests/.htaccess -text svneol=unset#text/plain +application/hub/main/template/bootstrap/.htaccess -text svneol=unset#text/plain +application/hub/main/template/bootstrap/class_XmlBootstrapTemplateEngine.php svneol=native#text/plain application/hub/main/template/connect/.htaccess -text svneol=unset#text/plain application/hub/main/template/connect/class_XmlSelfConnectTemplateEngine.php svneol=native#text/plain application/hub/main/template/entries/.htaccess -text svneol=unset#text/plain diff --git a/application/hub/config.php b/application/hub/config.php index 8faa8734c..bdfcb0835 100644 --- a/application/hub/config.php +++ b/application/hub/config.php @@ -127,10 +127,13 @@ $cfg->setConfigEntry('node_raw_data_monitor_visitor_class', 'RawDataPoolMonitorV $cfg->setConfigEntry('list_group_class', 'ListGroupList'); // CFG: NODE-ANNOUNCEMENT-HELPER-CLASS -$cfg->setConfigEntry('node_announcement_helper_class', 'HubAnnouncementHelper'); +$cfg->setConfigEntry('node_announcement_helper_class', 'NodeAnnouncementHelper'); // CFG: NODE-SELF-CONNECT-HELPER-CLASS -$cfg->setConfigEntry('node_self_connect_helper_class', 'HubSelfConnectHelper'); +$cfg->setConfigEntry('node_self_connect_helper_class', 'NodeSelfConnectHelper'); + +// CFG: DHT-BOOTSTRAP-HELPER-CLASS +$cfg->setConfigEntry('dht_bootstrap_helper_class', 'DhtBootstrapHelper'); // CFG: DEFAULT-CONSOLE-COMMAND $cfg->setConfigEntry('default_console_command', 'main'); @@ -249,6 +252,9 @@ $cfg->setConfigEntry('node_request_node_list_answer_template_class', 'XmlRequest // CFG: NODE-REQUEST-NODE-LIST-ENTRIES-TEMPLATE-CLASS $cfg->setConfigEntry('node_request_node_list_entries_template_class', 'XmlRequestNodeListEntryTemplateEngine'); +// CFG: DHT-BOOTSTRAP-TEMPLATE-CLASS +$cfg->setConfigEntry('dht_bootstrap_template_class', 'XmlBootstrapTemplateEngine'); + // CFG: NODE-MESSAGE-TEMPLATE-EXTENSION $cfg->setConfigEntry('node_message_template_extension', '.xml'); diff --git a/application/hub/interfaces/helper/dht/.htaccess b/application/hub/interfaces/helper/dht/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/interfaces/helper/dht/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/interfaces/helper/dht/class_HelpableDht.php b/application/hub/interfaces/helper/dht/class_HelpableDht.php new file mode 100644 index 000000000..cb684c6a2 --- /dev/null +++ b/application/hub/interfaces/helper/dht/class_HelpableDht.php @@ -0,0 +1,42 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface HelpableDht extends Helper { + /** + * Loads the descriptor XML file + * + * @return void + */ + function loadDescriptorXml (); + + /** + * Send a package out + * + * @param $dhtInstance An instance of a Distributable class + * @return void + */ + function sendPackage (Distributable $dhtInstance); +} + +// [EOF] +?> diff --git a/application/hub/interfaces/helper/hub/class_HelpableHub.php b/application/hub/interfaces/helper/hub/class_HelpableHub.php index 5c611a984..f551ef47b 100644 --- a/application/hub/interfaces/helper/hub/class_HelpableHub.php +++ b/application/hub/interfaces/helper/hub/class_HelpableHub.php @@ -1,43 +1,3 @@ - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -interface HelpableHub extends Helper { - /** - * Loads the descriptor XML file - * - * @param $nodeInstance An instance of a NodeHelper class - * @return void - */ - function loadDescriptorXml (NodeHelper $nodeInstance); - - /** - * Send a package out - * - * @param $nodeInstance An instance of a NodeHelper class - * @return void - */ - function sendPackage (NodeHelper $nodeInstance); -} - -// [EOF] +// @DEPRECATED ?> diff --git a/application/hub/interfaces/helper/node/.htaccess b/application/hub/interfaces/helper/node/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/interfaces/helper/node/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/interfaces/helper/node/class_HelpableNode.php b/application/hub/interfaces/helper/node/class_HelpableNode.php new file mode 100644 index 000000000..fd3d46bbe --- /dev/null +++ b/application/hub/interfaces/helper/node/class_HelpableNode.php @@ -0,0 +1,43 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +interface HelpableNode extends Helper { + /** + * Loads the descriptor XML file + * + * @param $nodeInstance An instance of a NodeHelper class + * @return void + */ + function loadDescriptorXml (NodeHelper $nodeInstance); + + /** + * Send a package out + * + * @param $nodeInstance An instance of a NodeHelper class + * @return void + */ + function sendPackage (NodeHelper $nodeInstance); +} + +// [EOF] +?> diff --git a/application/hub/interfaces/package/class_Deliverable.php b/application/hub/interfaces/package/class_Deliverable.php index 72d4ed139..bf854dc06 100644 --- a/application/hub/interfaces/package/class_Deliverable.php +++ b/application/hub/interfaces/package/class_Deliverable.php @@ -27,11 +27,11 @@ interface Deliverable extends FrameworkInterface { * from given helper's template instance and pushing it on the 'undeclared' * stack. * - * @param $helperInstance An instance of a HelpableHub class + * @param $helperInstance An instance of a HelpableNode class * @param $protocol Name of used protocol (TCP/UDP) * @return void */ - function enqueueRawDataFromTemplate (HelpableHub $helperInstance, $protocol); + function enqueueRawDataFromTemplate (HelpableNode $helperInstance, $protocol); /** * Checks whether a package has been enqueued for delivery. diff --git a/application/hub/main/helper/class_ b/application/hub/main/helper/class_ new file mode 100644 index 000000000..d3888ea45 --- /dev/null +++ b/application/hub/main/helper/class_ @@ -0,0 +1,86 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * @todo Find an interface for hub helper + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class !!!???Helper extends BaseHubSystemHelper implements Helpable!!! { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set recipient type + $this->setRecipientType(NetworkPackage::NETWORK_TARGET_!!!); + + // Set package tags + $this->setPackageTags(array('???')); + } + + /** + * Creates the helper class + * + * @return $helperInstance A prepared instance of this helper + */ + public final static function create!!!???Helper () { + // Get new instance + $helperInstance = new !!!???Helper(); + + // Return the prepared instance + return $helperInstance; + } + + /** + * Loads the descriptor XML file + * + * @return void + */ + public function loadDescriptorXml () { + $this->partialStub('Please implement this method.'); + } + + /** + * Do the helped attempt by delivering a package to ourselfs + * + * @param $|||Instance An instance of a !!!Helper class + * @return void + */ + public function sendPackage (!!!Helper $|||Instance) { + // Sanity check: Is the ||| in the approx. state? (///) + $|||Instance->getStateInstance()->validate!!!StateIs+++(); + + // Compile the template, this inserts the loaded ||| data into the gaps. + $this->getTemplateInstance()->compileTemplate(); + + // Get a singleton network package instance + $packageInstance = NetworkPackageFactory::createNetworkPackageInstance(); + + // Next, feed the content in. The network package class is a pipe-through class. + $packageInstance->enqueueRawDataFromTemplate($this, NetworkPackage::PROTOCOL_TCP); + } +} + +// [EOF] +?> diff --git a/application/hub/main/helper/class_BaseHubSystemHelper.php b/application/hub/main/helper/class_BaseHubSystemHelper.php new file mode 100644 index 000000000..79b80d1a5 --- /dev/null +++ b/application/hub/main/helper/class_BaseHubSystemHelper.php @@ -0,0 +1,85 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseHubSystemHelper extends BaseHubSystem { + /** + * Recipient type + */ + private $recipientType = 'invalid'; + + /** + * Package tags + */ + private $packageTags = array(); + + /** + * Protected constructor + * + * @param $className Name of the concrete class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } + + /** + * Setter for recipient type + * + * @return $recipientType Type of a recipient (the helper is made for) + */ + protected final function setRecipientType ($recipientType) { + $this->recipientType = $recipientType; + } + + /** + * Getter for recipient type + * + * @return $recipientType Type of a recipient (the helper is made for) + */ + public final function getRecipientType () { + return $this->recipientType; + } + + /** + * Getter for package tags in a simple array + * + * @return $packageTags An array with all tags for the currently handled package + */ + public final function getPackageTags () { + return $this->packageTags; + } + + /** + * Setter for package tags in a simple array + * + * @param $packageTags An array with all tags for the currently handled package + * @return void + */ + public final function setPackageTags (array $packageTags) { + $this->packageTags = $packageTags; + } +} + +// [EOF] +?> diff --git a/application/hub/main/helper/dht/.htaccess b/application/hub/main/helper/dht/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/main/helper/dht/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/main/helper/dht/class_DhtBootstrapHelper.php b/application/hub/main/helper/dht/class_DhtBootstrapHelper.php new file mode 100644 index 000000000..110bf25ea --- /dev/null +++ b/application/hub/main/helper/dht/class_DhtBootstrapHelper.php @@ -0,0 +1,97 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * @todo Find an interface for hub helper + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class DhtBootstrapHelper extends BaseHubSystemHelper implements HelpableDht { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set recipient type + $this->setRecipientType(NetworkPackage::NETWORK_TARGET_DHT); + } + + /** + * Creates the helper class + * + * @return $helperInstance A prepared instance of this helper + */ + public final static function createDhtBootstrapHelper () { + // Get new instance + $helperInstance = new DhtBootstrapHelper(); + + // Return the prepared instance + return $helperInstance; + } + + /** + * Loads the announcement descriptor for parsing + * + * @return void + */ + public function loadDescriptorXml () { + // Debug message + self::createDebugInstance(__CLASS__)->debugOutput('HELPER: Starting with DHT boostrap ...'); + + // Get a XML template instance + $templateInstance = XmlTemplateEngineFactory::createXmlTemplateEngineInstance('dht_bootstrap_template_class'); + + // Set it for later use + $this->setTemplateInstance($templateInstance); + + // Read the XML descriptor + $templateInstance->loadXmlTemplate(); + + // Render the XML content + $templateInstance->renderXmlContent(); + } + } + + /** + * Do the helped attempt by delivering a package to ourselfs + * + * @param $dhtInstance An instance of a Distributable class + * @return void + */ + public function sendPackage (Distributable $dhtInstance) { + // Sanity check: Is the dht in the approx. state? (init) + $dhtInstance->getStateInstance()->validateDhtStateIsInitialized(); + + // Compile the template, this inserts the loaded dht data into the gaps. + $this->getTemplateInstance()->compileTemplate(); + + // Get a singleton network package instance + $packageInstance = NetworkPackageFactory::createNetworkPackageInstance(); + + // Next, feed the content in. The network package class is a pipe-through class. + $packageInstance->enqueueRawDataFromTemplate($this, NetworkPackage::PROTOCOL_TCP); + } +} + +// [EOF] +?> diff --git a/application/hub/main/helper/hub/announcement/class_HubAnnouncementHelper.php b/application/hub/main/helper/hub/announcement/class_HubAnnouncementHelper.php index 06d4d5571..f551ef47b 100644 --- a/application/hub/main/helper/hub/announcement/class_HubAnnouncementHelper.php +++ b/application/hub/main/helper/hub/announcement/class_HubAnnouncementHelper.php @@ -1,104 +1,3 @@ - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * @todo Find an interface for hub helper - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class HubAnnouncementHelper extends BaseHubHelper implements HelpableHub { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set recipient type - $this->setRecipientType(NetworkPackage::NETWORK_TARGET_UPPER_NODES); - - // Set package tags - $this->setPackageTags(array('announcement')); - } - - /** - * Creates the helper class - * - * @return $helperInstance A prepared instance of this helper - */ - public static final function createHubAnnouncementHelper () { - // Get new instance - $helperInstance = new HubAnnouncementHelper(); - - // Return the prepared instance - return $helperInstance; - } - - /** - * Loads the announcement descriptor for parsing - * - * @param $nodeInstance An instance of a NodeHelper class - * @return void - */ - public function loadDescriptorXml (NodeHelper $nodeInstance) { - // Debug message - self::createDebugInstance(__CLASS__)->debugOutput('HELPER: Starting with announcement to upper hubs...'); - - // Get a XML template instance - $templateInstance = XmlTemplateEngineFactory::createXmlTemplateEngineInstance('node_announcement_template_class'); - - // Set it for later use - $this->setTemplateInstance($templateInstance); - - // Read the XML descriptor - $templateInstance->loadXmlTemplate(); - - // Render the XML content - $templateInstance->renderXmlContent(); - } - - /** - * Publishes the node's descriptor XML to all found upper nodes when the - * node has not yet published it's descriptor to a bootstrap node. This is - * done by getting the raw XML content and inserting all variables into - * the code. After this wents fine, the rendered content got "packaged" - * for network delivery. - * - * @param $nodeInstance An instance of a NodeHelper class - * @return void - */ - public function sendPackage (NodeHelper $nodeInstance) { - // Sanity check: Is the node in the approx. state? (active) - $nodeInstance->getStateInstance()->validateNodeStateIsActiveOrReachable(); - - // Compile the template, this inserts the loaded node data into the gaps. - $this->getTemplateInstance()->compileTemplate(); - - // Get a singleton network package instance - $packageInstance = NetworkPackageFactory::createNetworkPackageInstance(); - - // Next, feed the content in. The network package class is a pipe-through class. - $packageInstance->enqueueRawDataFromTemplate($this, NetworkPackage::PROTOCOL_TCP); - } -} - -// [EOF] +// @DEPRECATED ?> diff --git a/application/hub/main/helper/hub/answer/announcement/class_NodeAnnouncementMessageAnswerHelper.php b/application/hub/main/helper/hub/answer/announcement/class_NodeAnnouncementMessageAnswerHelper.php index 77a24360e..f551ef47b 100644 --- a/application/hub/main/helper/hub/answer/announcement/class_NodeAnnouncementMessageAnswerHelper.php +++ b/application/hub/main/helper/hub/answer/announcement/class_NodeAnnouncementMessageAnswerHelper.php @@ -1,104 +1,3 @@ - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * @todo Find an interface for hub helper - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class NodeAnnouncementMessageAnswerHelper extends BaseHubAnswerHelper implements HelpableHub { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Init package tags - $this->setPackageTags(array('announcement_answer')); - } - - /** - * Creates the helper class - * - * @param $messageData An array with all message data - * @return $helperInstance A prepared instance of this helper - */ - public final static function createNodeAnnouncementMessageAnswerHelper (array $messageData) { - // Get new instance - $helperInstance = new NodeAnnouncementMessageAnswerHelper(); - - // Set session id of other peer as recipient - $helperInstance->setRecipientType($messageData[XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID]); - - // Set message data - $helperInstance->setMessageData($messageData); - - // Return the prepared instance - return $helperInstance; - } - - /** - * Loads the descriptor XML file - * - * @param $nodeInstance An instance of a NodeHelper class - * @return void - */ - public function loadDescriptorXml (NodeHelper $nodeInstance) { - // Debug message - self::createDebugInstance(__CLASS__)->debugOutput('HELPER: Attempting to answer an announcement...'); - - // Get a XML template instance - $templateInstance = XmlTemplateEngineFactory::createXmlTemplateEngineInstance('node_announcement_answer_template_class'); - - // Set it for later use - $this->setTemplateInstance($templateInstance); - - // Read the XML descriptor - $templateInstance->loadXmlTemplate(); - - // Render the XML content - $templateInstance->renderXmlContent(); - } - - /** - * Send out announcement answer package - * - * @param $nodeInstance An instance of a NodeHelper class - * @return void - */ - public function sendPackage (NodeHelper $nodeInstance) { - // Sanity check: Is the node in the approx. state? (active/reachable) - $nodeInstance->getStateInstance()->validateNodeStateIsActiveOrReachable(); - - // Compile the template, this inserts the loaded node data into the gaps. - $this->getTemplateInstance()->compileTemplate(); - - // Get a singleton network package instance - $packageInstance = NetworkPackageFactory::createNetworkPackageInstance(); - - // Next, feed the content in. The network package class is a pipe-through class. - $packageInstance->enqueueRawDataFromTemplate($this, NetworkPackage::PROTOCOL_TCP); - } -} - -// [EOF] +// @DEPRECATED ?> diff --git a/application/hub/main/helper/hub/answer/class_BaseHubAnswerHelper.php b/application/hub/main/helper/hub/answer/class_BaseHubAnswerHelper.php index c5850d249..f551ef47b 100644 --- a/application/hub/main/helper/hub/answer/class_BaseHubAnswerHelper.php +++ b/application/hub/main/helper/hub/answer/class_BaseHubAnswerHelper.php @@ -1,61 +1,3 @@ - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class BaseHubAnswerHelper extends BaseHubHelper { - /** - * Message data array - */ - private $messageData = array(); - - /** - * Protected constructor - * - * @param $className Name of the concrete class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - } - - /** - * Setter for message data - * - * @return $messageData An array with message data - */ - protected final function setMessageData (array $messageData) { - $this->messageData = $messageData; - } - - /** - * Getter for message data - * - * @return $messageData An array with message data - */ - public final function getMessageData () { - return $this->messageData; - } -} - -// [EOF] +// @DEPRECATED ?> diff --git a/application/hub/main/helper/hub/answer/requests/class_NodeRequestNodeListMessageAnswerHelper.php b/application/hub/main/helper/hub/answer/requests/class_NodeRequestNodeListMessageAnswerHelper.php index 6926ed28f..f551ef47b 100644 --- a/application/hub/main/helper/hub/answer/requests/class_NodeRequestNodeListMessageAnswerHelper.php +++ b/application/hub/main/helper/hub/answer/requests/class_NodeRequestNodeListMessageAnswerHelper.php @@ -1,110 +1,3 @@ - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * @todo Find an interface for hub helper - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class NodeRequestNodeListMessageAnswerHelper extends BaseHubAnswerHelper implements HelpableHub { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Init package tags - $this->setPackageTags(array('request_node_list_answer')); - } - - /** - * Creates the helper class - * - * @param $messageData An array with all message data - * @return $helperInstance A prepared instance of this helper - */ - public final static function createNodeRequestNodeListMessageAnswerHelper (array $messageData) { - // Get new instance - $helperInstance = new NodeRequestNodeListMessageAnswerHelper(); - - // Set session id of other peer as recipient - $helperInstance->setRecipientType($messageData[XmlRequestNodeListTemplateEngine::REQUEST_DATA_SESSION_ID]); - - // Set message data - $helperInstance->setMessageData($messageData); - - // Return the prepared instance - return $helperInstance; - } - - /** - * Loads the descriptor XML file - * - * @param $nodeInstance An instance of a NodeHelper class - * @return void - */ - public function loadDescriptorXml (NodeHelper $nodeInstance) { - // Debug message - self::createDebugInstance(__CLASS__)->debugOutput('HELPER: Attempting to answer a request: node-list...'); - - // Get a XML template instance - $templateInstance = XmlTemplateEngineFactory::createXmlTemplateEngineInstance('node_request_node_list_answer_template_class'); - - // Set it for later use - $this->setTemplateInstance($templateInstance); - - // Read the XML descriptor - $templateInstance->loadXmlTemplate(); - - // "Cache" entries instance for next foreach loop - $entriesInstance = $templateInstance->getTemplateInstance(); - - // Is must not be NULL (then it can only be a template instance) - assert(!is_null($entriesInstance)); - - // Render the XML content - $templateInstance->renderXmlContent(); - } - - /** - * Send out request-node-list answer package - * - * @param $nodeInstance An instance of a NodeHelper class - * @return void - */ - public function sendPackage (NodeHelper $nodeInstance) { - // Sanity check: Is the node in the approx. state? (active/reachable) - $nodeInstance->getStateInstance()->validateNodeStateIsActiveOrReachable(); - - // Compile the template, this inserts the loaded node data into the gaps. - $this->getTemplateInstance()->compileTemplate(); - - // Get a singleton network package instance - $packageInstance = NetworkPackageFactory::createNetworkPackageInstance(); - - // Next, feed the content in. The network package class is a pipe-through class. - $packageInstance->enqueueRawDataFromTemplate($this, NetworkPackage::PROTOCOL_TCP); - } -} - -// [EOF] +// @DEPRECATED ?> diff --git a/application/hub/main/helper/hub/class_ b/application/hub/main/helper/hub/class_ index 337a1d730..f551ef47b 100644 --- a/application/hub/main/helper/hub/class_ +++ b/application/hub/main/helper/hub/class_ @@ -1,83 +1,3 @@ - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * @todo Find an interface for hub helper - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class Hub???Helper extends BaseHubHelper implements HelpableHub { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set recipient type - $this->setRecipientType(NetworkPackage::NETWORK_TARGET_!!!); - } - - /** - * Creates the helper class - * - * @return $helperInstance A prepared instance of this helper - */ - public final static function createHub???Helper () { - // Get new instance - $helperInstance = new Hub???Helper(); - - // Return the prepared instance - return $helperInstance; - } - - /** - * Loads the descriptor XML file - * - * @return void - */ - public function loadDescriptorXml () { - $this->partialStub('Please implement this method.'); - } - - /** - * Do the helped attempt by delivering a package to ourselfs - * - * @param $nodeInstance An instance of a NodeHelper class - * @return void - */ - public function sendPackage (NodeHelper $nodeInstance) { - // Sanity check: Is the node in the approx. state? (active) - $nodeInstance->getStateInstance()->validateNodeStateIsActive(); - - // Compile the template, this inserts the loaded node data into the gaps. - $this->getTemplateInstance()->compileTemplate(); - - // Get a singleton network package instance - $packageInstance = NetworkPackageFactory::createNetworkPackageInstance(); - - // Next, feed the content in. The network package class is a pipe-through class. - $packageInstance->enqueueRawDataFromTemplate($this, NetworkPackage::PROTOCOL_|||); - } -} - -// [EOF] +// @DEPRECATED ?> diff --git a/application/hub/main/helper/hub/class_BaseHubHelper.php b/application/hub/main/helper/hub/class_BaseHubHelper.php index 0cb1458b8..f551ef47b 100644 --- a/application/hub/main/helper/hub/class_BaseHubHelper.php +++ b/application/hub/main/helper/hub/class_BaseHubHelper.php @@ -1,85 +1,3 @@ - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class BaseHubHelper extends BaseHubSystem { - /** - * Recipient type - */ - private $recipientType = 'invalid'; - - /** - * Package tags - */ - private $packageTags = array(); - - /** - * Protected constructor - * - * @param $className Name of the concrete class - * @return void - */ - protected function __construct ($className) { - // Call parent constructor - parent::__construct($className); - } - - /** - * Setter for recipient type - * - * @return $recipientType Type of a recipient (the helper is made for) - */ - protected final function setRecipientType ($recipientType) { - $this->recipientType = $recipientType; - } - - /** - * Getter for recipient type - * - * @return $recipientType Type of a recipient (the helper is made for) - */ - public final function getRecipientType () { - return $this->recipientType; - } - - /** - * Getter for package tags in a simple array - * - * @return $packageTags An array with all tags for the currently handled package - */ - public final function getPackageTags () { - return $this->packageTags; - } - - /** - * Setter for package tags in a simple array - * - * @param $packageTags An array with all tags for the currently handled package - * @return void - */ - public final function setPackageTags (array $packageTags) { - $this->packageTags = $packageTags; - } -} - -// [EOF] +// @DEPRECATED ?> diff --git a/application/hub/main/helper/hub/connection/class_HubSelfConnectHelper.php b/application/hub/main/helper/hub/connection/class_HubSelfConnectHelper.php index 7953f8513..f551ef47b 100644 --- a/application/hub/main/helper/hub/connection/class_HubSelfConnectHelper.php +++ b/application/hub/main/helper/hub/connection/class_HubSelfConnectHelper.php @@ -1,100 +1,3 @@ - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * @todo Find an interface for hub helper - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class HubSelfConnectHelper extends BaseHubHelper implements HelpableHub { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set recipient type - $this->setRecipientType(NetworkPackage::NETWORK_TARGET_SELF); - - // Set package tags - $this->setPackageTags(array('self_connect')); - } - - /** - * Creates the helper class - * - * @return $helperInstance A prepared instance of this helper - */ - public static final function createHubSelfConnectHelper () { - // Get new instance - $helperInstance = new HubSelfConnectHelper(); - - // Return the prepared instance - return $helperInstance; - } - - /** - * Loads the descriptor XML file - * - * @param $nodeInstance An instance of a NodeHelper class - * @return void - */ - public function loadDescriptorXml (NodeHelper $nodeInstance) { - // Debug message - self::createDebugInstance(__CLASS__)->debugOutput('HELPER: Attempting self-connect...'); - - // Get a XML template instance - $templateInstance = XmlTemplateEngineFactory::createXmlTemplateEngineInstance('node_self_connect_template_class'); - - // Set it for later use - $this->setTemplateInstance($templateInstance); - - // Read the XML descriptor - $templateInstance->loadXmlTemplate(); - - // Render the XML content - $templateInstance->renderXmlContent(); - } - - /** - * Do the self-connect attempt by delivering a package to ourselfs - * - * @param $nodeInstance An instance of a NodeHelper class - * @return void - */ - public function sendPackage (NodeHelper $nodeInstance) { - // Sanity check: Is the node in the approx. state? (active) - $nodeInstance->getStateInstance()->validateNodeStateIsActiveOrAnnounced(); - - // Compile the template, this inserts the loaded node data into the gaps. - $this->getTemplateInstance()->compileTemplate(); - - // Get a singleton network package instance - $packageInstance = NetworkPackageFactory::createNetworkPackageInstance(); - - // Next, feed the content in. The network package class is a pipe-through class. - $packageInstance->enqueueRawDataFromTemplate($this, NetworkPackage::PROTOCOL_TCP); - } -} - -// [EOF] +// @DEPRECATED ?> diff --git a/application/hub/main/helper/hub/requests/class_NodeRequestNodeListHelper.php b/application/hub/main/helper/hub/requests/class_NodeRequestNodeListHelper.php index 87939508d..f551ef47b 100644 --- a/application/hub/main/helper/hub/requests/class_NodeRequestNodeListHelper.php +++ b/application/hub/main/helper/hub/requests/class_NodeRequestNodeListHelper.php @@ -1,100 +1,3 @@ - * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Core Developer Team - * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org - * @todo Find an interface for hub helper - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -class NodeRequestNodeListHelper extends BaseHubHelper implements HelpableHub { - /** - * Protected constructor - * - * @return void - */ - protected function __construct () { - // Call parent constructor - parent::__construct(__CLASS__); - - // Set recipient type - $this->setRecipientType(NetworkPackage::NETWORK_TARGET_UPPER_NODES); - - // Set package tags - $this->setPackageTags(array('request_node_list')); - } - - /** - * Creates the helper class - * - * @return $helperInstance A prepared instance of this helper - */ - public final static function createNodeRequestNodeListHelper () { - // Get new instance - $helperInstance = new NodeRequestNodeListHelper(); - - // Return the prepared instance - return $helperInstance; - } - - /** - * Loads the descriptor XML file - * - * @param $nodeInstance An instance of a NodeHelper class - * @return void - */ - public function loadDescriptorXml (NodeHelper $nodeInstance) { - // Debug message - self::createDebugInstance(__CLASS__)->debugOutput('HELPER: Attempting to request: node-list...'); - - // Get a XML template instance - $templateInstance = XmlTemplateEngineFactory::createXmlTemplateEngineInstance('node_request_node_list_template_class'); - - // Set it for later use - $this->setTemplateInstance($templateInstance); - - // Read the XML descriptor - $templateInstance->loadXmlTemplate(); - - // Render the XML content - $templateInstance->renderXmlContent(); - } - - /** - * Do the helped attempt by delivering a package to ourselfs - * - * @param $nodeInstance An instance of a NodeHelper class - * @return void - */ - public function sendPackage (NodeHelper $nodeInstance) { - // Sanity check: Is the node in the approx. state? (active) - $nodeInstance->getStateInstance()->validateNodeStateIsAnnouncementCompleted(); - - // Compile the template, this inserts the loaded node data into the gaps. - $this->getTemplateInstance()->compileTemplate(); - - // Get a singleton network package instance - $packageInstance = NetworkPackageFactory::createNetworkPackageInstance(); - - // Next, feed the content in. The network package class is a pipe-through class. - $packageInstance->enqueueRawDataFromTemplate($this, NetworkPackage::PROTOCOL_TCP); - } -} - -// [EOF] +// @DEPRECATED ?> diff --git a/application/hub/main/helper/node/.htaccess b/application/hub/main/helper/node/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/main/helper/node/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/main/helper/node/announcement/.htaccess b/application/hub/main/helper/node/announcement/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/main/helper/node/announcement/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/main/helper/node/announcement/class_NodeAnnouncementHelper.php b/application/hub/main/helper/node/announcement/class_NodeAnnouncementHelper.php new file mode 100644 index 000000000..20561aaf5 --- /dev/null +++ b/application/hub/main/helper/node/announcement/class_NodeAnnouncementHelper.php @@ -0,0 +1,104 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * @todo Find an interface for hub helper + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class NodeAnnouncementHelper extends BaseNodeHelper implements HelpableNode { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set recipient type + $this->setRecipientType(NetworkPackage::NETWORK_TARGET_UPPER_NODES); + + // Set package tags + $this->setPackageTags(array('announcement')); + } + + /** + * Creates the helper class + * + * @return $helperInstance A prepared instance of this helper + */ + public static final function createNodeAnnouncementHelper () { + // Get new instance + $helperInstance = new NodeAnnouncementHelper(); + + // Return the prepared instance + return $helperInstance; + } + + /** + * Loads the announcement descriptor for parsing + * + * @param $nodeInstance An instance of a NodeHelper class + * @return void + */ + public function loadDescriptorXml (NodeHelper $nodeInstance) { + // Debug message + self::createDebugInstance(__CLASS__)->debugOutput('HELPER: Starting with announcement to upper hubs...'); + + // Get a XML template instance + $templateInstance = XmlTemplateEngineFactory::createXmlTemplateEngineInstance('node_announcement_template_class'); + + // Set it for later use + $this->setTemplateInstance($templateInstance); + + // Read the XML descriptor + $templateInstance->loadXmlTemplate(); + + // Render the XML content + $templateInstance->renderXmlContent(); + } + + /** + * Publishes the node's descriptor XML to all found upper nodes when the + * node has not yet published it's descriptor to a bootstrap node. This is + * done by getting the raw XML content and inserting all variables into + * the code. After this wents fine, the rendered content got "packaged" + * for network delivery. + * + * @param $nodeInstance An instance of a NodeHelper class + * @return void + */ + public function sendPackage (NodeHelper $nodeInstance) { + // Sanity check: Is the node in the approx. state? (active) + $nodeInstance->getStateInstance()->validateNodeStateIsActiveOrReachable(); + + // Compile the template, this inserts the loaded node data into the gaps. + $this->getTemplateInstance()->compileTemplate(); + + // Get a singleton network package instance + $packageInstance = NetworkPackageFactory::createNetworkPackageInstance(); + + // Next, feed the content in. The network package class is a pipe-through class. + $packageInstance->enqueueRawDataFromTemplate($this, NetworkPackage::PROTOCOL_TCP); + } +} + +// [EOF] +?> diff --git a/application/hub/main/helper/node/answer/.htaccess b/application/hub/main/helper/node/answer/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/main/helper/node/answer/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/main/helper/node/answer/announcement/.htaccess b/application/hub/main/helper/node/answer/announcement/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/main/helper/node/answer/announcement/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/main/helper/node/answer/announcement/class_NodeAnnouncementMessageAnswerHelper.php b/application/hub/main/helper/node/answer/announcement/class_NodeAnnouncementMessageAnswerHelper.php new file mode 100644 index 000000000..dc511678c --- /dev/null +++ b/application/hub/main/helper/node/answer/announcement/class_NodeAnnouncementMessageAnswerHelper.php @@ -0,0 +1,104 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * @todo Find an interface for hub helper + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class NodeAnnouncementMessageAnswerHelper extends BaseHubAnswerHelper implements HelpableNode { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Init package tags + $this->setPackageTags(array('announcement_answer')); + } + + /** + * Creates the helper class + * + * @param $messageData An array with all message data + * @return $helperInstance A prepared instance of this helper + */ + public final static function createNodeAnnouncementMessageAnswerHelper (array $messageData) { + // Get new instance + $helperInstance = new NodeAnnouncementMessageAnswerHelper(); + + // Set session id of other peer as recipient + $helperInstance->setRecipientType($messageData[XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID]); + + // Set message data + $helperInstance->setMessageData($messageData); + + // Return the prepared instance + return $helperInstance; + } + + /** + * Loads the descriptor XML file + * + * @param $nodeInstance An instance of a NodeHelper class + * @return void + */ + public function loadDescriptorXml (NodeHelper $nodeInstance) { + // Debug message + self::createDebugInstance(__CLASS__)->debugOutput('HELPER: Attempting to answer an announcement...'); + + // Get a XML template instance + $templateInstance = XmlTemplateEngineFactory::createXmlTemplateEngineInstance('node_announcement_answer_template_class'); + + // Set it for later use + $this->setTemplateInstance($templateInstance); + + // Read the XML descriptor + $templateInstance->loadXmlTemplate(); + + // Render the XML content + $templateInstance->renderXmlContent(); + } + + /** + * Send out announcement answer package + * + * @param $nodeInstance An instance of a NodeHelper class + * @return void + */ + public function sendPackage (NodeHelper $nodeInstance) { + // Sanity check: Is the node in the approx. state? (active/reachable) + $nodeInstance->getStateInstance()->validateNodeStateIsActiveOrReachable(); + + // Compile the template, this inserts the loaded node data into the gaps. + $this->getTemplateInstance()->compileTemplate(); + + // Get a singleton network package instance + $packageInstance = NetworkPackageFactory::createNetworkPackageInstance(); + + // Next, feed the content in. The network package class is a pipe-through class. + $packageInstance->enqueueRawDataFromTemplate($this, NetworkPackage::PROTOCOL_TCP); + } +} + +// [EOF] +?> diff --git a/application/hub/main/helper/node/answer/class_BaseHubAnswerHelper.php b/application/hub/main/helper/node/answer/class_BaseHubAnswerHelper.php new file mode 100644 index 000000000..63f929656 --- /dev/null +++ b/application/hub/main/helper/node/answer/class_BaseHubAnswerHelper.php @@ -0,0 +1,61 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseHubAnswerHelper extends BaseNodeHelper { + /** + * Message data array + */ + private $messageData = array(); + + /** + * Protected constructor + * + * @param $className Name of the concrete class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } + + /** + * Setter for message data + * + * @return $messageData An array with message data + */ + protected final function setMessageData (array $messageData) { + $this->messageData = $messageData; + } + + /** + * Getter for message data + * + * @return $messageData An array with message data + */ + public final function getMessageData () { + return $this->messageData; + } +} + +// [EOF] +?> diff --git a/application/hub/main/helper/node/answer/requests/.htaccess b/application/hub/main/helper/node/answer/requests/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/main/helper/node/answer/requests/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/main/helper/node/answer/requests/class_NodeRequestNodeListMessageAnswerHelper.php b/application/hub/main/helper/node/answer/requests/class_NodeRequestNodeListMessageAnswerHelper.php new file mode 100644 index 000000000..0964e9a9a --- /dev/null +++ b/application/hub/main/helper/node/answer/requests/class_NodeRequestNodeListMessageAnswerHelper.php @@ -0,0 +1,110 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * @todo Find an interface for hub helper + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class NodeRequestNodeListMessageAnswerHelper extends BaseHubAnswerHelper implements HelpableNode { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Init package tags + $this->setPackageTags(array('request_node_list_answer')); + } + + /** + * Creates the helper class + * + * @param $messageData An array with all message data + * @return $helperInstance A prepared instance of this helper + */ + public final static function createNodeRequestNodeListMessageAnswerHelper (array $messageData) { + // Get new instance + $helperInstance = new NodeRequestNodeListMessageAnswerHelper(); + + // Set session id of other peer as recipient + $helperInstance->setRecipientType($messageData[XmlRequestNodeListTemplateEngine::REQUEST_DATA_SESSION_ID]); + + // Set message data + $helperInstance->setMessageData($messageData); + + // Return the prepared instance + return $helperInstance; + } + + /** + * Loads the descriptor XML file + * + * @param $nodeInstance An instance of a NodeHelper class + * @return void + */ + public function loadDescriptorXml (NodeHelper $nodeInstance) { + // Debug message + self::createDebugInstance(__CLASS__)->debugOutput('HELPER: Attempting to answer a request: node-list...'); + + // Get a XML template instance + $templateInstance = XmlTemplateEngineFactory::createXmlTemplateEngineInstance('node_request_node_list_answer_template_class'); + + // Set it for later use + $this->setTemplateInstance($templateInstance); + + // Read the XML descriptor + $templateInstance->loadXmlTemplate(); + + // "Cache" entries instance for next foreach loop + $entriesInstance = $templateInstance->getTemplateInstance(); + + // Is must not be NULL (then it can only be a template instance) + assert(!is_null($entriesInstance)); + + // Render the XML content + $templateInstance->renderXmlContent(); + } + + /** + * Send out request-node-list answer package + * + * @param $nodeInstance An instance of a NodeHelper class + * @return void + */ + public function sendPackage (NodeHelper $nodeInstance) { + // Sanity check: Is the node in the approx. state? (active/reachable) + $nodeInstance->getStateInstance()->validateNodeStateIsActiveOrReachable(); + + // Compile the template, this inserts the loaded node data into the gaps. + $this->getTemplateInstance()->compileTemplate(); + + // Get a singleton network package instance + $packageInstance = NetworkPackageFactory::createNetworkPackageInstance(); + + // Next, feed the content in. The network package class is a pipe-through class. + $packageInstance->enqueueRawDataFromTemplate($this, NetworkPackage::PROTOCOL_TCP); + } +} + +// [EOF] +?> diff --git a/application/hub/main/helper/node/class_ b/application/hub/main/helper/node/class_ new file mode 100644 index 000000000..5e5e493eb --- /dev/null +++ b/application/hub/main/helper/node/class_ @@ -0,0 +1,83 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * @todo Find an interface for hub helper + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class Node???Helper extends BaseNodeHelper implements HelpableNode { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set recipient type + $this->setRecipientType(NetworkPackage::NETWORK_TARGET_!!!); + } + + /** + * Creates the helper class + * + * @return $helperInstance A prepared instance of this helper + */ + public final static function createNode???Helper () { + // Get new instance + $helperInstance = new Node???Helper(); + + // Return the prepared instance + return $helperInstance; + } + + /** + * Loads the descriptor XML file + * + * @return void + */ + public function loadDescriptorXml () { + $this->partialStub('Please implement this method.'); + } + + /** + * Do the helped attempt by delivering a package to ourselfs + * + * @param $nodeInstance An instance of a NodeHelper class + * @return void + */ + public function sendPackage (NodeHelper $nodeInstance) { + // Sanity check: Is the node in the approx. state? (active) + $nodeInstance->getStateInstance()->validateNodeStateIsActive(); + + // Compile the template, this inserts the loaded node data into the gaps. + $this->getTemplateInstance()->compileTemplate(); + + // Get a singleton network package instance + $packageInstance = NetworkPackageFactory::createNetworkPackageInstance(); + + // Next, feed the content in. The network package class is a pipe-through class. + $packageInstance->enqueueRawDataFromTemplate($this, NetworkPackage::PROTOCOL_|||); + } +} + +// [EOF] +?> diff --git a/application/hub/main/helper/node/class_BaseNodeHelper.php b/application/hub/main/helper/node/class_BaseNodeHelper.php new file mode 100644 index 000000000..416f198ae --- /dev/null +++ b/application/hub/main/helper/node/class_BaseNodeHelper.php @@ -0,0 +1,38 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseNodeHelper extends BaseHubSystemHelper { + /** + * Protected constructor + * + * @param $className Name of the concrete class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } +} + +// [EOF] +?> diff --git a/application/hub/main/helper/node/connection/.htaccess b/application/hub/main/helper/node/connection/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/main/helper/node/connection/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/main/helper/node/connection/class_NodeSelfConnectHelper.php b/application/hub/main/helper/node/connection/class_NodeSelfConnectHelper.php new file mode 100644 index 000000000..f1746dce1 --- /dev/null +++ b/application/hub/main/helper/node/connection/class_NodeSelfConnectHelper.php @@ -0,0 +1,100 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * @todo Find an interface for hub helper + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class NodeSelfConnectHelper extends BaseNodeHelper implements HelpableNode { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set recipient type + $this->setRecipientType(NetworkPackage::NETWORK_TARGET_SELF); + + // Set package tags + $this->setPackageTags(array('self_connect')); + } + + /** + * Creates the helper class + * + * @return $helperInstance A prepared instance of this helper + */ + public static final function createNodeSelfConnectHelper () { + // Get new instance + $helperInstance = new NodeSelfConnectHelper(); + + // Return the prepared instance + return $helperInstance; + } + + /** + * Loads the descriptor XML file + * + * @param $nodeInstance An instance of a NodeHelper class + * @return void + */ + public function loadDescriptorXml (NodeHelper $nodeInstance) { + // Debug message + self::createDebugInstance(__CLASS__)->debugOutput('HELPER: Attempting self-connect...'); + + // Get a XML template instance + $templateInstance = XmlTemplateEngineFactory::createXmlTemplateEngineInstance('node_self_connect_template_class'); + + // Set it for later use + $this->setTemplateInstance($templateInstance); + + // Read the XML descriptor + $templateInstance->loadXmlTemplate(); + + // Render the XML content + $templateInstance->renderXmlContent(); + } + + /** + * Do the self-connect attempt by delivering a package to ourselfs + * + * @param $nodeInstance An instance of a NodeHelper class + * @return void + */ + public function sendPackage (NodeHelper $nodeInstance) { + // Sanity check: Is the node in the approx. state? (active) + $nodeInstance->getStateInstance()->validateNodeStateIsActiveOrAnnounced(); + + // Compile the template, this inserts the loaded node data into the gaps. + $this->getTemplateInstance()->compileTemplate(); + + // Get a singleton network package instance + $packageInstance = NetworkPackageFactory::createNetworkPackageInstance(); + + // Next, feed the content in. The network package class is a pipe-through class. + $packageInstance->enqueueRawDataFromTemplate($this, NetworkPackage::PROTOCOL_TCP); + } +} + +// [EOF] +?> diff --git a/application/hub/main/helper/node/requests/.htaccess b/application/hub/main/helper/node/requests/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/main/helper/node/requests/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/main/helper/node/requests/class_NodeRequestNodeListHelper.php b/application/hub/main/helper/node/requests/class_NodeRequestNodeListHelper.php new file mode 100644 index 000000000..c95589972 --- /dev/null +++ b/application/hub/main/helper/node/requests/class_NodeRequestNodeListHelper.php @@ -0,0 +1,100 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * @todo Find an interface for hub helper + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class NodeRequestNodeListHelper extends BaseNodeHelper implements HelpableNode { + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Set recipient type + $this->setRecipientType(NetworkPackage::NETWORK_TARGET_UPPER_NODES); + + // Set package tags + $this->setPackageTags(array('request_node_list')); + } + + /** + * Creates the helper class + * + * @return $helperInstance A prepared instance of this helper + */ + public final static function createNodeRequestNodeListHelper () { + // Get new instance + $helperInstance = new NodeRequestNodeListHelper(); + + // Return the prepared instance + return $helperInstance; + } + + /** + * Loads the descriptor XML file + * + * @param $nodeInstance An instance of a NodeHelper class + * @return void + */ + public function loadDescriptorXml (NodeHelper $nodeInstance) { + // Debug message + self::createDebugInstance(__CLASS__)->debugOutput('HELPER: Attempting to request: node-list...'); + + // Get a XML template instance + $templateInstance = XmlTemplateEngineFactory::createXmlTemplateEngineInstance('node_request_node_list_template_class'); + + // Set it for later use + $this->setTemplateInstance($templateInstance); + + // Read the XML descriptor + $templateInstance->loadXmlTemplate(); + + // Render the XML content + $templateInstance->renderXmlContent(); + } + + /** + * Do the helped attempt by delivering a package to ourselfs + * + * @param $nodeInstance An instance of a NodeHelper class + * @return void + */ + public function sendPackage (NodeHelper $nodeInstance) { + // Sanity check: Is the node in the approx. state? (active) + $nodeInstance->getStateInstance()->validateNodeStateIsAnnouncementCompleted(); + + // Compile the template, this inserts the loaded node data into the gaps. + $this->getTemplateInstance()->compileTemplate(); + + // Get a singleton network package instance + $packageInstance = NetworkPackageFactory::createNetworkPackageInstance(); + + // Next, feed the content in. The network package class is a pipe-through class. + $packageInstance->enqueueRawDataFromTemplate($this, NetworkPackage::PROTOCOL_TCP); + } +} + +// [EOF] +?> diff --git a/application/hub/main/package/class_NetworkPackage.php b/application/hub/main/package/class_NetworkPackage.php index 6e21861c9..09ca858bf 100644 --- a/application/hub/main/package/class_NetworkPackage.php +++ b/application/hub/main/package/class_NetworkPackage.php @@ -587,11 +587,11 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R * from given helper's template instance and pushing it on the 'undeclared' * stack. * - * @param $helperInstance An instance of a HelpableHub class + * @param $helperInstance An instance of a HelpableNode class * @param $protocol Name of used protocol (TCP/UDP) * @return void */ - public function enqueueRawDataFromTemplate (HelpableHub $helperInstance, $protocolName) { + public function enqueueRawDataFromTemplate (HelpableNode $helperInstance, $protocolName) { // Get the raw content ... $content = $helperInstance->getTemplateInstance()->getRawTemplateData(); //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('content(' . strlen($content) . ')=' . $content); diff --git a/application/hub/main/template/bootstrap/.htaccess b/application/hub/main/template/bootstrap/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/main/template/bootstrap/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/main/template/bootstrap/class_XmlBootstrapTemplateEngine.php b/application/hub/main/template/bootstrap/class_XmlBootstrapTemplateEngine.php new file mode 100644 index 000000000..50bf15e65 --- /dev/null +++ b/application/hub/main/template/bootstrap/class_XmlBootstrapTemplateEngine.php @@ -0,0 +1,336 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Core Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.ship-simu.org + * @todo This template engine does not make use of setTemplateType() + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class XmlBootstrapTemplateEngine extends BaseXmlTemplateEngine implements CompileableTemplate, Registerable { + /** + * Some XML nodes must be available for later data extraction + */ + const BOOTSTRAP_DATA_SESSION_ID = 'session-id'; + const BOOTSTRAP_DATA_NODE_STATUS = 'node-status'; + const BOOTSTRAP_DATA_NODE_MODE = 'node-mode'; + const BOOTSTRAP_DATA_EXTERNAL_IP = 'external-ip'; + const BOOTSTRAP_DATA_INTERNAL_IP = 'internal-ip'; + const BOOTSTRAP_DATA_LISTEN_PORT = 'listen-port'; + + /** + * Protected constructor + * + * @return void + */ + protected function __construct () { + // Call parent constructor + parent::__construct(__CLASS__); + + // Init array + $this->subNodes = array( + 'bootstrap-data', + 'listener', + self::BOOTSTRAP_DATA_NODE_STATUS, + self::BOOTSTRAP_DATA_NODE_MODE, + self::BOOTSTRAP_DATA_LISTEN_PORT, + self::BOOTSTRAP_DATA_SESSION_ID, + self::BOOTSTRAP_DATA_EXTERNAL_IP, + self::BOOTSTRAP_DATA_INTERNAL_IP, + 'object-type-list', + ); + } + + /** + * Creates an instance of the class TemplateEngine and prepares it for usage + * + * @return $templateInstance An instance of TemplateEngine + * @throws BasePathIsEmptyException If the provided $templateBasePath is empty + * @throws InvalidBasePathStringException If $templateBasePath is no string + * @throws BasePathIsNoDirectoryException If $templateBasePath is no + * directory or not found + * @throws BasePathReadProtectedException If $templateBasePath is + * read-protected + */ + public static final function createXmlBootstrapTemplateEngine () { + // Get a new instance + $templateInstance = new XmlBootstrapTemplateEngine(); + + // Init template instance + $templateInstance->initXmlTemplateEngine('node', 'bootstrap'); + + // Return the prepared instance + return $templateInstance; + } + + /** + * Currently not used + * + * @param $resource XML parser resource (currently ignored) + * @param $characters Characters to handle + * @return void + */ + public function characterHandler ($resource, $characters) { + // Trim all spaces away + $characters = trim($characters); + + // Is this string empty? + if (empty($characters)) { + // Then skip it silently + return false; + } // END - if + + /* + * Assign the found characters to variable and use the last entry from + * stack as the name. + */ + parent::assignVariable($this->getStackerInstance()->getNamed('node_bootstrap'), $characters); + } + + /** + * Getter for cache file (FQFN) + * + * @return $fqfn Full-qualified file name of the menu cache + */ + public function getMenuCacheFqfn () { + $this->partialStub('Please implement this method.'); + } + + /** + * Starts the bootstrap + * + * @return void + */ + protected function startBootstrap () { + // Push the node name on the stacker + $this->getStackerInstance()->pushNamed('node_bootstrap', 'node_bootstrap'); + } + + /** + * Starts the bootstrap data + * + * @return void + */ + protected function startBootstrapData () { + // Push the node name on the stacker + $this->getStackerInstance()->pushNamed('node_bootstrap', 'bootstrap-data'); + } + + /** + * Starts the node status + * + * @return void + */ + protected function startNodeStatus () { + // Push the node name on the stacker + $this->getStackerInstance()->pushNamed('node_bootstrap', self::BOOTSTRAP_DATA_NODE_STATUS); + } + + /** + * Starts the node-mode + * + * @return void + */ + protected function startNodeMode () { + // Push the node name on the stacker + $this->getStackerInstance()->pushNamed('node_bootstrap', self::BOOTSTRAP_DATA_NODE_MODE); + } + + /** + * Starts the listener + * + * @return void + */ + protected function startListener () { + // Push the node name on the stacker + $this->getStackerInstance()->pushNamed('node_bootstrap', 'listener'); + } + + /** + * Starts the TCP/UDP listen port + * + * @return void + */ + protected function startListenPort () { + // Push the node name on the stacker + $this->getStackerInstance()->pushNamed('node_bootstrap', self::BOOTSTRAP_DATA_LISTEN_PORT); + } + + /** + * Starts the session id + * + * @return void + */ + protected function startSessionId () { + // Push the node name on the stacker + $this->getStackerInstance()->pushNamed('node_bootstrap', self::BOOTSTRAP_DATA_SESSION_ID); + } + + /** + * Starts the public ip + * + * @return void + */ + protected function startExternalIp () { + // Push the node name on the stacker + $this->getStackerInstance()->pushNamed('node_bootstrap', self::BOOTSTRAP_DATA_EXTERNAL_IP); + } + + /** + * Starts the private ip + * + * @return void + */ + protected function startInternalIp () { + // Push the node name on the stacker + $this->getStackerInstance()->pushNamed('node_bootstrap', self::BOOTSTRAP_DATA_INTERNAL_IP); + } + + /** + * Starts the object type list + * + * @return void + */ + protected function startObjectTypeList () { + // Push the node name on the stacker + $this->getStackerInstance()->pushNamed('node_bootstrap', 'object-type-list'); + } + + /** + * Starts the object type + * + * @return void + */ + protected function startObjectType () { + // Push the node name on the stacker + $this->getStackerInstance()->pushNamed('node_bootstrap', 'object-type'); + } + + /** + * Finishes the object type + * + * @return void + */ + protected function finishObjectType () { + // Pop the last entry + $this->getStackerInstance()->popNamed('node_bootstrap'); + } + + /** + * Finishes the object type list + * + * @return void + */ + protected function finishObjectTypeList () { + // Pop the last entry + $this->getStackerInstance()->popNamed('node_bootstrap'); + } + + /** + * Finishes the session id + * + * @return void + */ + protected function finishSessionId () { + // Pop the last entry + $this->getStackerInstance()->popNamed('node_bootstrap'); + } + + /** + * Finishes the private ip + * + * @return void + */ + protected function finishInternalIp () { + // Pop the last entry + $this->getStackerInstance()->popNamed('node_bootstrap'); + } + + /** + * Finishes the public ip + * + * @return void + */ + protected function finishExternalIp () { + // Pop the last entry + $this->getStackerInstance()->popNamed('node_bootstrap'); + } + + /** + * Finishes the TCP/UDP listen port + * + * @return void + */ + protected function finishListenPort () { + // Pop the last entry + $this->getStackerInstance()->popNamed('node_bootstrap'); + } + + /** + * Finishes the listener + * + * @return void + */ + protected function finishListener () { + // Pop the last entry + $this->getStackerInstance()->popNamed('node_bootstrap'); + } + + /** + * Finishes the node mode + * + * @return void + */ + protected function finishNodeMode () { + // Pop the last entry + $this->getStackerInstance()->popNamed('node_bootstrap'); + } + + /** + * Finishes the node status + * + * @return void + */ + protected function finishNodeStatus () { + // Pop the last entry + $this->getStackerInstance()->popNamed('node_bootstrap'); + } + + /** + * Finishes the bootstrap data + * + * @return void + */ + protected function finishBootstrapData () { + // Pop the last entry + $this->getStackerInstance()->popNamed('node_bootstrap'); + } + + /** + * Finishes the bootstrap + * + * @return void + */ + protected function finishBootstrap () { + // Pop the last entry + $this->getStackerInstance()->popNamed('node_bootstrap'); + } +} + +// [EOF] +?>