]> git.mxchange.org Git - hub.git/commitdiff
The decoded package is now fully 'decoded' and got handled over into the 'new message...
authorRoland Häder <roland@mxchange.org>
Tue, 8 May 2012 20:20:06 +0000 (20:20 +0000)
committerRoland Häder <roland@mxchange.org>
Tue, 8 May 2012 20:20:06 +0000 (20:20 +0000)
application/hub/config.php
application/hub/interfaces/package/class_Receivable.php
application/hub/main/package/class_NetworkPackage.php
application/hub/main/tasks/network/class_NetworkPackageReaderTask.php

index 8353a61c57b20e41bb58fec5ea2e38ed0c4ba327..928b5ee935c171f59b8eb51f3e16534ba8df15ad 100644 (file)
@@ -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);
 
index 72149c53269968f40db00a83e0c4146583434eef..b45b9868529e2c8ce166b0646d82f9eb75d918de 100644 (file)
@@ -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
index 67cc10b7957039bfe334f02352f060d49773ce12..342c4c673e6545a5af0a0cced1b92215c9851b8f 100644 (file)
@@ -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));
        }
 }
index 057324e98627a862f35b67e87f1fa0b34d198d70..2defd47bfd11e37e158c310862ec415f9a9a5ed5 100644 (file)
@@ -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