From: Roland Häder Date: Sat, 4 Aug 2012 23:20:23 +0000 (+0000) Subject: Introduced isPackageContentCompleted() X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=67c2f1054bf44da48114cf60da66ba906cdd5672;p=hub.git Introduced isPackageContentCompleted() --- diff --git a/application/hub/main/package/assembler/class_PackageAssembler.php b/application/hub/main/package/assembler/class_PackageAssembler.php index c41ef71e7..9b1b2bdee 100644 --- a/application/hub/main/package/assembler/class_PackageAssembler.php +++ b/application/hub/main/package/assembler/class_PackageAssembler.php @@ -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];