]> git.mxchange.org Git - hub.git/commitdiff
Add the chunk handler instance and not the stacker, else two stacker instances will...
authorRoland Haeder <roland@mxchange.org>
Sun, 16 Feb 2014 00:57:35 +0000 (01:57 +0100)
committerRoland Haeder <roland@mxchange.org>
Sun, 16 Feb 2014 00:57:35 +0000 (01:57 +0100)
Signed-off-by: Roland Haeder <roland@mxchange.org>
application/hub/main/decoder/package/class_PackageDecoder.php
application/hub/main/tasks/node/decoder/class_NodePackageDecoderTask.php

index cda04a1bc7e006c09d370c0e4058e7408275e472..e7689d193626142993d0d857fa136c2716ecfa89 100644 (file)
@@ -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));
index 6ab2cf8738ca01e6cf2747d6b162844a332b98d0..491b56093709099ad7dbc211389a049bad9c0660 100644 (file)
@@ -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);