*/
const STACKER_NAME_OUTGOING = 'outgoing';
+ /**
+ * Stacker name for "back-buffered" packages
+ */
+ const STACKER_NAME_BACK_BUFFER = 'backbuffer';
+
/**
* Network target (alias): 'upper hubs'
*/
} // END - if
// Sent it away (we catch exceptions one method above
- $connectionInstance->sendRawPackageData($packageData);
+ $sentBytes = $connectionInstance->sendRawPackageData($packageData);
+
+ // Remember unsent raw bytes in back-buffer, if any
+ $this->storeUnsentBytesInBackBuffer($packageData, $sentBytes);
}
/**
*
* @return void
*/
- public function sentWaitingPackage () {
+ public function sendWaitingPackage () {
+ // Sent any waiting bytes in the back-buffer
+ $this->sendBackBufferBytes();
+
// Sanity check if we have packages waiting for delivery
if (!$this->isPackageWaitingDelivery()) {
// This is not fatal but should be avoided
// Get the package again
$packageData = $this->getStackerInstance()->getNamed(self::STACKER_NAME_OUTGOING);
- // Now try to send it
try {
+ // Now try to send it
$this->sendOutgoingPackage($packageData);
+ die("O!\n");
- // And remove it finally when it has been fully delivered
+ // And remove it finally
$this->getStackerInstance()->popNamed(self::STACKER_NAME_OUTGOING);
} catch (InvalidSocketException $e) {
// Output exception message