]> git.mxchange.org Git - hub.git/blobdiff - application/hub/main/tasks/network/class_NetworkPackageReaderTask.php
Renamed some methods to make them more clear
[hub.git] / application / hub / main / tasks / network / class_NetworkPackageReaderTask.php
index 057324e98627a862f35b67e87f1fa0b34d198d70..4a9537d5baee378fdeb42e309408e557dac899fe 100644 (file)
@@ -4,7 +4,7 @@
  *
  * @author             Roland Haeder <webmaster@ship-simu.org>
  * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2011 Hub Developer Team
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
  * @license            GNU GPL 3.0 or any newer version
  * @link               http://www.ship-simu.org
  *
@@ -74,21 +74,34 @@ 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();
-               } elseif ($this->getPackageInstance()->isIncomingDecodedDataHandled()) {
+               if ($this->getPackageInstance()->isProcessedMessagePending()) {
                        /*
-                        * We have handled decoded data so we should validate it, if we have
-                        * all chunks/fragments together, and assemble it into an abstract
-                        * network package.
+                        * A previously proccessed message is waiting for being
+                        * "interpreted". This is done by trying to find a configuration
+                        * entry based on 'message_type' element.
+                        */
+                       $this->getPackageInstance()->handleProcessedMessage();
+               } elseif ($this->getPackageInstance()->isNewMessageArrived()) {
+                       /*
+                        * A fully "decoded" message has been received and added for being
+                        * processed. Processing a message should not take long, so mostly
+                        * this step involves reading all data through a XML template engine
+                        * as "XML variables" from the content (which must be a well-formed
+                        * XML) and then pushing it on the next stack "processed messages".
+                        */
+                       $this->getPackageInstance()->handleNewlyArrivedMessage();
+               } elseif ($this->getPackageInstance()->isIncomingRawDataHandled()) {
+                       /*
+                        * Incoming decoded data has been handled (see below) so it needs to
+                        * be assembled back to a "package array". Please see NetworkPackage
+                        * for further details (what array elements are required et cetera).
                         */
                        $this->getPackageInstance()->assembleDecodedDataToPackage();
                } elseif ($this->getPackageInstance()->isNewRawDataPending($this->getListenerPoolInstance())) {
-                       // We have to handle raw data from the socket
+                       // Raw, decoded data has been received
                        $this->getPackageInstance()->handleIncomingDecodedData();
                } elseif ($this->getPackageInstance()->ifAssemblerHasPendingDataLeft()) {
-                       // Okay, handle it here
+                       // Handle any pending data from the package assembler
                        $this->getPackageInstance()->handleAssemblerPendingData();
                } // END - if
        }