]> git.mxchange.org Git - hub.git/commitdiff
Removed package status from packageData array because recipients doesn't need this...
authorRoland Häder <roland@mxchange.org>
Sat, 11 Feb 2012 23:31:26 +0000 (23:31 +0000)
committerRoland Häder <roland@mxchange.org>
Sat, 11 Feb 2012 23:31:26 +0000 (23:31 +0000)
17 files changed:
.gitattributes
application/hub/config.php
application/hub/exceptions/package/class_FinalChunkVerificationException.php [new file with mode: 0644]
application/hub/exceptions/package/class_UnsupportedPackageCodeHandlerException.php [new file with mode: 0644]
application/hub/interfaces/package/assembler/.htaccess [new file with mode: 0644]
application/hub/interfaces/package/assembler/class_Assembler.php [new file with mode: 0644]
application/hub/main/class_BaseHubSystem.php
application/hub/main/factories/fragmenter/class_FragmenterFactory.php
application/hub/main/factories/package/assembler/.htaccess [new file with mode: 0644]
application/hub/main/factories/package/assembler/class_PackageAssemblerFactory.php [new file with mode: 0644]
application/hub/main/factories/package/fragmenter/.htaccess [new file with mode: 0644]
application/hub/main/factories/package/fragmenter/class_FragmenterFactory.php [new file with mode: 0644]
application/hub/main/listener/class_BaseListener.php
application/hub/main/package/assembler/.htaccess [new file with mode: 0644]
application/hub/main/package/assembler/class_PackageAssembler.php [new file with mode: 0644]
application/hub/main/package/class_NetworkPackage.php
application/hub/main/package/fragmenter/class_PackageFragmenter.php

index 906de45107f3383d355fa2ab810a7afd2818b44b..b6aa3f2cc8da06db4bf30e166049f44b4e6fce72 100644 (file)
@@ -17,7 +17,9 @@ application/hub/exceptions/lists/class_InvalidListHashException.php svneol=nativ
 application/hub/exceptions/lists/class_ListGroupAlreadyAddedException.php svneol=native#text/plain
 application/hub/exceptions/lists/class_NoListGroupException.php svneol=native#text/plain
 application/hub/exceptions/package/.htaccess -text svneol=unset#text/plain
+application/hub/exceptions/package/class_FinalChunkVerificationException.php svneol=native#text/plain
 application/hub/exceptions/package/class_UnexpectedPackageStatusException.php -text
+application/hub/exceptions/package/class_UnsupportedPackageCodeHandlerException.php svneol=native#text/plain
 application/hub/exceptions/peer/.htaccess -text svneol=unset#text/plain
 application/hub/exceptions/peer/class_PeerAlreadyRegisteredException.php svneol=native#text/plain
 application/hub/exceptions/resolver/.htaccess svneol=native#text/plain
@@ -70,6 +72,8 @@ application/hub/interfaces/messages/class_MessageHelper.php svneol=native#text/p
 application/hub/interfaces/nodes/.htaccess -text svneol=unset#text/plain
 application/hub/interfaces/nodes/class_NodeHelper.php svneol=native#text/plain
 application/hub/interfaces/package/.htaccess -text svneol=unset#text/plain
+application/hub/interfaces/package/assembler/.htaccess -text svneol=unset#text/plain
+application/hub/interfaces/package/assembler/class_Assembler.php svneol=native#text/plain
 application/hub/interfaces/package/class_Deliverable.php svneol=native#text/plain
 application/hub/interfaces/package/fragmenter/.htaccess -text svneol=unset#text/plain
 application/hub/interfaces/pool/.htaccess -text svneol=unset#text/plain
@@ -196,7 +200,10 @@ application/hub/main/factories/fragmenter/.htaccess -text
 application/hub/main/factories/lists/.htaccess -text svneol=unset#text/plain
 application/hub/main/factories/lists/class_RecipientListFactory.php svneol=native#text/plain
 application/hub/main/factories/package/.htaccess -text svneol=unset#text/plain
+application/hub/main/factories/package/assembler/.htaccess -text svneol=unset#text/plain
+application/hub/main/factories/package/assembler/class_PackageAssemblerFactory.php svneol=native#text/plain
 application/hub/main/factories/package/class_NetworkPackageFactory.php svneol=native#text/plain
+application/hub/main/factories/package/fragmenter/.htaccess -text
 application/hub/main/factories/producer/.htaccess -text
 application/hub/main/factories/socket/.htaccess -text svneol=unset#text/plain
 application/hub/main/factories/socket/class_SocketFactory.php svneol=native#text/plain
@@ -396,6 +403,8 @@ application/hub/main/nodes/master/class_HubMasterNode.php svneol=native#text/pla
 application/hub/main/nodes/regular/.htaccess -text svneol=unset#text/plain
 application/hub/main/nodes/regular/class_HubRegularNode.php svneol=native#text/plain
 application/hub/main/package/.htaccess -text svneol=unset#text/plain
+application/hub/main/package/assembler/.htaccess -text svneol=unset#text/plain
+application/hub/main/package/assembler/class_PackageAssembler.php svneol=native#text/plain
 application/hub/main/package/class_NetworkPackage.php svneol=native#text/plain
 application/hub/main/package/fragmenter/.htaccess -text svneol=unset#text/plain
 application/hub/main/pools/.htaccess -text svneol=unset#text/plain
index 2bbb4a6345bb714e0179595ec89796dae8c66a22..7a0d2f0404a9cddc20fe19a6b409688fe50c1acd 100644 (file)
@@ -510,6 +510,9 @@ $cfg->setConfigEntry('external_ip', '');
 // CFG: PACKAGE-FRAGMENTER-CLASS
 $cfg->setConfigEntry('package_fragmenter_class', 'PackageFragmenter');
 
+// CFG: PACKAGE-ASSEMBLER-CLASS
+$cfg->setConfigEntry('package_assembler_class', 'PackageAssembler');
+
 // CFG: PACKAGE-CHUNK-SIZE
 $cfg->setConfigEntry('package_chunk_size', 256*8);
 
diff --git a/application/hub/exceptions/package/class_FinalChunkVerificationException.php b/application/hub/exceptions/package/class_FinalChunkVerificationException.php
new file mode 100644 (file)
index 0000000..e08647d
--- /dev/null
@@ -0,0 +1,50 @@
+<?php
+/**
+ * This exception is thrown when the final (last) chunks does not contain the
+ * "End-Of-Package-Identifier".
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @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
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class FinalChunkVerificationException extends FrameworkException {
+       /**
+        * The super constructor for all exceptions
+        *
+        * @param       $messageArray   Error message array
+        * @param       $code                   Error code
+        * @return      void
+        */
+       public function __construct (array $messageArray, $code) {
+               // Construct the message
+               $message = sprintf("[%s:%d] The final chunk %s is not a valid EOP (%s) chunk. Raw content: %s, total chunks: %s",
+                       $messageArray[0]->__toString(),
+                       $this->getLine(),
+                       $messageArray[2][count($messageArray[2]) - 1],
+                       PackageFragmenter::END_OF_PACKAGE_IDENTIFIER,
+                       $messageArray[1][BaseRawDataHandler::PACKAGE_DECODED_DATA]
+                       count($messageArray[2])
+               );
+
+               // Call parent exception constructor
+               parent::__construct($message, $code);
+       }
+}
+
+// [EOF]
+?>
diff --git a/application/hub/exceptions/package/class_UnsupportedPackageCodeHandlerException.php b/application/hub/exceptions/package/class_UnsupportedPackageCodeHandlerException.php
new file mode 100644 (file)
index 0000000..6e288b4
--- /dev/null
@@ -0,0 +1,47 @@
+<?php
+/**
+ * This exception is thrown when an unexpected package status was detected.
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @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
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class UnsupportedPackageCodeHandlerException extends FrameworkException {
+       /**
+        * The super constructor for all exceptions
+        *
+        * @param       $messageArray   Error message array
+        * @param       $code                   Error code
+        * @return      void
+        */
+       public function __construct (array $messageArray, $code) {
+               // Construct the message
+               $message = sprintf("[%s:%d] Unsupported package code handler %s for package code %s detected.",
+                       $messageArray[0]->__toString(),
+                       $this->getLine(),
+                       $messageArray[2],
+                       $messageArray[1][BaseRawDataHandler::PACKAGE_ERROR_CODE]
+               );
+
+               // Call parent exception constructor
+               parent::__construct($message, $code);
+       }
+}
+
+// [EOF]
+?>
diff --git a/application/hub/interfaces/package/assembler/.htaccess b/application/hub/interfaces/package/assembler/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/interfaces/package/assembler/class_Assembler.php b/application/hub/interfaces/package/assembler/class_Assembler.php
new file mode 100644 (file)
index 0000000..38fc930
--- /dev/null
@@ -0,0 +1,36 @@
+<?php
+/**
+ * An interface for a package assembler
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @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
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+interface Assembler extends FrameworkInterface {
+       /**
+        * Assembles the content from $packageContent into a raw package data array.
+        * This method may throw exceptions if some checks fails.
+        *
+        * @param       $packageContent         An array with two elements: 'decoded_data' and 'error_code'
+        * @return      $packageData            A valid raw package data array
+        */
+       function assemblePackageDataArrayFromContent (array $packageContent);
+}
+
+// [EOF]
+?>
index b0abb8c4ae30f9da24d95b953069e97e1b8366e5..ca002ebda6a727b153d792e9cfd32fed54f771f5 100644 (file)
@@ -214,7 +214,7 @@ class BaseHubSystem extends BaseFrameworkSystem {
         * method is not found, a generic one is used.
         *
         * @param       $errorCode              Error code from socket_last_error()
-        * @return      $methodName             Call-back method name for the error handler
+        * @return      $handlerName    Call-back method name for the error handler
         * @throws      UnsupportedSocketErrorHandlerException If the error handler is not implemented
         */
        protected function getSocketErrorHandlerFromCode ($errorCode) {
index 0436b76f1f7c5fdae36489f670d02b380b296e26..f551ef47b7591c74e7b59193e56a1fa6505a87ab 100644 (file)
@@ -1,62 +1,3 @@
 <?php
-/**
- * A factory class for fragmenter
- *
- * @author             Roland Haeder <webmaster@ship-simu.org>
- * @version            0.0.0
- * @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
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-class FragmenterFactory extends ObjectFactory {
-       /**
-        * Protected constructor
-        *
-        * @return      void
-        */
-       protected function __construct () {
-               // Call parent constructor
-               parent::__construct(__CLASS__);
-       }
-
-       /**
-        * Returns a singleton fragmenter instance. If no instance is found, it fill
-        * be generated and stored in registry, else the fragmenter from the
-        * registry will be returned.
-        *
-        * @param       $fragmenterType                 The fragmenter's type
-        * @return      $fragmenterInstance             A fragmenter instance
-        */
-       public static final function createFragmenterInstance ($fragmenterType) {
-               // If there is no fragmenter?
-               if (Registry::getRegistry()->instanceExists($fragmenterType . '_fragmenter')) {
-                       // Get fragmenter from registry
-                       $fragmenterInstance = Registry::getRegistry()->getInstance($fragmenterType . '_fragmenter');
-               } else {
-                       // Get the fragmenter instance
-                       $fragmenterInstance = self::createObjectByConfiguredName($fragmenterType . '_fragmenter_class');
-
-                       // Add it to the registry
-                       Registry::getRegistry()->addInstance($fragmenterType . '_fragmenter', $fragmenterInstance);
-               }
-
-               // Return the instance
-               return $fragmenterInstance;
-       }
-}
-
-// [EOF]
+// @DEPRECATED
 ?>
diff --git a/application/hub/main/factories/package/assembler/.htaccess b/application/hub/main/factories/package/assembler/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/main/factories/package/assembler/class_PackageAssemblerFactory.php b/application/hub/main/factories/package/assembler/class_PackageAssemblerFactory.php
new file mode 100644 (file)
index 0000000..62fc0e5
--- /dev/null
@@ -0,0 +1,61 @@
+<?php
+/**
+ * A factory class for package assembler
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @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
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class PackageAssemblerFactory extends ObjectFactory {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+       }
+
+       /**
+        * Returns a singleton assembler instance. If no instance is found, it fill
+        * be generated and stored in registry, else the assembler from the
+        * registry will be returned.
+        *
+        * @return      $assemblerInstance      An assembler instance
+        */
+       public static final function createAssemblerInstance () {
+               // If there is no assembler?
+               if (Registry::getRegistry()->instanceExists('package_assembler')) {
+                       // Get assembler from registry
+                       $assemblerInstance = Registry::getRegistry()->getInstance('package_assembler');
+               } else {
+                       // Get the assembler instance
+                       $assemblerInstance = self::createObjectByConfiguredName('package_assembler_class');
+
+                       // Add it to the registry
+                       Registry::getRegistry()->addInstance('package_assembler', $assemblerInstance);
+               }
+
+               // Return the instance
+               return $assemblerInstance;
+       }
+}
+
+// [EOF]
+?>
diff --git a/application/hub/main/factories/package/fragmenter/.htaccess b/application/hub/main/factories/package/fragmenter/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/main/factories/package/fragmenter/class_FragmenterFactory.php b/application/hub/main/factories/package/fragmenter/class_FragmenterFactory.php
new file mode 100644 (file)
index 0000000..0436b76
--- /dev/null
@@ -0,0 +1,62 @@
+<?php
+/**
+ * A factory class for fragmenter
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @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
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class FragmenterFactory extends ObjectFactory {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+       }
+
+       /**
+        * Returns a singleton fragmenter instance. If no instance is found, it fill
+        * be generated and stored in registry, else the fragmenter from the
+        * registry will be returned.
+        *
+        * @param       $fragmenterType                 The fragmenter's type
+        * @return      $fragmenterInstance             A fragmenter instance
+        */
+       public static final function createFragmenterInstance ($fragmenterType) {
+               // If there is no fragmenter?
+               if (Registry::getRegistry()->instanceExists($fragmenterType . '_fragmenter')) {
+                       // Get fragmenter from registry
+                       $fragmenterInstance = Registry::getRegistry()->getInstance($fragmenterType . '_fragmenter');
+               } else {
+                       // Get the fragmenter instance
+                       $fragmenterInstance = self::createObjectByConfiguredName($fragmenterType . '_fragmenter_class');
+
+                       // Add it to the registry
+                       Registry::getRegistry()->addInstance($fragmenterType . '_fragmenter', $fragmenterInstance);
+               }
+
+               // Return the instance
+               return $fragmenterInstance;
+       }
+}
+
+// [EOF]
+?>
index 8e232d4b274ed330183a227acfd0e814f4df09b5..e7de4c07a6794c1247afc2818630cb719e0dde8f 100644 (file)
  */
 class BaseListener extends BaseHubSystem implements Visitable {
        // Exception code constants
-       const EXCEPTION_INVALID_SOCKET                = 0xa00;
-       const EXCEPTION_SOCKET_ALREADY_REGISTERED     = 0xa01;
-       const EXCEPTION_SOCKET_CREATION_FAILED        = 0xa02;
-       const EXCEPTION_NO_SOCKET_ERROR               = 0xa03;
-       const EXCEPTION_CONNECTION_ALREADY_REGISTERED = 0xa04;
-       const EXCEPTION_UNEXPECTED_PACKAGE_STATUS     = 0xa05;
+       const EXCEPTION_INVALID_SOCKET                   = 0xa00;
+       const EXCEPTION_SOCKET_ALREADY_REGISTERED        = 0xa01;
+       const EXCEPTION_SOCKET_CREATION_FAILED           = 0xa02;
+       const EXCEPTION_NO_SOCKET_ERROR                  = 0xa03;
+       const EXCEPTION_CONNECTION_ALREADY_REGISTERED    = 0xa04;
+       const EXCEPTION_UNEXPECTED_PACKAGE_STATUS        = 0xa05;
+       const EXCEPTION_UNSUPPORTED_PACKAGE_CODE_HANDLER = 0xa06;
 
        /**
         * Used protocol (Default: invalid, which is indeed invalid...)
diff --git a/application/hub/main/package/assembler/.htaccess b/application/hub/main/package/assembler/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/main/package/assembler/class_PackageAssembler.php b/application/hub/main/package/assembler/class_PackageAssembler.php
new file mode 100644 (file)
index 0000000..2255fe1
--- /dev/null
@@ -0,0 +1,109 @@
+<?php
+/**
+ * A PackageAssembler class to assemble a package content stream fragemented
+ * by PackageFragmenter back to a raw package data array.
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @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
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+class PackageAssembler extends BaseFrameworkSystem implements Assembler, Registerable {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+       }
+
+       /**
+        * Creates an instance of this class
+        *
+        * @return      $assemblerInstance              An instance of a Fragmentable class
+        */
+       public static final function createPackageAssembler () {
+               // Get new instance
+               $assemblerInstance = new PackageAssembler();
+
+               // Return the prepared instance
+               return $assemblerInstance;
+       }
+
+       /**
+        * Assembles the content from $packageContent. This method does only
+        * initialize the whole process by creating a call-back which will then
+        * itself (99.9% of all cases) "explode" the decoded data stream and add
+        * it to a chunk assembler queue.
+        *
+        * If the call-back method or this would attempt to assemble the package
+        * chunks and (maybe) re-request some chunks from the sender, this would
+        * take to much time and therefore slow down this node again.
+        *
+        * @param       $packageContent         An array with two elements: 'decoded_data' and 'error_code'
+        * @return      void
+        * @throws      UnsupportedPackageCodeHandlerException  If the package code handler is not implemented
+        */
+       public function assemblePackageDataArrayFromContent (array $packageContent) {
+               // Validate the package content array again
+               assert(
+                       (isset($packageContent[BaseRawDataHandler::PACKAGE_DECODED_DATA])) &&
+                       (isset($packageContent[BaseRawDataHandler::PACKAGE_ERROR_CODE]))
+               );
+
+               // Construct call-back name from package error code
+               $methodName = 'handlePackageBy' . $this->convertToClassName($packageContent[BaseRawDataHandler::PACKAGE_ERROR_CODE]);
+
+               // Abort if the call-back method is not there
+               if (!method_exists($this, $methodName)) {
+                       // Throw an exception
+                       throw new UnsupportedPackageCodeHandlerException(array($this, $packageContent, $methodName), BaseListener::EXCEPTION_UNSUPPORTED_PACKAGE_CODE_HANDLER);
+               } // END - if
+
+               // Call it back
+               call_user_func(array($this, $methodName), $packageContent);
+       }
+
+       /**
+        * Call-back handler to handle unhandled packages
+        *
+        * @param       $packageContent         An array with two elements: 'decoded_data' and 'error_code'
+        * @return      void
+        * @throws      FinalChunkVerificationException         If the final chunk does not start with 'EOP:'
+        */
+       private function handlePackageByUnhandledPackage (array $packageContent) {
+               /*
+                * "explode" the string from 'decoded_data' with chunk separator to
+                * get an array of chunks. These chunks must then be verified by
+                * their checksums. Also the final chunk must be handled.
+                */
+               $chunks = explode(PackageFragmenter::CHUNK_SEPARATOR, $packageContent[BaseRawDataHandler::PACKAGE_DECODED_DATA]);
+
+               // Validate final chunk
+               if (substr($chunks[count($chunks) - 1], 0, strlen(PackageFragmenter::END_OF_PACKAGE_IDENTIFIER)) != PackageFragmenter::END_OF_PACKAGE_IDENTIFIER) {
+                       // Last chunk is not valid
+                       throw new FinalChunkVerificationException(array($this, $packageContent, $chunks), BaseListener::EXCEPTION_FINAL_CHUNK_VERIFICATION);
+               } // END - if
+
+               die('chunks='.print_r($chunks,true));
+       }
+}
+
+// [EOF]
+?>
index 9b96b2fb9bd3f0d17d978ef1eccbe16a2bb44450..631d0101b1f7ada020d4b65ad4d5f8b5befb1f36 100644 (file)
@@ -630,7 +630,11 @@ class NetworkPackage extends BaseFrameworkSystem implements Deliverable, Receiva
                $decodedData = $this->getStackerInstance()->popNamed(self::STACKER_NAME_DECODED_INCOMING);
 
                // Make sure both array elements are there
-               assert((is_array($decodedData)) && (isset($decodedData[BaseRawDataHandler::PACKAGE_DECODED_DATA])) && (isset($decodedData[BaseRawDataHandler::PACKAGE_ERROR_CODE])));
+               assert(
+                       (is_array($decodedData)) &&
+                       (isset($decodedData[BaseRawDataHandler::PACKAGE_DECODED_DATA])) &&
+                       (isset($decodedData[BaseRawDataHandler::PACKAGE_ERROR_CODE]))
+               );
 
                /*
                 * Also make sure the error code is SOCKET_ERROR_UNHANDLED because we
@@ -683,15 +687,24 @@ class NetworkPackage extends BaseFrameworkSystem implements Deliverable, Receiva
 
        /**
         * Assembles incoming decoded data so it will become an abstract network
-        * package again.
+        * package again. The assembler does later do it's job by an other task,
+        * not this one to keep best speed possible.
         *
         * @return      void
         */
        public function assembleDecodedDataToPackage () {
                // Make sure the raw decoded package data is handled
                assert($this->isIncomingDecodedDataHandled());
-               $this->getStackerInstance()->debugInstance();
-               $this->partialStub('Please implement this method.');
+
+               // Get current package content (an array with two elements; see handleIncomingDecodedData() for details)
+               $packageContent = $this->getStackerInstance()->getNamed(self::STACKER_NAME_DECODED_HANDLED);
+
+               // Get a package assembler instance from factory
+               $assemblerInstance = PackageAssemblerFactory::createAssemblerInstance();
+
+               // Start assembling the raw package data array
+               $assemblerInstance->assemblePackageDataArrayFromContent($packageContent);
+               die(__METHOD__.': BACK!' . chr(10));
        }
 
        /**
index e8e62aaad812223285fc036d4152ebd8645df9c8..a2f721b4b5f09ca7322fae1d630e70f0ee13141d 100644 (file)
@@ -429,6 +429,9 @@ class PackageFragmenter extends BaseFrameworkSystem implements Fragmentable, Reg
        public function fragmentPackageArray (array $packageData, ConnectionHelper $helperInstance) {
                // Is this package already fragmented?
                if (!$this->isPackageProcessed($packageData)) {
+                       // Remove package status, the recipient doesn't need this
+                       unset($packageData[NetworkPackage::PACKAGE_DATA_STATUS]);
+
                        // First we need to "implode" the array
                        $rawData = implode(NetworkPackage::PACKAGE_DATA_SEPARATOR, $packageData);
 
@@ -466,6 +469,7 @@ class PackageFragmenter extends BaseFrameworkSystem implements Fragmentable, Reg
         *
         * @param       $finalHash              Final hash for faster lookup
         * @return      $rawDataChunk   Raw package data chunk
+        * @throws      AssertionException      If $finalHash was not 'true'
         */
        public function getNextRawDataChunk ($finalHash) {
                try {