application/hub/debug.php -text
application/hub/exceptions.php -text
application/hub/exceptions/.htaccess -text
+application/hub/exceptions/hub/.htaccess -text
+application/hub/exceptions/hub/class_HubAlreadyAnnouncedException.php -text
application/hub/exceptions/lists/.htaccess -text
application/hub/exceptions/lists/class_InvalidListHashException.php -text
application/hub/exceptions/lists/class_ListGroupAlreadyAddedException.php -text
application/hub/templates/xml/.xml -text
application/hub/templates/xml/announcement/.htaccess -text
application/hub/templates/xml/announcement/self_announcement.xml -text
+application/hub/templates/xml/node/.htaccess -text
+application/hub/templates/xml/node/node_status.xml -text
/clear-cache.sh -text
db/.htaccess -text
db/news/.htaccess -text
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * This exception is thrown when a hash is invalid
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 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/>.
+ */
+class HubAlreadyAnnouncedException extends FrameworkException {
+ /**
+ * The super constructor for all exceptions
+ *
+ * @param $messageArray Error message array
+ * @param $code Error code
+ * @return void
+ */
+ public function __construct (NodeHelper $nodeInstance, $code) {
+ // Construct the message
+ $message = sprintf("[%s] This hub is already announced. Please fix this.",
+ $messageArray[0]->__toString()
+ );
+
+ // Call parent exception constructor
+ parent::__construct($message, $code);
+ }
+}
+
+// [EOF]
+?>
* @return void
*/
function addExtraHubFilters ();
+
+ /**
+ * Announces this hub to the upper (bootstrap or list) hubs. After this is
+ * successfully done the given task is unregistered from the handler.
+ *
+ * @param $taskInstance The task instance running this announcement
+ * @return void
+ * @throws HubAlreadyAnnouncedException If this hub is already announced
+ */
+ function announceSelfToUpperNodes (Taskable $taskInstance);
}
//
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
class BaseHubNode extends BaseHubSystem implements Updateable {
+ // Exception constants
+ const EXCEPTION_HUB_ALREADY_ANNOUNCED = 0xe00;
+
/**
* Node id
*/
*/
private $hubIsActive = false;
+ /**
+ * Wether this node is anncounced (KEEP ON false!)
+ */
+ private $hubIsAnnounced = false;
+
/**
* Protected constructor
*
$this->hubIsActive = $hubIsActive;
}
+ /**
+ * Announces this hub to the upper (bootstrap or list) hubs. After this is
+ * successfully done the given task is unregistered from the handler.
+ *
+ * @param $taskInstance The task instance running this announcement
+ * @return void
+ * @throws HubAlreadyAnnouncedException If this hub is already announced
+ */
+ public function announceSelfToUpperNodes (Taskable $taskInstance) {
+ // Is this hub node announced?
+ if ($this->hubIsAnnounced === true) {
+ // Already announced!
+ throw new HubAlreadyAnnouncedException($this, self::EXCEPTION_HUB_ALREADY_ANNOUNCED);
+ } // END - if
+
+ // Get a helper instance
+ $helperInstance = ObjectFactory::createObjectByConfiguredName('hub_descriptor_class', array($this));
+
+ die("\n");
+ }
+
/**
* Activates the hub by doing some final preparation and setting
* $hubIsActive to true
* @return void
*/
public function execute () {
- $this->partialStub('Unimplemented task.');
+ // Get the node instance and announce us
+ Registry::getRegistry()->getInstance('node')->announceSelfToUpperNodes($this);
}
}
<annoucement-data>
<!-- Our node id. This should be announced only to upper hubs. //-->
<node-id>{?node_id?}</node-id>
+ <!-- Status of this node, see node_status.xml for details. //-->
+ <node-status>{?node_status?}</node-status>
<!-- The session id. This should be announced to all other hubs. //-->
<session-id>{?session_id?}</session-id>
<!-- A list of shared object types. //-->
--- /dev/null
+Deny from all
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+All valid node status.
+
+@author Roland Haeder <webmaster@ship-simu.org>
+@version 0.0.0
+@copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 Ship-Simu 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/>
+//-->
+<node-status-list>
+ <!-- This hub cannot be reached from outside by TCP only. //-->
+ <node-status status="unreachable_tcp" />
+ <!-- This hub cannot be reached from outside by UDP only. //-->
+ <node-status status="unreachable_udp" />
+ <!-- This hub cannot be reached from outside by TCP and UDP. //-->
+ <node-status status="unreachable_tcp_udp" />
+ <!-- This hub did not share anything (virgin). //-->
+ <node-status status="virgin" />
+ <!-- This hub is very busy (slow self pings). //-->
+ <node-status status="slow" />
+ <!-- This hub is full (max connections reached). //-->
+ <node-status status="full" />
+ <!-- This hub is reachable, fast enougth and has already shared some objects. //-->
+ <node-status status="ok" />
+</node-status-list>