application/hub/main/factories/package/class_NetworkPackageFactory.php svneol=native#text/plain
application/hub/main/factories/package/fragmenter/.htaccess -text
application/hub/main/factories/producer/.htaccess -text
+application/hub/main/factories/registry/.htaccess -text svneol=unset#text/plain
+application/hub/main/factories/registry/class_ObjectTypeRegistryFactory.php svneol=native#text/plain
application/hub/main/factories/socket/.htaccess -text svneol=unset#text/plain
application/hub/main/factories/socket/class_SocketFactory.php svneol=native#text/plain
application/hub/main/factories/source/.htaccess svneol=native#text/plain
* @return void
*/
function handleAnswerStatusByMessageData (array $messageData, Receivable $packageInstance);
+
+ /**
+ * "Getter" for an array of all accepted object types
+ *
+ * @return $objectList Array of all accepted object types
+ */
+ function getListFromAcceptedObjectTypes ();
}
// [EOF]
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A factory class for network packages
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @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 <http://www.gnu.org/licenses/>.
+ */
+class ObjectTypeRegistryFactory extends ObjectFactory {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Returns a singleton object type regsitry.
+ *
+ * @return $registryInstance A registry for object types
+ */
+ public static final function createObjectTypeRegistryInstance () {
+ // Do we have an instance in the registry?
+ if (Registry::getRegistry()->instanceExists('object_type_registry')) {
+ // Then use this instance
+ $registryInstance = Registry::getRegistry()->getInstance('object_type_registry');
+ } else {
+ // Now prepare the tags instance
+ $registryInstance = self::createObjectByConfiguredName('node_object_type_registry_class');
+
+ // Set the instance in registry for further use
+ Registry::getRegistry()->addInstance('object_type_registry', $registryInstance);
+ }
+
+ // Return the instance
+ return $registryInstance;
+ }
+}
+
+// [EOF]
+?>
*
* The following array is being handled over:
*
- * my-external-ip => 1.2.3.4
- * my-internal-ip => 5.6.7.8
- * my-status => reachable
- * my-session-id => aaabbbcccdddeeefff123456789
- * my-tcp-port => 9060
- * my-udp-port => 9060
- * answer-status => OKAY
- * message_type => announcement_answer
+ * my-external-ip => 1.2.3.4
+ * my-internal-ip => 5.6.7.8
+ * my-status => reachable
+ * my-session-id => aaabbbcccdddeeefff123456789
+ * my-tcp-port => 9060
+ * my-udp-port => 9060
+ * answer-status => OKAY
+ * message_type => announcement_answer
*
* @param $messageData An array with all message data
* @return void
*/
protected function initMessageConfigurationData (array $messageData) {
- $this->partialStub('messageData=' . print_r($messageData, true));
+ // Get node instance
+ $nodeInstance = Registry::getRegistry()->getInstance('node');
+
+ // Get an array of all accepted object types
+ $objectList = $nodeInstance->getListFromAcceptedObjectTypes();
+
+ // Add missing (temporary) configuration 'accepted_object_types'
+ //$this->getConfigInstance()->setConfigEntry(implode(BaseHubNode::OBJECT_LIST_SEPARATOR, $objectList));
}
/**
* @return void
*/
protected function removeMessageConfigurationData (array $messageData) {
- $this->partialStub('messageData=' . print_r($messageData, true));
+ // Remove temporay configuration
+ $this->getConfigInstance()->unsetConfigEntry('accepted_object_types');
}
}
// Exception constants
const EXCEPTION_HUB_ALREADY_ANNOUNCED = 0xe00;
+ // Other constants
+ const OBJECT_LIST_SEPARATOR = ',';
+
/**
* IP/port number of bootstrapping node
*/
// Handle it there
$handlerInstance->handleAnswerMessageData($messageData, $packageInstance);
}
+
+ /**
+ * "Getter" for an array of all accepted object types
+ *
+ * @return $objectList Array of all accepted object types
+ */
+ public function getListFromAcceptedObjectTypes () {
+ // Get registry instance
+ $objectRegistryInstance = ObjectTypeRegistryFactory::createObjectTypeRegistryInstance();
+
+ // Get all entries
+ $objectList = $objectRegistryInstance->getEntries(XmlObjectRegistryTemplateEngine::OBJECT_TYPE_DATA_NAME);
+
+ // ... and return it
+ return $objectList;
+ }
}
// [EOF]
// Return the instance
return self::$registryInstance;
}
-
- /**
- * Getter for iterator instance from this registry
- *
- * @return $iteratorInstance An instance of a Iterator class
- */
- public function getIterator () {
- // Prepare a default iterator
- $iteratorInstance = ObjectFactory::createObjectByConfiguredName('node_object_type_iterator_class', array($this));
-
- // And return it
- return $iteratorInstance;
- }
}
// [EOF]
*/
private function verifyAllTags () {
// Get the registry
- $objectRegistryInstance = ObjectFactory::createObjectByConfiguredName('node_object_type_registry_class');
+ $objectRegistryInstance = ObjectTypeRegistryFactory::createObjectTypeRegistryInstance();
// "Walk" over all tags
foreach ($this->getTags() as $tag) {
self::createDebugInstance(__CLASS__)->debugOutput('TAGS: Validating tag ' . $tag . ' ...');
// Get an array from this tag
- $entry = $objectRegistryInstance->getArrayFromKey($tag);
+ $entry = $objectRegistryInstance->getArrayFromKey(XmlObjectRegistryTemplateEngine::OBJECT_TYPE_DATA_NAME, $tag);
// If the array is empty, the entry is invalid!
if (count($entry) == 0) {
} // END - if
// Now save the last discovered protocol/recipient type
- $this->lastProtocol = $entry['object-protocol'];
- $this->lastRecipientType = $entry['object-recipient-type'];
+ $this->lastProtocol = $entry[XmlObjectRegistryTemplateEngine::OBJECT_TYPE_DATA_PROTOCOL];
+ $this->lastRecipientType = $entry[XmlObjectRegistryTemplateEngine::OBJECT_TYPE_DATA_RECIPIENT_TYPE];
} // END - foreach
}
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
class XmlObjectRegistryTemplateEngine extends BaseTemplateEngine implements CompileableTemplate, Registerable {
+ // Constants
+ const OBJECT_TYPE_DATA_NAME = 'object-name';
+ const OBJECT_TYPE_DATA_RECIPIENT_LIMITATION = 'object-recipient-limitation';
+ const OBJECT_TYPE_DATA_MAX_SPREAD = 'object-max-spread';
+ const OBJECT_TYPE_DATA_PROTOCOL = 'object-protocol';
+ const OBJECT_TYPE_DATA_RECIPIENT_TYPE = 'object-recipient-type';
+
/**
* Instance for the object registry
*/
private $subNodes = array(
'object-list',
'object-list-entry',
- 'object-name',
- 'object-recipient-limitation',
- 'object-max-spread',
- 'object-protocol',
- 'object-recipient-type'
+ self::OBJECT_TYPE_DATA_NAME,
+ self::OBJECT_TYPE_DATA_RECIPIENT_LIMITATION,
+ self::OBJECT_TYPE_DATA_MAX_SPREAD,
+ self::OBJECT_TYPE_DATA_PROTOCOL,
+ self::OBJECT_TYPE_DATA_RECIPIENT_TYPE
);
/**
parent::__construct(__CLASS__);
// Init object type registry instance
- $this->objectRegistryInstance = ObjectFactory::createObjectByConfiguredName('node_object_type_registry_class');
+ $this->objectRegistryInstance = ObjectTypeRegistryFactory::createObjectTypeRegistryInstance();
}
/**
// Get current XML node name as an array index
$nodeName = $this->getStackerInstance()->getNamed('object_registry');
- // Is the node name 'object-name'?
- if ($nodeName == 'object-name') {
+ // Is the node name self::OBJECT_TYPE_DATA_NAME?
+ if ($nodeName == self::OBJECT_TYPE_DATA_NAME) {
// Output debug message
self::createDebugInstance(__CLASS__)->debugOutput('TAGS: Adding object type ' . $characters . ' to registry.');
} // END - if
*/
private function startObjectName () {
// Push the node name on the stacker
- $this->getStackerInstance()->pushNamed('object_registry', 'object-name');
+ $this->getStackerInstance()->pushNamed('object_registry', self::OBJECT_TYPE_DATA_NAME);
}
/**
*/
private function startObjectRecipientLimitation () {
// Push the node name on the stacker
- $this->getStackerInstance()->pushNamed('object_registry', 'object-recipient-limitation');
+ $this->getStackerInstance()->pushNamed('object_registry', self::OBJECT_TYPE_DATA_RECIPIENT_LIMITATION);
}
/**
*/
private function startObjectMaxSpread () {
// Push the node name on the stacker
- $this->getStackerInstance()->pushNamed('object_registry', 'object-max-spread');
+ $this->getStackerInstance()->pushNamed('object_registry', self::OBJECT_TYPE_DATA_MAX_SPREAD);
}
/**
*/
private function startObjectProtocol () {
// Push the node name on the stacker
- $this->getStackerInstance()->pushNamed('object_registry', 'object-protocol');
+ $this->getStackerInstance()->pushNamed('object_registry', self::OBJECT_TYPE_DATA_PROTOCOL);
}
/**
*/
private function startObjectRecipientType () {
// Push the node name on the stacker
- $this->getStackerInstance()->pushNamed('object_registry', 'object-recipient-type');
+ $this->getStackerInstance()->pushNamed('object_registry', self::OBJECT_TYPE_DATA_RECIPIENT_TYPE);
}
/**
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
class XmlRequestNodeListTemplateEngine extends BaseTemplateEngine implements CompileableTemplate, Registerable {
+ // Constants for array elements
+ const REQUEST_DATA_ACCEPTED_OBJECT_TYPES = 'accepted-object-types';
+ const REQUEST_DATA_SESSION_ID = 'session-id';
+
/**
* Main nodes in the XML tree
*/
* Sub nodes in the XML tree
*/
private $subNodes = array(
- 'accepted-object-types'
+ self::REQUEST_DATA_ACCEPTED_OBJECT_TYPES,
+ self::REQUEST_DATA_SESSION_ID
);
/**
*/
private function startAcceptedObjectTypes () {
// Push the node name on the stacker
- $this->getStackerInstance()->pushNamed('node_request_node_list', 'accepted-object-types');
+ $this->getStackerInstance()->pushNamed('node_request_node_list', self::REQUEST_DATA_ACCEPTED_OBJECT_TYPES);
+ }
+
+ /**
+ * Starts the session-id
+ *
+ * @return void
+ */
+ private function startSessionId () {
+ // Push the node name on the stacker
+ $this->getStackerInstance()->pushNamed('node_request_node_list', self::REQUEST_DATA_SESSION_ID);
+ }
+
+ /**
+ * Finishes the session-id
+ *
+ * @return void
+ */
+ private function finishSessionId () {
+ // Pop the last entry
+ $this->getStackerInstance()->popNamed('node_request_node_list');
}
/**
to share (even master nodes may not accept all types of objects.
//-->
<accepted-object-types>{?accepted_object_types?}</accepted-object-types>
+ <!--
+ This node's session id
+ //-->
+ <session-id>{?session_id?}</session-id>
</node-request-node-list>