application/hub/interfaces/handler/network/class_Networkable.php -text
application/hub/interfaces/handler/task/.htaccess -text
application/hub/interfaces/handler/task/class_HandleableTask.php -text
+application/hub/interfaces/helper/.htaccess -text
+application/hub/interfaces/helper/hub/.htaccess -text
application/hub/interfaces/listener/.htaccess -text
application/hub/interfaces/listener/class_Listenable.php -text
application/hub/interfaces/lists/.htaccess -text
application/hub/main/factories/discovery/.htaccess -text
application/hub/main/factories/lists/.htaccess -text
application/hub/main/factories/package/.htaccess -text
+application/hub/main/factories/socket/.htaccess -text
application/hub/main/factories/states/.htaccess -text
application/hub/main/factories/states/class_StateFactory.php -text
application/hub/main/factories/states/peer/.htaccess -text
--- /dev/null
+Deny from all
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * An interface for hub helper classes
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009, 2010 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 <http://www.gnu.org/licenses/>.
+ */
+interface HelpableHub extends FrameworkInterface {
+ /**
+ * Loads the descriptor XML file
+ *
+ * @return void
+ */
+ public function loadDescriptorXml ();
+
+ /**
+ * Do the helped attempt by delivering a package to ourselfs
+ *
+ * @return void
+ */
+ public function sendPackage ();
+}
+
+// [EOF]
+?>
// Is it false, the recipient isn't known to us and we have no connection to it
if (!is_resource($socketResource)) {
// Create a new socket resource
- $socketResource = HubConnectionHelper::getSocketFromPackageData($packageData, $protocolName);
+ $socketResource = SocketFactory::createSocketFromPackageData($packageData, $protocolName);
} // END - if
// And return it
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A socket factory class
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009, 2010 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 <http://www.gnu.org/licenses/>.
+ */
+class SocketFactory extends BaseHubHelper {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates a valid socket resource from given packae data and protocol
+ *
+ * @param $packageData Raw package data
+ * @param $protocolName Protocol name (TCP/UDP)
+ * @return $socketResource Socket resource
+ */
+ public static function createSocketFromPackageData (array $packageData, $protocolName) {
+ // Construct configuration entry for object factory
+ $configEntry = $protocolName . '_connection_class';
+
+ // And call the static method
+ $socketResource = call_user_func(FrameworkConfiguration::getInstance()->getConfigEntry($configEntry) . '::createConnectionFromPackageData', $packageData);
+
+ // Return the resource
+ return $socketResource;
+ }
+}
+
+// [EOF]
+?>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-class HubDescriptorHelper extends BaseHubHelper {
+class HubDescriptorHelper extends BaseHubHelper implements HelpableHub {
/**
* An array with all tags for network packages
*/
* @return void
* @todo Rewrite the ->renderXmlContent() call to no arguments
*/
- public function loadAnnouncementDescriptor () {
+ public function loadDescriptorXml () {
// Debug message
$this->debugOutput('HELPER: Starting with announcement to upper hubs...');
*
* @return void
*/
- public function publishAnnouncementDescriptor () {
+ public function sendPackage () {
// Sanity check: Is the node in the approx. state? (active)
$this->getNodeInstance()->getStateInstance()->validateNodeStateIsActive();
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-class Hub???Helper extends BaseHubHelper {
+class Hub???Helper extends BaseHubHelper implements HelpableHub {
/**
* Protected constructor
*
// 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
+ *
+ * @return void
+ */
+ public function sendPackage () {
+ // Sanity check: Is the node in the approx. state? (active)
+ $this->getNodeInstance()->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);
+ }
}
// [EOF]
+++ /dev/null
-<?php
-/**
- * A Connection hub helper class
- *
- * @author Roland Haeder <webmaster@ship-simu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009, 2010 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 <http://www.gnu.org/licenses/>.
- */
-class HubConnectionHelper extends BaseHubHelper {
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
- }
-
- /**
- * "Getter" for a valid socket resource from given packae data.
- *
- * @param $packageData Raw package data
- * @param $protocolName Protocol name (TCP/UDP)
- * @return $socketResource Socket resource
- */
- public static function getSocketFromPackageData (array $packageData, $protocolName) {
- // Construct configuration entry for object factory
- $configEntry = $protocolName . '_connection_class';
-
- // And call the static method
- $socketResource = call_user_func(FrameworkConfiguration::getInstance()->getConfigEntry($configEntry) . '::createConnectionFromPackageData', $packageData);
-
- // Return the resource
- return $socketResource;
- }
-}
-
-// [EOF]
-?>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-class HubSelfConnectHelper extends BaseHubHelper {
+class HubSelfConnectHelper extends BaseHubHelper implements HelpableHub {
/**
* Protected constructor
*
return $helperInstance;
}
+ /**
+ * Loads the descriptor XML file
+ *
+ * @return void
+ */
+ public function loadDescriptorXml () {
+ $this->partialStub('Please implement this method.');
+ }
+
/**
* Do the self-connect attempt by delivering a package to ourselfs
*
* @return void
*/
- public function doSelfConnect () {
- $this->partialStub('Not yet finished.');
+ public function sendPackage () {
+ // Sanity check: Is the node in the approx. state? (active)
+ $this->getNodeInstance()->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);
}
}
$helperInstance = ObjectFactory::createObjectByConfiguredName('hub_announcement_helper_class', array($this));
// Load the announcement descriptor
- $helperInstance->loadAnnouncementDescriptor();
+ $helperInstance->loadDescriptorXml();
// Set some dummy configuration entries, e.g. node_status
$this->getConfigInstance()->setConfigEntry('node_status', $this->getStateInstance()->getStateName());
$helperInstance->getTemplateInstance()->compileConfigInVariables();
// "Publish" the descriptor by sending it to the bootstrap/list nodes
- $helperInstance->publishAnnouncementDescriptor();
+ $helperInstance->sendPackage();
// Change the state, this should be the last line except debug output
$this->getStateInstance()->nodeAnnouncedToUpperHubs();
// Get a helper instance
$helperInstance = ObjectFactory::createObjectByConfiguredName('hub_self_connect_helper_class', array($this));
+ // Load the descriptor (XML) file
+ $helperInstance->loadDescriptorXml();
+
// And send the package away
- $helperInstance->doSelfConnect();
+ $helperInstance->sendPackage();
// Debug output
$this->debugOutput('HUB: Self Connection: FINISHED');