+ // Debug message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PACKAGE-ASSEMBLER[' . __METHOD__ . ':' . __LINE__ . ']: packageData[' . BaseRawDataHandler::PACKAGE_RAW_DATA . ']=' . $packageContent[BaseRawDataHandler::PACKAGE_RAW_DATA]);
+
+ // Check for some conditions
+ if ((!$this->ifInputBufferIsEmpty()) || (!$this->isPackageContentCompleted($packageContent))) {
+ // Last chunk is not valid, so wait for more
+ $this->pendingData .= $packageContent[BaseRawDataHandler::PACKAGE_RAW_DATA];
+
+ // Debug message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PACKAGE-ASSEMBLER[' . __METHOD__ . ':' . __LINE__ . ': Partial data received. Waiting for more ... ( ' . strlen($packageContent[BaseRawDataHandler::PACKAGE_RAW_DATA]) . ' bytes)');
+ } else {
+ // Debug message
+ /* DEBUG */ self::createDebugInstance(__CLASS__)->debugOutput('PACKAGE-ASSEMBLER[' . __METHOD__ . ':' . __LINE__ . ': packageContent=' . print_r($packageContent, TRUE) . ',chunks='.print_r($chunks, TRUE));
+ }
+ }
+
+ /**
+ * Checks whether the assembler's pending data is empty which means it has
+ * no pending data left for handling ... ;-)
+ *
+ * @return $ifPendingDataIsEmpty Whether pending data is empty
+ */
+ public function isPendingDataEmpty () {
+ // A simbple check
+ $ifPendingDataIsEmpty = empty($this->pendingData);
+
+ // Return it
+ return $ifPendingDataIsEmpty;
+ }
+
+ /**
+ * Handles the assembler's pending data
+ *
+ * @return void
+ */
+ public function handlePendingData () {
+ // Debug output
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PACKAGE-ASSEMBLER[' . __METHOD__ . ':' . __LINE__ . ': Going to decode ' . strlen($this->pendingData) . ' Bytes of pending data. pendingData=' . $this->pendingData);
+
+ // Assert on condition
+ assert(!$this->isPendingDataEmpty());
+
+ // No markers set?
+ if (!$this->ifStartEndMarkersSet($this->pendingData)) {
+ // This will cause an assertition in next call, so simply wait for more data
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PACKAGE-ASSEMBLER[' . __METHOD__ . ':' . __LINE__ . ': Pending data of ' . strlen($this->pendingData) . ' Bytes are incomplete, waiting for more ...');
+ return;
+ } // END - if
+
+ // Init fake array
+ $packageContent = array(
+ BaseRawDataHandler::PACKAGE_RAW_DATA => $this->getInputStreamInstance()->streamData($this->pendingData),
+ BaseRawDataHandler::PACKAGE_ERROR_CODE => BaseRawDataHandler::SOCKET_ERROR_UNHANDLED
+ );
+
+ // Clear pending data
+ $this->pendingData = '';
+
+ // Debug message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PACKAGE-ASSEMBLER[' . __METHOD__ . ':' . __LINE__ . ': Last block of partial data received. A total of ' . strlen($packageContent[BaseRawDataHandler::PACKAGE_RAW_DATA]) . ' bytes has been received.');
+
+ // Make sure last CHUNK_SEPARATOR is not there
+ if (substr($packageContent[BaseRawDataHandler::PACKAGE_RAW_DATA], -1, 1) == PackageFragmenter::CHUNK_SEPARATOR) {
+ // Remove it
+ $packageContent[BaseRawDataHandler::PACKAGE_RAW_DATA] = substr($packageContent[BaseRawDataHandler::PACKAGE_RAW_DATA], 0, -1);
+ } // END - if
+