]> git.mxchange.org Git - hub.git/blobdiff - application/hub/main/helper/connection/class_BaseConnectionHelper.php
Copyright notice updated, our first hub application introduced (which is incomplete)
[hub.git] / application / hub / main / helper / connection / class_BaseConnectionHelper.php
index a5d427bde97e3579ac6fa5cf8356d5ec75559cdd..0f2ffcc01fd6f9dd05d03d67a858efeb1f385fbd 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, 2010 Hub Developer Team
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2011 Hub Developer Team
  * @license            GNU GPL 3.0 or any newer version
  * @link               http://www.ship-simu.org
  *
@@ -140,8 +140,16 @@ class BaseConnectionHelper extends BaseHubHelper implements Registerable, Protoc
        }
 
        /**
-        * "Getter" for raw package data from a package array. This method does
-        * honor any unsend bytes in the back-buffer and the sending buffer size.
+        * "Getter" for raw data from a package array. A fragmenter is used which
+        * will returns us only so many raw data which fits into the back buffer.
+        * The rest is being held in a back-buffer and waits there for the next
+        * cycle and while be then sent. This is done by a FIFO.
+        *
+        * This method does 4 simple steps:
+        * 1) Aquire fragmenter object instance from the factory
+        * 2) Handle over the package data array to the fragmenter
+        * 3) Request a chunk (which "pops" the chunk from the fragmenter's FIFO)
+        * 4) Finally return the chunk to the caller
         *
         * @param       $packageData    Raw package data array
         * @return      $rawData                Raw package data bytes
@@ -149,7 +157,14 @@ class BaseConnectionHelper extends BaseHubHelper implements Registerable, Protoc
        private function getRawDataFromPackageArray (array $packageData) {
                // Get the fragmenter instance
                $fragmenterInstance = ObjectFactory::createObjectByConfiguredName('package_fragmenter_class');
-               $fragmenterInstance->debugInstance();
+
+               // Implode the package data array and fragement the resulting string
+               $fragmenterInstance->fragmentPackageArray($packageData, $this);
+
+               // Get the next raw data chunk from the fragmenter's FIFO
+               $rawData = $fragmenterInstance->getNextRawDataChunk($packageData);
+               /* DEBUG: */ $this->debugOutput('rawData['.strlen($rawData).']='.$rawData);
+               /* DEBUG: */ die();
 
                // Return it
                return $rawData;
@@ -163,7 +178,7 @@ class BaseConnectionHelper extends BaseHubHelper implements Registerable, Protoc
         * @throws      InvalidSocketException  If we got a problem with this socket
         */
        public function sendRawPackageData (array $packageData) {
-               // We need to "package" all data. This is done by a implode()
+               // Convert the package data array to a raw data stream
                $rawData = $this->getRawDataFromPackageArray($packageData);
 
                // Get socket resource