/**
* Checks whether given package content is completed (start/end markers are found)
*
- * @param $packageContent An array with two elements: 'decoded_data' and 'error_code'
+ * @param $packageContent An array with two elements: 'raw_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]]'));
+ $isCompleted = ((substr($packageContent[BaseRawDataHandler::PACKAGE_RAW_DATA], 0, 5) == '[[S]]') && (substr($packageContent[BaseRawDataHandler::PACKAGE_RAW_DATA], -5, 5) == '[[E]]'));
// Return status
return $isCompleted;
* chunks and (maybe) re-request some chunks from the sender, this would
* take to much time and therefore slow down this node again.
*
- * @param $packageContent An array with two elements: 'decoded_data' and 'error_code'
+ * @param $packageContent An array with two elements: 'raw_data' and 'error_code'
* @return void
* @throws UnsupportedPackageCodeHandlerException If the package code handler is not implemented
*/
public function chunkPackageContent (array $packageContent) {
// Validate the package content array again
assert(
- (isset($packageContent[BaseRawDataHandler::PACKAGE_DECODED_DATA])) &&
+ (isset($packageContent[BaseRawDataHandler::PACKAGE_RAW_DATA])) &&
(isset($packageContent[BaseRawDataHandler::PACKAGE_ERROR_CODE]))
);
* some low checks on it and feeds it into another queue for verification
* and re-request for bad chunks.
*
- * @param $packageContent An array with two elements: 'decoded_data' and 'error_code'
+ * @param $packageContent An array with two elements: 'raw_data' and 'error_code'
* @return void
* @throws FinalChunkVerificationException If the final chunk does not start with 'EOP:'
*/
private function handlePackageByUnhandledPackage (array $packageContent) {
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PACKAGE-ASSEMBLER: packageData[' . BaseRawDataHandler::PACKAGE_DECODED_DATA . ']=' . $packageContent[BaseRawDataHandler::PACKAGE_DECODED_DATA]);
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PACKAGE-ASSEMBLER: 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_DECODED_DATA];
+ $this->pendingData .= $packageContent[BaseRawDataHandler::PACKAGE_RAW_DATA];
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PACKAGE-ASSEMBLER: Partial data received. Waiting for more ... ( ' . strlen($packageContent[BaseRawDataHandler::PACKAGE_DECODED_DATA]) . ' bytes)');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PACKAGE-ASSEMBLER: Partial data received. Waiting for more ... ( ' . strlen($packageContent[BaseRawDataHandler::PACKAGE_RAW_DATA]) . ' bytes)');
} else {
// Debug message
//* NOISY-DEBUG */ self::createDebugInstance(__CLASS__)->debugOutput('packageContent=' . print_r($packageContent,true) . ',chunks='.print_r($chunks,true));
/*
- * "explode" the string from 'decoded_data' with chunk separator to
+ * "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_DECODED_DATA]);
+ $chunks = explode(PackageFragmenter::CHUNK_SEPARATOR, $packageContent[BaseRawDataHandler::PACKAGE_RAW_DATA]);
// Now get a chunk handler instance
$handlerInstance = ChunkHandlerFactory::createChunkHandlerInstance();
// Init fake array
$packageContent = array(
- BaseRawDataHandler::PACKAGE_DECODED_DATA => $this->pendingData,
+ BaseRawDataHandler::PACKAGE_RAW_DATA => $this->pendingData,
BaseRawDataHandler::PACKAGE_ERROR_CODE => BaseRawDataHandler::SOCKET_ERROR_UNHANDLED
);
$this->pendingData = '';
// Debug message
- /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PACKAGE-ASSEMBLER: Last block of partial data received. A total of ' . strlen($packageContent[BaseRawDataHandler::PACKAGE_DECODED_DATA]) . ' bytes has been received.');
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PACKAGE-ASSEMBLER: Last block of partial data received. A total of ' . strlen($packageContent[BaseRawDataHandler::PACKAGE_RAW_DATA]) . ' bytes has been received.');
// Call the real handler method
$this->handlePackageByUnhandledPackage($packageContent);
// Make sure both array elements are there
assert(
(is_array($decodedData)) &&
- (isset($decodedData[BaseRawDataHandler::PACKAGE_DECODED_DATA])) &&
+ (isset($decodedData[BaseRawDataHandler::PACKAGE_RAW_DATA])) &&
(isset($decodedData[BaseRawDataHandler::PACKAGE_ERROR_CODE]))
);
assert($decodedData[BaseRawDataHandler::PACKAGE_ERROR_CODE] == BaseRawDataHandler::SOCKET_ERROR_UNHANDLED);
// Remove the last chunk SEPARATOR (because it is being added and we don't need it)
- if (substr($decodedData[BaseRawDataHandler::PACKAGE_DECODED_DATA], -1, 1) == PackageFragmenter::CHUNK_SEPARATOR) {
+ if (substr($decodedData[BaseRawDataHandler::PACKAGE_RAW_DATA], -1, 1) == PackageFragmenter::CHUNK_SEPARATOR) {
// It is there and should be removed
- $decodedData[BaseRawDataHandler::PACKAGE_DECODED_DATA] = substr($decodedData[BaseRawDataHandler::PACKAGE_DECODED_DATA], 0, -1);
+ $decodedData[BaseRawDataHandler::PACKAGE_RAW_DATA] = substr($decodedData[BaseRawDataHandler::PACKAGE_RAW_DATA], 0, -1);
} // END - if
// This package is "handled" and can be pushed on the next stack
public function addRawDataToIncomingStack (Networkable $handlerInstance) {
/*
* Get the decoded data from the handler, this is an array with
- * 'decoded_data' and 'error_code' as elements.
+ * 'raw_data' and 'error_code' as elements.
*/
$decodedData = $handlerInstance->getNextRawData();