]> git.mxchange.org Git - hub.git/blobdiff - application/hub/main/tasks/network/class_NetworkPackageWriterTask.php
Updated 'core'.
[hub.git] / application / hub / main / tasks / network / class_NetworkPackageWriterTask.php
index 2bba76f86a8b6df6ce7940e8a7aa1a43463b2070..3f24ec0f6b83893a54b1307c3d2c6481573277ab 100644 (file)
@@ -2,11 +2,11 @@
 /**
  * A NetworkPackageWriter task
  *
- * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @author             Roland Haeder <webmaster@shipsimu.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 - 2015 Hub Developer Team
  * @license            GNU GPL 3.0 or any newer version
- * @link               http://www.ship-simu.org
+ * @link               http://www.shipsimu.org
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -35,7 +35,7 @@ class NetworkPackageWriterTask extends BaseTask implements Taskable, Visitable {
        /**
         * Creates an instance of this class
         *
-        * @return      $taskInstance   An instance of a Visitable class
+        * @return      $taskInstance   An instance of a Taskable/Visitable class
         */
        public static final function createNetworkPackageWriterTask () {
                // Get new instance
@@ -46,10 +46,11 @@ class NetworkPackageWriterTask extends BaseTask implements Taskable, Visitable {
        }
 
        /**
-        * Accepts the visitor to process the visit "request"
+        * Accepts the visitor to process the visitor
         *
         * @param       $visitorInstance        An instance of a Visitor class
         * @return      void
+        * @todo        Also visit some sub-objects?
         */
        public function accept (Visitor $visitorInstance) {
                // Visit this task
@@ -62,21 +63,34 @@ class NetworkPackageWriterTask extends BaseTask implements Taskable, Visitable {
         * @return      void
         */
        public function executeTask () {
-               // Get a singleton network package instance
+               // "Cache" package instance
                $packageInstance = NetworkPackageFactory::createNetworkPackageInstance();
 
                // Do we have something to deliver?
-               if ($packageInstance->isPackageEnqueued()) {
-                       // Okay, then deliver (better discover its recipients) this package
-                       $packageInstance->declareEnqueuedPackage();
-               } elseif ($packageInstance->isPackageDeclared()) {
-                       // Prepare package for delivery
-                       $packageInstance->deliverDeclaredPackage();
+               if ($packageInstance->isEncodedDataPending()) {
+                       // Sent encoded (raw) data
+                       $packageInstance->sendEncodedData();
                } elseif ($packageInstance->isPackageWaitingForDelivery()) {
                        // Sent it finally out
                        $packageInstance->sendWaitingPackage();
+               } elseif ($packageInstance->isPackageDeclared()) {
+                       // Prepare package for delivery
+                       $packageInstance->processDeclaredPackage();
+               } elseif ($packageInstance->isPackageEnqueued()) {
+                       // Okay, then deliver (better discover its recipients) this package
+                       $packageInstance->declareEnqueuedPackage();
                }
        }
+
+       /**
+        * Shuts down the task
+        *
+        * @return      void
+        * @todo        0% done
+        */
+       public function doShutdown () {
+               self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...');
+       }
 }
 
 // [EOF]