/**
* Creates an instance of this class
*
- * @param $stackerInstance An instance of a Stackable class
+ * @param $handlerInstance An instance of a HandleableChunks class
* @return $decoderInstance An instance of a Decodeable class
*/
- public final static function createPackageDecoder (Stackable $stackerInstance) {
+ public final static function createPackageDecoder (HandleableChunks $handlerInstance) {
// Get new instance
$decoderInstance = new PackageDecoder();
// Init stacker for received packages
- $stackerInstance->initStack(self::STACKER_NAME_DECODED_PACKAGE);
+ $handlerInstance->getStackerInstance()->initStack(self::STACKER_NAME_DECODED_PACKAGE);
- // Set the stacker instance here
- $decoderInstance->setStackerInstance($stackerInstance);
+ // Set the handler instance here
+ $decoderInstance->setHandlerInstance($handlerInstance);
// Get a singleton network package instance
$packageInstance = NetworkPackageFactory::createNetworkPackageInstance();
*/
public function ifUnhandledRawPackageDataLeft () {
// Check it
- $unhandledDataLeft = (!$this->getStackerInstance()->isStackEmpty(ChunkHandler::STACKER_NAME_ASSEMBLED_RAW_DATA));
+ $unhandledDataLeft = (!$this->getHandlerInstance()->getStackerInstance()->isStackEmpty(ChunkHandler::STACKER_NAME_ASSEMBLED_RAW_DATA));
// Return it
return $unhandledDataLeft;
assert($this->ifUnhandledRawPackageDataLeft());
// "Pop" the next raw package content
- $rawPackageContent = $this->getStackerInstance()->popNamed(ChunkHandler::STACKER_NAME_ASSEMBLED_RAW_DATA);
+ $rawPackageContent = $this->getHandlerInstance()->getStackerInstance()->popNamed(ChunkHandler::STACKER_NAME_ASSEMBLED_RAW_DATA);
// Debug message
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PACKAGE-DECODER[' . __METHOD__ . ':' . __LINE__ . ']: Got ' . strlen($rawPackageContent) . ' bytes from stack ' . ChunkHandler::STACKER_NAME_ASSEMBLED_RAW_DATA . ', decoding it ...');
if ($discoveryInstance->isRecipientListEmpty()) {
// The recipient is this node so next stack it on 'decoded_package'
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PACKAGE-DECODER[' . __METHOD__ . ':' . __LINE__ . ']: Pushing ' . strlen($decodedData) . ' bytes to stack ' . self::STACKER_NAME_DECODED_PACKAGE . ' ...');
- $this->getStackerInstance()->pushNamed(self::STACKER_NAME_DECODED_PACKAGE, $decodedData);
+ $this->getHandlerInstance()->getStackerInstance()->pushNamed(self::STACKER_NAME_DECODED_PACKAGE, $decodedData);
} else {
// Forward the package to the next node
$this->getPackageInstance()->forwardRawPackage($decodedData);
*/
public function ifDeocedPackagesLeft () {
// Check it ...
- $ifRawPackagesLeft = (!$this->getStackerInstance()->isStackEmpty(self::STACKER_NAME_DECODED_PACKAGE));
+ $ifRawPackagesLeft = (!$this->getHandlerInstance()->getStackerInstance()->isStackEmpty(self::STACKER_NAME_DECODED_PACKAGE));
// ... return it
return $ifRawPackagesLeft;
assert($this->ifDeocedPackagesLeft());
// Get the next entry (assoziative array)
- $decodedData = $this->getStackerInstance()->popNamed(self::STACKER_NAME_DECODED_PACKAGE);
+ $decodedData = $this->getHandlerInstance()->getStackerInstance()->popNamed(self::STACKER_NAME_DECODED_PACKAGE);
// Handle it
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('PACKAGE-DECODER[' . __METHOD__ . ':' . __LINE__ . ']: decodedData()=' . strlen($decodedData));
// Get a chunk handler instance
$handlerInstance = ChunkHandlerFactory::createChunkHandlerInstance();
- // Get the stacker from it, we don't need the handler here
- $stackerInstance = $handlerInstance->getStackerInstance();
-
// Get a decoder instance
- $decoderInstance = ObjectFactory::createObjectByConfiguredName('package_decoder_class', array($stackerInstance));
+ $decoderInstance = ObjectFactory::createObjectByConfiguredName('package_decoder_class', array($handlerInstance));
// ... and also set the decoder instance here
$taskInstance->setDecoderInstance($decoderInstance);