From: Roland Haeder Date: Sun, 16 Mar 2014 20:16:31 +0000 (+0100) Subject: Implemented handleMultipleMessages() X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=144e2c1d9edd7ba43f7548286713b42f36c2b037;p=hub.git Implemented handleMultipleMessages() Signed-off-by: Roland Haeder --- diff --git a/application/hub/main/package/assembler/class_PackageAssembler.php b/application/hub/main/package/assembler/class_PackageAssembler.php index 263300aa0..02983c06e 100644 --- a/application/hub/main/package/assembler/class_PackageAssembler.php +++ b/application/hub/main/package/assembler/class_PackageAssembler.php @@ -207,16 +207,6 @@ class PackageAssembler extends BaseHubSystem implements Assembler, Registerable, return $isPending; } - /** - * Handles multiple messages. - * - * @return void - * @todo 0% done - */ - public function handleMultipleMessages () { - $this->partialStub('Unfinished method.'); - } - /** * Handles the assembler's pending data * @@ -260,7 +250,10 @@ class PackageAssembler extends BaseHubSystem implements Assembler, Registerable, BaseRawDataHandler::PACKAGE_ERROR_CODE => BaseRawDataHandler::SOCKET_ERROR_UNHANDLED ); - // Clear pending data + /* + * Clear pending data as it has been processed and will be handled some + * lines below. + */ $this->clearPendingData(); // Debug message @@ -273,9 +266,9 @@ class PackageAssembler extends BaseHubSystem implements Assembler, Registerable, } // END - if /* - * "explode" the string from 'raw_data' with chunk separator to - * get an array of chunks. These chunks must then be verified by - * their checksums. Also the final chunk must be handled. + * "explode" the string from 'raw_data' with chunk separator to get an + * array of chunks. These chunks must then be verified by their + * checksums. Also the final chunk must be handled. */ $chunks = explode(PackageFragmenter::CHUNK_SEPARATOR, $packageContent[BaseRawDataHandler::PACKAGE_RAW_DATA]); @@ -284,6 +277,23 @@ class PackageAssembler extends BaseHubSystem implements Assembler, Registerable, $this->getHandlerInstance()->addAllChunksWithFinal($chunks); } + /** + * Handles multiple messages. + * + * @return void + */ + public function handleMultipleMessages () { + // Assert on condition + assert($this->ifMultipleMessagesPending()); + assert($this->isPendingDataEmpty()); + + // "Pop" next entry from stack and set it as new pending data + $this->pendingData = $this->getStackerInstance()->popNamed(self::STACKER_NAME_MULTIPLE_MESSAGE); + + // And handle it + $this->handlePendingData(); + } + /** * Accepts the visitor to process the visit "request" *