]> git.mxchange.org Git - hub.git/commitdiff
Implemented handleMultipleMessages()
authorRoland Haeder <roland@mxchange.org>
Sun, 16 Mar 2014 20:16:31 +0000 (21:16 +0100)
committerRoland Haeder <roland@mxchange.org>
Sun, 16 Mar 2014 20:16:31 +0000 (21:16 +0100)
Signed-off-by: Roland Haeder <roland@mxchange.org>
application/hub/main/package/assembler/class_PackageAssembler.php

index 263300aa00b6e74d881fa6f962a343c7c96eb27a..02983c06e8b3ec3c618166d44a283a04a6423b30 100644 (file)
@@ -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"
         *