]> git.mxchange.org Git - hub.git/commitdiff
Introduced isPackageContentCompleted()
authorRoland Häder <roland@mxchange.org>
Sat, 4 Aug 2012 23:20:23 +0000 (23:20 +0000)
committerRoland Häder <roland@mxchange.org>
Sat, 4 Aug 2012 23:20:23 +0000 (23:20 +0000)
application/hub/main/package/assembler/class_PackageAssembler.php

index c41ef71e7283fb423c0371ba12b096cd6066a4e0..9b1b2bdeeff79c818495697dba0f3fc156327bf9 100644 (file)
@@ -71,6 +71,20 @@ class PackageAssembler extends BaseHubSystem implements Assembler, Registerable
                return $isInputBufferEmpty;
        }
 
+       /**
+        * Checks whether given package content is completed (start/end markers are found)
+        *
+        * @param       $packageContent         An array with two elements: 'decoded_data' and 'error_code'
+        * @return      $isCompleted            Whether the given package content is completed
+        */
+       private function isPackageContentCompleted (array $packageContent) {
+               // Check both
+               $isCompleted = ((substr($packageContent[BaseRawDataHandler::PACKAGE_DECODED_DATA], 0, 5) == '[[S]]') && (substr($packageContent[BaseRawDataHandler::PACKAGE_DECODED_DATA], -5, 5) == '[[E]]'));
+
+               // Return status
+               return $isCompleted;
+       }
+
        /**
         * Assembles the content from $packageContent. This method does only
         * initialize the whole process by creating a call-back which will then
@@ -124,7 +138,7 @@ class PackageAssembler extends BaseHubSystem implements Assembler, Registerable
                /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PACKAGE-ASSEMBLER: packageData[' . BaseRawDataHandler::PACKAGE_DECODED_DATA . ']=' . $packageContent[BaseRawDataHandler::PACKAGE_DECODED_DATA]);
 
                // Check for some conditions
-               if (!$this->ifInputBufferIsEmpty()) {
+               if ((!$this->ifInputBufferIsEmpty()) || (!$this->isPackageContentCompleted($packageContent))) {
                        // Last chunk is not valid, so wait for more
                        $this->pendingData .= $packageContent[BaseRawDataHandler::PACKAGE_DECODED_DATA];