X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=application%2Fhub%2Fmain%2Fclass_BaseHubSystem.php;h=a147db4370dac946fd666aeda250e394e49b84a8;hb=c13ca7c93ee55b02d1d3320fca5d2d8d6e953768;hp=978f6922c2d5deda4ac932c269860b0656135b5e;hpb=9f1e17f739807480f3ee3da4ffc5709bef580225;p=hub.git diff --git a/application/hub/main/class_BaseHubSystem.php b/application/hub/main/class_BaseHubSystem.php index 978f6922c..a147db437 100644 --- a/application/hub/main/class_BaseHubSystem.php +++ b/application/hub/main/class_BaseHubSystem.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2011 Hub Developer Team + * @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 * @@ -66,6 +66,21 @@ class BaseHubSystem extends BaseFrameworkSystem { */ private $listenerPoolInstance = NULL; + /** + * Fragmenter instance + */ + private $fragmenterInstance = NULL; + + /** + * Decoder instance + */ + private $decoderInstance = NULL; + + /** + * Assembler instance + */ + private $assemblerInstance = NULL; + /** * Protected constructor * @@ -210,6 +225,103 @@ class BaseHubSystem extends BaseFrameworkSystem { return $this->listenerPoolInstance; } + /** + * Setter for fragmenter instance + * + * @param $fragmenterInstance A Fragmentable instance + * @return void + */ + protected final function setFragmenterInstance (Fragmentable $fragmenterInstance) { + $this->fragmenterInstance = $fragmenterInstance; + } + + /** + * Getter for fragmenter instance + * + * @return $fragmenterInstance A Fragmentable instance + */ + protected final function getFragmenterInstance () { + return $this->fragmenterInstance; + } + + /** + * Setter for decoder instance + * + * @param $decoderInstance A Decodeable instance + * @return void + */ + protected final function setDecoderInstance (Decodeable $decoderInstance) { + $this->decoderInstance = $decoderInstance; + } + + /** + * Getter for decoder instance + * + * @return $decoderInstance A Decodeable instance + */ + protected final function getDecoderInstance () { + return $this->decoderInstance; + } + + /** + * Setter for assembler instance + * + * @param $assemblerInstance A Decodeable instance + * @return void + */ + protected final function setAssemblerInstance (Assembler $assemblerInstance) { + $this->assemblerInstance = $assemblerInstance; + } + + /** + * Getter for assembler instance + * + * @return $assemblerInstance A Decodeable instance + */ + protected final function getAssemblerInstance () { + return $this->assemblerInstance; + } + + /** + * Setter for node id + * + * @param $nodeId Our new node id + * @return void + */ + protected final function setNodeId ($nodeId) { + // Set it config now + $this->getConfigInstance()->setConfigEntry('node_id', (string) $nodeId); + } + + /** + * Getter for node id + * + * @return $nodeId Current node id + */ + public final function getNodeId () { + // Get it from config + return $this->getConfigInstance()->getConfigEntry('node_id'); + } + + /** + * Setter for session id + * + * @param $sessionId Our new session id + * @return void + */ + protected final function setSessionId ($sessionId) { + $this->getConfigInstance()->setConfigEntry('session_id', (string) $sessionId); + } + + /** + * Getter for session id + * + * @return $sessionId Current session id + */ + public final function getSessionId () { + return $this->getConfigInstance()->getConfigEntry('session_id'); + } + /** * Constructs a callable method name from given socket error code. If the * method is not found, a generic one is used. @@ -219,10 +331,7 @@ class BaseHubSystem extends BaseFrameworkSystem { * @throws UnsupportedSocketErrorHandlerException If the error handler is not implemented */ protected function getSocketErrorHandlerFromCode ($errorCode) { - // Set NULL, so everyone is forced to implement socket error handlers - $handlerName = NULL; - - // Temporary create a possible name from translated error code + // Create a name from translated error code $handlerName = 'socketError' . $this->convertToClassName($this->translateSocketErrorCodeToName($errorCode)) . 'Handler'; // Is the call-back method there? @@ -294,10 +403,10 @@ class BaseHubSystem extends BaseFrameworkSystem { assert(count($chunkSplits) == 3); // Validate final chunk - if (substr($chunkSplits[2], 0, strlen(PackageFragmenter::END_OF_PACKAGE_IDENTIFIER)) != PackageFragmenter::END_OF_PACKAGE_IDENTIFIER) { + if (substr($chunkSplits[ChunkHandler::CHUNK_SPLITS_INDEX_RAW_DATA], 0, strlen(PackageFragmenter::END_OF_PACKAGE_IDENTIFIER)) != PackageFragmenter::END_OF_PACKAGE_IDENTIFIER) { // Not fine $isValid = false; - } elseif (substr_count($chunkSplits[2], PackageFragmenter::CHUNK_HASH_SEPARATOR) != 1) { + } elseif (substr_count($chunkSplits[ChunkHandler::CHUNK_SPLITS_INDEX_RAW_DATA], PackageFragmenter::CHUNK_HASH_SEPARATOR) != 1) { // CHUNK_HASH_SEPARATOR shall only be found once $isValid = false; } @@ -382,6 +491,9 @@ class BaseHubSystem extends BaseFrameworkSystem { // Get a visitor instance $visitorInstance = ObjectFactory::createObjectByConfiguredName('shutdown_socket_visitor_class'); + // Debug output + $this->debugOutput('HUB-SYSTEM:' . $this->__toString() . ': visitorInstance=' . $visitorInstance->__toString()); + // Call the visitor $this->accept($visitorInstance); } @@ -403,6 +515,9 @@ class BaseHubSystem extends BaseFrameworkSystem { // Get a visitor instance $visitorInstance = ObjectFactory::createObjectByConfiguredName('half_shutdown_socket_visitor_class'); + // Debug output + $this->debugOutput('HUB-SYSTEM:' . $this->__toString() . ': visitorInstance=' . $visitorInstance->__toString()); + // Call the visitor $this->accept($visitorInstance); }