function declareEnqueuedPackage ();
/**
- * Delivers the next declared package. Only one package per time will be sent
- * because this may take time and slows down the whole delivery
+ * Processes the next declared package. Only one package per time will be
+ * processed because this may take time and slows down the whole delivery
* infrastructure.
*
* @return void
*/
- function deliverDeclaredPackage ();
+ function processDeclaredPackage ();
/**
* Sends waiting packages out for delivery
* The rest is being held in a back-buffer and waits there for the next
* cycle and while be then sent.
*
- * 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
- * 4) Finally return the chunk (array) to the caller
+ * This method does 2 simple steps:
+ * 1) Request a chunk from set fragmenter instance
+ * 2) Finally return the chunk (array) to the caller
*
* @param $packageData Raw package data array
* @return $chunkData Raw data chunk
///////////////////////////////////////////////////////////////////////////
/**
- * Delivers the given raw package data.
+ * Declares the given raw package data by discovering recipients
*
* @param $packageData Raw package data in an array
* @return void
// Set the recipient
$packageData[self::PACKAGE_DATA_RECIPIENT] = $currentRecipient;
- // And enqueue it to the writer class
+ // Push the declared package to the next stack.
$this->getStackerInstance()->pushNamed(self::STACKER_NAME_DECLARED, $packageData);
// Debug message
// Debug message
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: Reached line ' . __LINE__ . ' after discoverSocket() has been called.');
- // We have to put this socket in our registry, so get an instance
- $registryInstance = SocketRegistryFactory::createSocketRegistryInstance();
-
- // Get the listener from registry
- $helperInstance = Registry::getRegistry()->getInstance('connection');
-
// Debug message
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: stateInstance=' . $helperInstance->getStateInstance());
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: Reached line ' . __LINE__ . ' before isSocketRegistered() has been called.');
// Is it not there?
if ((is_resource($socketResource)) && (!$registryInstance->isSocketRegistered($helperInstance, $socketResource))) {
+ // The socket needs to be put in a special registry that can handle such data
+ $registryInstance = SocketRegistryFactory::createSocketRegistryInstance();
+
+ // Get the connection helper from registry
+ $helperInstance = Registry::getRegistry()->getInstance('connection');
+
+ // And make sure it is valid
+ assert($helperInstance instanceof ConnectionHelper);
+
// Debug message
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: Registering socket ' . $socketResource . ' ...');
*
* @return void
*/
- public function deliverDeclaredPackage () {
+ public function processDeclaredPackage () {
// Sanity check if we have packages declared
if (!$this->isPackageDeclared()) {
// This is not fatal but should be avoided
*/
public function getNextHexSerialNumber ($finalHash) {
// Assert on maximum serial number length
+ assert(isset($this->serialNumber[$finalHash]));
assert($this->serialNumber[$finalHash] <= $this->maxSerialNumber);
// Encode the current serial number
// Final hash must be set
assert((is_string($finalHash)) && (!empty($finalHash)));
- // Reset serial number
+ // Reset/set serial number
$this->serialNumber[$finalHash] = 0;
}
}
$packageInstance->sendWaitingPackage();
} elseif ($packageInstance->isPackageDeclared()) {
// Prepare package for delivery
- $packageInstance->deliverDeclaredPackage();
+ $packageInstance->processDeclaredPackage();
} elseif ($packageInstance->isPackageEnqueued()) {
// Okay, then deliver (better discover its recipients) this package
$packageInstance->declareEnqueuedPackage();