From: Roland Haeder Date: Sun, 16 Feb 2014 00:57:35 +0000 (+0100) Subject: Add the chunk handler instance and not the stacker, else two stacker instances will... X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=5be532bb8fe1db0e4599d97a6f51217deffab17d;p=hub.git Add the chunk handler instance and not the stacker, else two stacker instances will be used which doesn't work. Signed-off-by: Roland Haeder --- diff --git a/application/hub/main/decoder/package/class_PackageDecoder.php b/application/hub/main/decoder/package/class_PackageDecoder.php index cda04a1bc..e7689d193 100644 --- a/application/hub/main/decoder/package/class_PackageDecoder.php +++ b/application/hub/main/decoder/package/class_PackageDecoder.php @@ -40,18 +40,18 @@ class PackageDecoder extends BaseDecoder implements Decodeable { /** * Creates an instance of this class * - * @param $stackerInstance An instance of a Stackable class + * @param $handlerInstance An instance of a HandleableChunks class * @return $decoderInstance An instance of a Decodeable class */ - public final static function createPackageDecoder (Stackable $stackerInstance) { + public final static function createPackageDecoder (HandleableChunks $handlerInstance) { // Get new instance $decoderInstance = new PackageDecoder(); // Init stacker for received packages - $stackerInstance->initStack(self::STACKER_NAME_DECODED_PACKAGE); + $handlerInstance->getStackerInstance()->initStack(self::STACKER_NAME_DECODED_PACKAGE); - // Set the stacker instance here - $decoderInstance->setStackerInstance($stackerInstance); + // Set the handler instance here + $decoderInstance->setHandlerInstance($handlerInstance); // Get a singleton network package instance $packageInstance = NetworkPackageFactory::createNetworkPackageInstance(); @@ -70,7 +70,7 @@ class PackageDecoder extends BaseDecoder implements Decodeable { */ public function ifUnhandledRawPackageDataLeft () { // Check it - $unhandledDataLeft = (!$this->getStackerInstance()->isStackEmpty(ChunkHandler::STACKER_NAME_ASSEMBLED_RAW_DATA)); + $unhandledDataLeft = (!$this->getHandlerInstance()->getStackerInstance()->isStackEmpty(ChunkHandler::STACKER_NAME_ASSEMBLED_RAW_DATA)); // Return it return $unhandledDataLeft; @@ -86,7 +86,7 @@ class PackageDecoder extends BaseDecoder implements Decodeable { assert($this->ifUnhandledRawPackageDataLeft()); // "Pop" the next raw package content - $rawPackageContent = $this->getStackerInstance()->popNamed(ChunkHandler::STACKER_NAME_ASSEMBLED_RAW_DATA); + $rawPackageContent = $this->getHandlerInstance()->getStackerInstance()->popNamed(ChunkHandler::STACKER_NAME_ASSEMBLED_RAW_DATA); // Debug message /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PACKAGE-DECODER[' . __METHOD__ . ':' . __LINE__ . ']: Got ' . strlen($rawPackageContent) . ' bytes from stack ' . ChunkHandler::STACKER_NAME_ASSEMBLED_RAW_DATA . ', decoding it ...'); @@ -107,7 +107,7 @@ class PackageDecoder extends BaseDecoder implements Decodeable { if ($discoveryInstance->isRecipientListEmpty()) { // The recipient is this node so next stack it on 'decoded_package' /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PACKAGE-DECODER[' . __METHOD__ . ':' . __LINE__ . ']: Pushing ' . strlen($decodedData) . ' bytes to stack ' . self::STACKER_NAME_DECODED_PACKAGE . ' ...'); - $this->getStackerInstance()->pushNamed(self::STACKER_NAME_DECODED_PACKAGE, $decodedData); + $this->getHandlerInstance()->getStackerInstance()->pushNamed(self::STACKER_NAME_DECODED_PACKAGE, $decodedData); } else { // Forward the package to the next node $this->getPackageInstance()->forwardRawPackage($decodedData); @@ -121,7 +121,7 @@ class PackageDecoder extends BaseDecoder implements Decodeable { */ public function ifDeocedPackagesLeft () { // Check it ... - $ifRawPackagesLeft = (!$this->getStackerInstance()->isStackEmpty(self::STACKER_NAME_DECODED_PACKAGE)); + $ifRawPackagesLeft = (!$this->getHandlerInstance()->getStackerInstance()->isStackEmpty(self::STACKER_NAME_DECODED_PACKAGE)); // ... return it return $ifRawPackagesLeft; @@ -137,7 +137,7 @@ class PackageDecoder extends BaseDecoder implements Decodeable { assert($this->ifDeocedPackagesLeft()); // Get the next entry (assoziative array) - $decodedData = $this->getStackerInstance()->popNamed(self::STACKER_NAME_DECODED_PACKAGE); + $decodedData = $this->getHandlerInstance()->getStackerInstance()->popNamed(self::STACKER_NAME_DECODED_PACKAGE); // Handle it /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PACKAGE-DECODER[' . __METHOD__ . ':' . __LINE__ . ']: decodedData()=' . strlen($decodedData)); diff --git a/application/hub/main/tasks/node/decoder/class_NodePackageDecoderTask.php b/application/hub/main/tasks/node/decoder/class_NodePackageDecoderTask.php index 6ab2cf873..491b56093 100644 --- a/application/hub/main/tasks/node/decoder/class_NodePackageDecoderTask.php +++ b/application/hub/main/tasks/node/decoder/class_NodePackageDecoderTask.php @@ -44,11 +44,8 @@ class NodePackageDecoderTask extends BaseTask implements Taskable, Visitable { // Get a chunk handler instance $handlerInstance = ChunkHandlerFactory::createChunkHandlerInstance(); - // Get the stacker from it, we don't need the handler here - $stackerInstance = $handlerInstance->getStackerInstance(); - // Get a decoder instance - $decoderInstance = ObjectFactory::createObjectByConfiguredName('package_decoder_class', array($stackerInstance)); + $decoderInstance = ObjectFactory::createObjectByConfiguredName('package_decoder_class', array($handlerInstance)); // ... and also set the decoder instance here $taskInstance->setDecoderInstance($decoderInstance);