*
* @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
*
}
/**
- * "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
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;
* @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