*
* @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
*
/**
* "Getter" to get a string respresentation for a key for the sub-registry
- * in this format: class:protocol:port
+ * in this format: class:type:port
*
* @param $connectionInstance An instance of a ConnectionHelper class
* @return $key A string representation of the socket for the registry
*/
private function getSubRegistryKey (ConnectionHelper $connectionInstance) {
- // Get protocol and port number and add both together
- $key = sprintf("%s:%s:%s",
+ // Debug message
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']: connectionInstance=' . $connectionInstance->__toString() . ' CALLED!');
+
+ // Get connection type and port number and add both together
+ $key = sprintf('%s:%s:%s',
$connectionInstance->__toString(),
- $connectionInstance->getProtocol(),
- $connectionInstance->getPort()
+ $connectionInstance->getConnectionType(),
+ $connectionInstance->getConnectionPort()
);
+ // Debug message
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']: key=' . $key . ' - EXIT!');
+
// Return resulting key
return $key;
}
/**
* "Getter" to get a string respresentation of the protocol
*
- * @param $connectionInstance An instance of a ConnectionHelper class
- * @return $key A string representation of the protocol for the registry
+ * @param $connectionInstance An instance of a ConnectionHelper class
+ * @return $key A string representation of the protocol for the registry
*/
- private function getRegistryKeyFromProtocol (ConnectionHelper $connectionInstance) {
+ private function getRegistryKeyFromConnection (ConnectionHelper $connectionInstance) {
// Get the key
- $key = $connectionInstance->getProtocol();
+ $key = $connectionInstance->getProtocolName();
// Return resulting key
return $key;
* @param $connectionInstance An instance of a ConnectionHelper class
* @return $isRegistered Whether the protocol is registered
*/
- private function isProtocolRegistered (ConnectionHelper $connectionInstance) {
+ private function isConnectionRegistered (ConnectionHelper $connectionInstance) {
// Get the key
- $key = $this->getRegistryKeyFromProtocol($connectionInstance);
+ $key = $this->getRegistryKeyFromConnection($connectionInstance);
// Determine it
$isRegistered = $this->instanceExists($key);
$isRegistered = FALSE;
// First, check for the instance, there can be only once
- if ($this->isProtocolRegistered($connectionInstance)) {
+ if ($this->isConnectionRegistered($connectionInstance)) {
// That one is found so "get" a registry key from it
- $key = $this->getRegistryKeyFromProtocol($connectionInstance);
+ $key = $this->getRegistryKeyFromConnection($connectionInstance);
// Get the registry
$registryInstance = $this->getInstance($key);
} // END - if
// Does the instance exist?
- if (!$this->isProtocolRegistered($connectionInstance)) {
+ if (!$this->isConnectionRegistered($connectionInstance)) {
// No, not found so we create a sub registry (not needed to configure!)
$registryInstance = SubRegistry::createSubRegistry();
// Now we can create the sub-registry for this protocol
- $this->addInstance($this->getRegistryKeyFromProtocol($connectionInstance), $registryInstance);
+ $this->addInstance($this->getRegistryKeyFromConnection($connectionInstance), $registryInstance);
} else {
// Get the sub-registry back
- $registryInstance = $this->getInstance($this->getRegistryKeyFromProtocol($connectionInstance));
+ $registryInstance = $this->getInstance($this->getRegistryKeyFromConnection($connectionInstance));
}
// Get a key for sub-registries
$socketInstance = ObjectFactory::CreateObjectByConfiguredName('socket_container_class', array($socketResource, $connectionInstance, $packageData));
// We have a sub-registry, the socket key and the socket, now we need to put all together
- /* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-REGISTRY[' . __LINE__ . ']: socketKey=' . $socketKey . ',socketResource=' . $socketResource . ' - adding socket container instance ...');
+ /* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']: socketKey=' . $socketKey . ',socketResource=' . $socketResource . ' - adding socket container instance ...');
$registryInstance->addInstance($socketKey, $socketInstance);
}
} // END - if
// Now get the key from the protocol
- $key = $this->getRegistryKeyFromProtocol($connectionInstance);
+ $key = $this->getRegistryKeyFromConnection($connectionInstance);
// And get the registry
$registryInstance = $this->getInstance($key);
// This is always a SubRegistry instance
foreach ($registryInstance->getInstanceRegistry() as $subKey => $containerInstance) {
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-REGISTRY[' . __LINE__ . ']: key=' . $key . ',subKey=' . $subKey . ',containerInstance=' . $containerInstance->__toString());
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('CONNECTION-REGISTRY[' . __METHOD__ . ':' . __LINE__ . ']: key=' . $key . ',subKey=' . $subKey . ',containerInstance=' . $containerInstance->__toString());
// This is a ConnectionContainer instance, so does the recipient match?
if ($containerInstance->ifAddressMatches($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT])) {