]> git.mxchange.org Git - hub.git/blobdiff - application/hub/main/package/class_NetworkPackage.php
Introduced package fragmenter class to fragment network packages into smaller chunks
[hub.git] / application / hub / main / package / class_NetworkPackage.php
index dd634f3adfe84492f6467779c14da3ee32713cc9..323dba060d5854601be8f64adf85748f561245a0 100644 (file)
@@ -89,6 +89,11 @@ class NetworkPackage extends BaseFrameworkSystem implements Deliverable, Registe
         */
        const STACKER_NAME_OUTGOING = 'outgoing';
 
+       /**
+        * Stacker name for "back-buffered" packages
+        */
+       const STACKER_NAME_BACK_BUFFER = 'backbuffer';
+
        /**
         * Network target (alias): 'upper hubs'
         */
@@ -256,7 +261,10 @@ class NetworkPackage extends BaseFrameworkSystem implements Deliverable, Registe
                } // 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);
        }
 
        /**
@@ -391,7 +399,10 @@ class NetworkPackage extends BaseFrameworkSystem implements Deliverable, Registe
         *
         * @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
@@ -402,11 +413,12 @@ class NetworkPackage extends BaseFrameworkSystem implements Deliverable, Registe
                // 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