From: Roland Häder Date: Tue, 8 May 2012 20:20:06 +0000 (+0000) Subject: The decoded package is now fully 'decoded' and got handled over into the 'new message... X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=0a08fc3df26e7de96a0e6fdb235f20fa9dff967e;p=hub.git The decoded package is now fully 'decoded' and got handled over into the 'new message' queue. Still there is unfinished business in handleNewlyArrivedMessage() (please pardon me). --- diff --git a/application/hub/config.php b/application/hub/config.php index 8353a61c5..928b5ee93 100644 --- a/application/hub/config.php +++ b/application/hub/config.php @@ -279,6 +279,9 @@ $cfg->setConfigEntry('stacker_package_handled_decoded_max_size', 200); // CFG: STACKER-PACKAGE-CHUNKED-DECODED-MAX-SIZE $cfg->setConfigEntry('stacker_package_chunked_decoded_max_size', 800); +// CFG: STACKER-PACKAGE-NEW-MESSAGE-MAX-SIZE +$cfg->setConfigEntry('stacker_package_new_message_max_size', 400); + // CFG: STACKER-PACKAGE-BACKBUFFER-MAX-SIZE $cfg->setConfigEntry('stacker_package_backbuffer_max_size', 1000); diff --git a/application/hub/interfaces/package/class_Receivable.php b/application/hub/interfaces/package/class_Receivable.php index 72149c532..b45b98685 100644 --- a/application/hub/interfaces/package/class_Receivable.php +++ b/application/hub/interfaces/package/class_Receivable.php @@ -55,11 +55,18 @@ interface Receivable extends FrameworkInterface { function assembleDecodedDataToPackage (); /** - * Checks whether a new package has arrived + * Checks whether a new message has arrived * - * @return $hasArrived Whether a new package has arrived for processing + * @return $hasArrived Whether a new message has arrived for processing */ - function isNewPackageArrived (); + function isNewMessageArrived (); + + /** + * Handle newly arrived message + * + * @return void + */ + function handleNewlyArrivedMessage (); /** * Adds raw decoded data from the given handler instance to this receiver diff --git a/application/hub/main/package/class_NetworkPackage.php b/application/hub/main/package/class_NetworkPackage.php index 67cc10b79..342c4c673 100644 --- a/application/hub/main/package/class_NetworkPackage.php +++ b/application/hub/main/package/class_NetworkPackage.php @@ -171,6 +171,11 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R */ const STACKER_NAME_DECODED_CHUNKED = 'package_chunked_decoded'; + /** + * Stacker name for new messages + */ + const STACKER_NAME_NEW_MESSAGE = 'package_new_message'; + /************************************************************************** * Stacker for other/internal purposes * **************************************************************************/ @@ -250,6 +255,7 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R self::STACKER_NAME_DECODED_INCOMING, self::STACKER_NAME_DECODED_HANDLED, self::STACKER_NAME_DECODED_CHUNKED, + self::STACKER_NAME_NEW_MESSAGE, self::STACKER_NAME_BACK_BUFFER ) as $stackerName) { // Init this stacker @@ -882,15 +888,6 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R $this->getStackerInstance()->pushNamed(self::STACKER_NAME_DECODED_CHUNKED, $packageContent); } - /** - * Checks whether a new package has arrived - * - * @return $hasArrived Whether a new package has arrived for processing - */ - public function isNewPackageArrived () { - // @TODO Add some content here - } - /** * Accepts the visitor to process the visit "request" * @@ -1017,8 +1014,38 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R throw new InvalidDataChecksumException(array($this, $decodedContent, $decodedData), BaseListener::EXCEPTION_INVALID_DATA_CHECKSUM); } // END - if - // It is the same, then decompress it, the original message is than fully decoded + /* + * It is the same, then decompress it, the original message is than + * fully decoded. + */ $decodedContent[self::PACKAGE_CONTENT_MESSAGE] = $this->getCompressorInstance()->decompressStream($decodedContent[self::PACKAGE_CONTENT_MESSAGE]); + + // And push it on the next stack + $this->getStackerInstance()->pushNamed(self::STACKER_NAME_NEW_MESSAGE, $decodedContent); + } + + /** + * Checks whether a new message has arrived + * + * @return $hasArrived Whether a new message has arrived for processing + */ + public function isNewMessageArrived () { + // Determine if the stack is not empty + $hasArrived = (!$this->getStackerInstance()->isStackEmpty(self::STACKER_NAME_NEW_MESSAGE)); + + // Return it + return $hasArrived; + } + + /** + * Handles newly arrived messages + * + * @return void + */ + public function handleNewlyArrivedMessage () { + // Get it from the stacker, it is the full array with the decoded message + $decodedContent = $this->getStackerInstance()->popNamed(self::STACKER_NAME_NEW_MESSAGE); + die('decodedContent='.print_r($decodedContent,true)); } } diff --git a/application/hub/main/tasks/network/class_NetworkPackageReaderTask.php b/application/hub/main/tasks/network/class_NetworkPackageReaderTask.php index 057324e98..2defd47bf 100644 --- a/application/hub/main/tasks/network/class_NetworkPackageReaderTask.php +++ b/application/hub/main/tasks/network/class_NetworkPackageReaderTask.php @@ -74,9 +74,9 @@ class NetworkPackageReaderTask extends BaseTask implements Taskable, Visitable { */ public function executeTask () { // Do we have something to handle? - if ($this->getPackageInstance()->isNewPackageArrived()) { - // Okay, then handle newly arrived package - $this->getPackageInstance()->handleNewlyArrivedPackage(); + if ($this->getPackageInstance()->isNewMessageArrived()) { + // Okay, then handle newly arrived message + $this->getPackageInstance()->handleNewlyArrivedMessage(); } elseif ($this->getPackageInstance()->isIncomingDecodedDataHandled()) { /* * We have handled decoded data so we should validate it, if we have