]> git.mxchange.org Git - hub.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Mon, 26 Oct 2020 10:01:11 +0000 (11:01 +0100)
committerRoland Häder <roland@mxchange.org>
Mon, 26 Oct 2020 10:01:11 +0000 (11:01 +0100)
- renamed *ByPackageData to *ByPackageInstance
- renamed more old-lost remains of $packageData (removed type-unsafe array) with
  modern and type-safe $packageInstance

Signed-off-by: Roland Häder <roland@mxchange.org>
37 files changed:
application/hub/classes/class_BaseHubSystem.php
application/hub/classes/container/class_BaseHubContainer.php
application/hub/classes/container/socket/class_SocketContainer.php
application/hub/classes/database/frontend/class_BaseHubDatabaseWrapper.php
application/hub/classes/database/frontend/node/class_NodeDistributedHashTableDatabaseWrapper.php
application/hub/classes/database/frontend/states/class_PeerStateLookupDatabaseWrapper.php
application/hub/classes/dht/node/class_NodeDhtFacade.php
application/hub/classes/discovery/protocol/class_ProtocolDiscovery.php
application/hub/classes/discovery/recipient/dht/class_DhtRecipientDiscovery.php
application/hub/classes/discovery/recipient/package/class_PackageRecipientDiscovery.php
application/hub/classes/discovery/recipient/socket/class_PackageSocketDiscovery.php
application/hub/classes/factories/chain/class_PackageFilterChainFactory.php
application/hub/classes/factories/handler/class_ProtocolHandlerFactory.php
application/hub/classes/factories/socket/class_SocketFactory.php
application/hub/classes/factories/states/peer/class_PeerStateFactory.php
application/hub/classes/filter/class_BaseHubFilter.php
application/hub/classes/handler/class_BaseHubHandler.php
application/hub/classes/handler/package/class_NetworkPackageHandler.php
application/hub/classes/handler/protocol/ipv4/class_BaseIpV4ProtocolHandler.php
application/hub/classes/handler/raw_data/class_BaseRawDataHandler.php
application/hub/classes/helper/connection/ipv4/tcp/class_TcpConnectionHelper.php
application/hub/classes/listener/class_BaseListener.php
application/hub/classes/listener/class_BaseListenerDecorator.php
application/hub/classes/nodes/class_BaseHubNode.php
application/hub/classes/package/deliverable/class_PackageData.php
application/hub/classes/package/fragmenter/class_PackageFragmenter.php
application/hub/classes/recipient/dht/class_DhtRecipient.php
application/hub/classes/registry/socket/class_SocketRegistry.php
application/hub/classes/tags/package/class_PackageTags.php
application/hub/classes/template/objects/class_XmlObjectRegistryTemplateEngine.php
application/hub/exceptions/package/class_UnexpectedPackageStatusException.php
application/hub/exceptions/unl/class_InvalidUnlException.php
application/hub/interfaces/class_HubInterface.php
application/hub/interfaces/discovery/recipient/dht/class_DiscoverableDhtRecipient.php
application/hub/interfaces/distributable/class_Distributable.php
application/hub/interfaces/handler/protocol/class_HandleableProtocol.php
application/hub/interfaces/lookup/peer_states/class_LookupablePeerState.php

index c20c6f96afbc444a1923d195e09aaffbcd2a6edb..8857121af3abbf899bb973f15f514a80619542f4 100644 (file)
@@ -313,7 +313,7 @@ abstract class BaseHubSystem extends BaseFrameworkSystem implements HubInterface
         * @param       $privateKeyHash         The new private key hash
         * @return      void
         */
-       protected final function setPrivateKeyHash ($privateKeyHash) {
+       protected final function setNodePrivateKeyHash ($privateKeyHash) {
                // Set it config now
                $this->getConfigInstance()->setConfigEntry('private_key_hash', (string) $privateKeyHash);
        }
@@ -323,7 +323,7 @@ abstract class BaseHubSystem extends BaseFrameworkSystem implements HubInterface
         *
         * @return      $privateKeyHash         Current private key hash
         */
-       public final function getPrivateKeyHash () {
+       public final function getNodePrivateKeyHash () {
                // Get it from config
                return $this->getConfigInstance()->getConfigEntry('private_key_hash');
        }
index 284d82d648486a577772cac341fb19055942cc77..53fa4b479b8054549286662ae62ca96988ae77ea 100644 (file)
@@ -213,7 +213,7 @@ abstract class BaseHubContainer extends BaseContainer implements HubInterface {
         * @param       $privateKeyHash         The new private key hash
         * @return      void
         */
-       protected final function setPrivateKeyHash ($privateKeyHash) {
+       protected final function setNodePrivateKeyHash ($privateKeyHash) {
                throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
        }
 
@@ -222,7 +222,7 @@ abstract class BaseHubContainer extends BaseContainer implements HubInterface {
         *
         * @return      $privateKeyHash         Current private key hash
         */
-       public final function getPrivateKeyHash () {
+       public final function getNodePrivateKeyHash () {
                throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
        }
 
index 3e8987eafbfc8e367ee2cdc755d84279e1b0ab46..5ef1b3cb0807a75cb8aaa6fce76072438ad6d43c 100644 (file)
@@ -182,7 +182,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($this->getSocketProtocol()) . '-SOCKET: unl=' . $unl . ',packageInstance=' . print_r($packageInstance, true));
 
                // So, does both match?
-               $matches = (($packageInstance->getRecipient() !== '') && ($packageInstance->getRecipient() === $unl));
+               $matches = (($packageInstance->getRecipientType() !== '') && ($packageInstance->getRecipientType() === $unl));
 
                // Trace message
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: matches=%d - EXIT!', strtoupper($this->getSocketProtocol()), intval($matches)));
@@ -346,10 +346,10 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita
                $packageInstance = $this->getPackageDataInstance();
 
                // Trace message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: packageInstance.recipient=%s - EXIT!', strtoupper($this->getSocketProtocol()), $packageInstance->getRecipient()));
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: packageInstance.recipient=%s - EXIT!', strtoupper($this->getSocketProtocol()), $packageInstance->getRecipientType()));
 
                // Return it
-               return $packageInstance->getRecipient();
+               return $packageInstance->getRecipientType();
        }
 
        /**
index 3aa5e7ce0145cbfecc872387ccfd368edc2a7f6f..f776e8091cb2f50663b515977cdf69fbbf05c0d0 100644 (file)
@@ -212,7 +212,7 @@ abstract class BaseHubDatabaseWrapper extends BaseDatabaseWrapper implements Hub
         * @param       $privateKeyHash         The new private key hash
         * @return      void
         */
-       protected final function setPrivateKeyHash ($privateKeyHash) {
+       protected final function setNodePrivateKeyHash ($privateKeyHash) {
                throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
        }
 
@@ -221,7 +221,7 @@ abstract class BaseHubDatabaseWrapper extends BaseDatabaseWrapper implements Hub
         *
         * @return      $privateKeyHash         Current private key hash
         */
-       public final function getPrivateKeyHash () {
+       public final function getNodePrivateKeyHash () {
                throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
        }
 
index 1248ffa62108673c58e45675294dedcd77889e22..752efd55b32b870b67422b6d62acaf65ddb89b69 100644 (file)
@@ -193,7 +193,7 @@ class NodeDistributedHashTableDatabaseWrapper extends BaseHubDatabaseWrapper imp
                $dataSetInstance->addCriteria(self::DB_COLUMN_EXTERNAL_ADDRESS, $externalUnl);
                $dataSetInstance->addCriteria(self::DB_COLUMN_NODE_ID         , $nodeInstance->getNodeId());
                $dataSetInstance->addCriteria(self::DB_COLUMN_SESSION_ID      , $nodeInstance->getSessionId());
-               $dataSetInstance->addCriteria(self::DB_COLUMN_PRIVATE_KEY_HASH, $nodeInstance->getPrivateKeyHash());
+               $dataSetInstance->addCriteria(self::DB_COLUMN_PRIVATE_KEY_HASH, $nodeInstance->getNodePrivateKeyHash());
                $dataSetInstance->addCriteria(self::DB_COLUMN_ACCEPTED_OBJECTS, implode(BaseHubNode::OBJECT_LIST_SEPARATOR, $objectList));
                $dataSetInstance->addCriteria(self::DB_COLUMN_ACCEPT_BOOTSTRAP, $this->translateBooleanToYesNo($nodeInstance->isAcceptingDhtBootstrap()));
 
@@ -312,10 +312,8 @@ class NodeDistributedHashTableDatabaseWrapper extends BaseHubDatabaseWrapper imp
         * @return      $nodeData       Node data array
         */
        public function findNodeLocalBySessionId ($sessionId) {
-               // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: sessionId=' . $sessionId . ' - CALLED!');
-
                // Get search criteria
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: sessionId=' . $sessionId . ' - CALLED!');
                $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
 
                // Search for session id and limit it to one entry
@@ -325,10 +323,8 @@ class NodeDistributedHashTableDatabaseWrapper extends BaseHubDatabaseWrapper imp
                // Query database and get a result instance back
                $resultInstance = $this->doSelectByCriteria($searchInstance);
 
-               // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: resultInstance->valid()=' . intval($resultInstance->valid()) . ' - EXIT!');
-
                // Return result instance
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: resultInstance->valid()=' . intval($resultInstance->valid()) . ' - EXIT!');
                return $resultInstance;
        }
 
index 32acb0e421dbab70172a8322a035cb03f020c30a..a5c7c918b9ad7a452b1d76605291aa6d5287e550 100644 (file)
@@ -140,7 +140,7 @@ class PeerStateLookupDatabaseWrapper extends BaseHubDatabaseWrapper implements L
         * @return      void
         * @throws      PeerAlreadyRegisteredException  If a peer is already registered
         */
-       public function registerPeerByPackageData (DeliverablePackage $packageInstance, StorableSocket $socketInstance) {
+       public function registerPeerByPackageInstance (DeliverablePackage $packageInstance, StorableSocket $socketInstance) {
                // Make sure only new peers can be registered with package data
                if (!$this->isSenderNewPeer($packageInstance)) {
                        // Throw an exception because this should normally not happen
index 236933dd943410b17ec6534ce46f84fe4d61596b..cb66fa372d48db2fb0a53c961641c76fbe325a4e 100644 (file)
@@ -145,6 +145,7 @@ class NodeDhtFacade extends BaseDht implements DistributableNode, Registerable {
         */
        public function findNodeLocalBySessionId ($sessionId) {
                // Default is empty data array
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('DHT-FACADE: sessionid=%s - CALLED!', $sessionId));
                $nodeData = array();
 
                /*
@@ -166,6 +167,8 @@ class NodeDhtFacade extends BaseDht implements DistributableNode, Registerable {
                } // END - if
 
                // Return node data
+               //* DEBUG-DIE: */ die(sprintf('[%s:%d]: nodeData=%s', __METHOD__, __LINE__, print_r($nodeData, TRUE)));
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('DHT-FACADE: nodeData()=%d - EXIT!', count($nodeData)));
                return $nodeData;
        }
 
@@ -333,12 +336,12 @@ class NodeDhtFacade extends BaseDht implements DistributableNode, Registerable {
        /**
         * Find recipients for given package data
         *
-        * @param       $packageData    An instance of a DeliverablePackage class
+        * @param       $packageInstance        An instance of a DeliverablePackage class
         * @return      $recipients             An indexed array with DHT recipients
         */
-       public function findRecipientsByPackageData (DeliverablePackage $packageInstance) {
+       public function findRecipientsByPackageInstance (DeliverablePackage $packageInstance) {
                // Query get a result instance back from DHT database wrapper.
-               $resultInstance = $this->getWrapperInstance()->getResultFromExcludedSender($packageData);
+               $resultInstance = $this->getWrapperInstance()->getResultFromExcludedSender($packageInstance);
 
                // Make sure the result instance is valid
                assert($resultInstance instanceof SearchableResult);
index 348956f3095c6494abd1f9982afbecb10a56a9c8..33332033671c0e93b080970af38d71334eb75300 100644 (file)
@@ -60,10 +60,10 @@ class ProtocolDiscovery extends BaseNodeDiscovery implements DiscoverableProtoco
        /**
         * Determines the protoctol name
         *
-        * @param       $packageData            Valid package data
+        * @param       $packageInstance        An instance of a DeliverablePackage class
         * @return      $protocolInstance       An instance of a HandleableProtocol class
         */
-       public static final function determineProtocolByPackageData (DeliverablePackage $packageInstance) {
+       public static final function determineProtocolByPackageInstance (DeliverablePackage $packageInstance) {
                // First we need a tags instance
                $tagsInstance = PackageTagsFactory::createPackageTagsInstance();
 
@@ -74,7 +74,7 @@ class ProtocolDiscovery extends BaseNodeDiscovery implements DiscoverableProtoco
                 * and if so we can re-use it. If there is no socket registered, we try
                 * to make a new connection to the given Universal Node Locator.
                 */
-               $protocolInstance = $tagsInstance->chooseProtocolFromPackageInstance($packageData);
+               $protocolInstance = $tagsInstance->chooseProtocolFromPackageInstance($packageInstance);
 
                // Return it
                return $protocolInstance;
@@ -84,17 +84,17 @@ class ProtocolDiscovery extends BaseNodeDiscovery implements DiscoverableProtoco
         * "Discovers" the protocol type from given raw package data. This is done
         * by looking at the 'recipient' field and extract the first part from it.
         *
-        * @param       $packageData    An instance of a DeliverablePackage class
+        * @param       $packageInstance        An instance of a DeliverablePackage class
         * @return      $protocolType   Type of protocol, e.g. 'tcp' for TCP/IPv4 connections
         */
-       public static final function discoverProtocolByPackageData (DeliverablePackage $packageInstance) {
-               //* DEBUG: */ die(__METHOD__ . ':packageData=' . print_r($packageData, TRUE));
+       public static final function discoverProtocolByPackageInstance (DeliverablePackage $packageInstance) {
+               //* DEBUG: */ die(__METHOD__ . ':packageInstance=' . print_r($packageInstance, TRUE));
 
                /*
                 * "Explode" the 'recipient' array element into a new one, giving at
                 * least two entries: protocol://address
                 */
-               $recipient = explode(':', $packageInstance->getRecipient());
+               $recipient = explode(':', $packageInstance->getRecipientType());
 
                // At least 2 entries must be found
                assert(count($recipient) >= 2);
index 54dfe716b1f6ee1b604473cd41e786dff3b9b630..56247a9f07422326ae4679dc87b70d12a3852f4f 100644 (file)
@@ -59,12 +59,12 @@ class DhtRecipientDiscovery extends BaseRecipientDiscovery implements Discoverab
        /**
         * Resolves one or more recipients for a DHT transfer by given package data.
         *
-        * @param       $packageData    An instance of a DeliverablePackage class
+        * @param       $packageInstance        An instance of a DeliverablePackage class
         * @return      $recipients             An indexed array with DHT recipients
         */
-       public function resolveRecipientsByPackageData (DeliverablePackage $packageInstance) {
+       public function resolveRecipientsByPackageInstance (DeliverablePackage $packageInstance) {
                // Use facade to get recipients back
-               $recipients = DhtObjectFactory::createDhtInstance('node')->findRecipientsByPackageData($packageData);
+               $recipients = DhtObjectFactory::createDhtInstance('node')->findRecipientsByPackageInstance($packageInstance);
 
                // Return it
                return $recipients;
index 8213e619380bd69ace678862bc33d4de442891c4..881e99ab56930c8627cd8276c56d6e1bcccebac4 100644 (file)
@@ -66,7 +66,7 @@ class PackageRecipientDiscovery extends BaseRecipientDiscovery implements Discov
        /**
         * Tries to discover all recipients for given package data
         *
-        * @param       $packageData    An instance of a DeliverablePackage class array
+        * @param       $packageInstance        An instance of a DeliverablePackage class array
         * @return      void
         */
        public function discoverRecipients (DeliverablePackage $packageInstance) {
@@ -80,16 +80,16 @@ class PackageRecipientDiscovery extends BaseRecipientDiscovery implements Discov
                         * recipient must be direct recipient then, otherwise a "virtual"
                         * recipient.
                         */
-                       if (NodeLocatorUtils::isValidUniversalNodeLocator($packageInstance->getRecipient())) {
+                       if (NodeLocatorUtils::isValidUniversalNodeLocator($packageInstance->getRecipientType())) {
                                // Get instance (should not break)
                                $recipientInstance = ObjectFactory::createObjectByConfiguredName('direct_recipient_class');
                        } else {
                                // Try to find the right class
-                               $recipientInstance = ObjectFactory::createObjectByConfiguredName(strtolower($packageInstance->getRecipient()) . '_recipient_class');
+                               $recipientInstance = ObjectFactory::createObjectByConfiguredName(sprintf('%s_recipient_class', strtolower($packageInstance->getRecipientType())));
                        }
 
                        // Try to solve it
-                       $recipientInstance->resolveRecipient($packageInstance->getRecipient(), $this->getListInstance(), $packageData);
+                       $recipientInstance->resolveRecipient($packageInstance->getRecipientType(), $this->getListInstance(), $packageInstance);
                } catch (FrameworkException $e) {
                        // Could not find class, what ever failed
                        $this->debugInstance(sprintf('[%s:%d]: Exception: %s,message=%s', __METHOD__, __LINE__, $e->__toString(), $e->getMessage()));
@@ -112,7 +112,7 @@ class PackageRecipientDiscovery extends BaseRecipientDiscovery implements Discov
                $handlerInstance = ProtocolHandlerFactory::createProtocolHandlerFromPackageInstance($packageInstance);
 
                // Is the 'recipient' field same as this peer's IP?
-               if ($handlerInstance->isOwnAddress($packageInstance->getRecipient())) {
+               if ($handlerInstance->isOwnAddress($packageInstance->getRecipientType())) {
                        /*
                         * Is same as own external address + TCP/UDP listen port or
                         * internal address, don't do anything here so other classes found
@@ -121,13 +121,13 @@ class PackageRecipientDiscovery extends BaseRecipientDiscovery implements Discov
                         */
 
                        // Debug output (may flood)
-                       /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('RECIPIENT-DISCOVERY: Recipient ' . $packageInstance->getRecipient() . ' matches own ip (external=' .  HubTools::determineOwnExternalAddress() . ' or internal=' . HubTools::determineOwnInternalAddress() . ')');
+                       /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('RECIPIENT-DISCOVERY: Recipient ' . $packageInstance->getRecipientType() . ' matches own ip (external=' .  HubTools::determineOwnExternalAddress() . ' or internal=' . HubTools::determineOwnInternalAddress() . ')');
                } else {
                        // Debug output (may flood)
-                       /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('RECIPIENT-DISCOVERY: Recipient ' . $packageInstance->getRecipient() . ' is different than own external address (' .  HubTools::determineOwnExternalAddress() . ') nor internal address (' . HubTools::determineOwnInternalAddress() . '), need to forward (not yet implemented)!');
+                       /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('RECIPIENT-DISCOVERY: Recipient ' . $packageInstance->getRecipientType() . ' is different than own external address (' .  HubTools::determineOwnExternalAddress() . ') nor internal address (' . HubTools::determineOwnInternalAddress() . '), need to forward (not yet implemented)!');
 
                        // This package is to be delivered to someone else, so add it
-                       // @TODO Unfinished: $this->getListInstance()->addEntry('unl', $packageInstance->getRecipient());
+                       // @TODO Unfinished: $this->getListInstance()->addEntry('unl', $packageInstance->getRecipientType());
                }
        }
 
index bf2fac5423ee56c9eaa799c5effe141a9a481de3..1384a711128abe420b0a447994c888c295e4bc85 100644 (file)
@@ -78,7 +78,7 @@ class PackageSocketDiscovery extends BaseRecipientDiscovery implements Discovera
         * Tries to dicover the right listener instance
         *
         * @param       $protocolInstance       An instance of a HandleableProtocol class
-        * @param       $packageData            An instance of a DeliverablePackage class
+        * @param       $packageInstance        An instance of a DeliverablePackage class
         * @return      $listenerInstance       An instance of a Listenable instance or null
         */
        public function discoverListenerInstance (HandleableProtocol $protocolInstance, DeliverablePackage $packageInstance) {
@@ -117,10 +117,10 @@ class PackageSocketDiscovery extends BaseRecipientDiscovery implements Discovera
                        assert($listenerInstance instanceof Listenable);
 
                        // Trace message
-                       /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('PACKAGE-SOCKET-DISCOVERY: Calling listenerInstance->ifListenerAcceptsPackageData(%d) ...', count($packageData)));
+                       /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('PACKAGE-SOCKET-DISCOVERY: Calling listenerInstance->ifListenerAcceptsPackageData(%s) ...', $packageInstance->__toString()));
 
                        // Does the listener want that package?
-                       if ($listenerInstance->ifListenerAcceptsPackageData($packageData)) {
+                       if ($listenerInstance->ifListenerAcceptsPackageData($packageInstance)) {
                                // This listener likes our package data, so abort here
                                /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('PACKAGE-SOCKET-DISCOVERY: Listener "%s" is accepting package data.', $listenerInstance->__toString()));
                                break;
@@ -141,7 +141,7 @@ class PackageSocketDiscovery extends BaseRecipientDiscovery implements Discovera
         * Tries to discover the right socket for given package data and returns a
         * matching socket resource for that protocol.
         *
-        * @param       $packageData            An instance of a DeliverablePackage class array
+        * @param       $packageInstance        An instance of a DeliverablePackage class array
         * @param       $connectionType         Type of connection, can be either 'incoming' or 'outgoing', but *NEVER* 'server'!
         * @return      $socketResource         A valid socket resource or FALSE if an error occured
         * @throws      NoListGroupException    If the procol group is not found in peer list
@@ -152,8 +152,8 @@ class PackageSocketDiscovery extends BaseRecipientDiscovery implements Discovera
         */
        public function discoverSocket (DeliverablePackage $packageInstance, $connectionType) {
                // Debug message
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-SOCKET-DISOVERY: packageData()=' . count($packageData) . ',connectionType=' . $connectionType . ' - CALLED!');
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-SOCKET-DISOVERY: packageData=' . print_r($packageData, TRUE));
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('PACKAGE-SOCKET-DISOVERY: packageInstance=%s,connectionType=%s - CALLED!', $packageInstance->__toString(), $connectionType));
+               //* PRINTR-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-SOCKET-DISOVERY: packageInstance=' . print_r($packageInstance, TRUE));
 
                // Make sure all parameters are valid
                if (($connectionType != StorableSocket::CONNECTION_TYPE_INCOMING) && ($connectionType != StorableSocket::CONNECTION_TYPE_OUTGOING)) {
@@ -162,25 +162,25 @@ class PackageSocketDiscovery extends BaseRecipientDiscovery implements Discovera
                } // END - if
 
                // Determine protocol instance
-               $protocolInstance = ProtocolDiscovery::determineProtocolByPackageData($packageData);
+               $protocolInstance = ProtocolDiscovery::determineProtocolByPackageInstance($packageInstance);
 
                // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('protocolInstance=' . $protocolInstance . ',packageData=' . print_r($packageData, TRUE));
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('protocolInstance=' . $protocolInstance . ',packageInstance=' . print_r($packageInstance, TRUE));
 
                // Is it valid?
                assert($protocolInstance instanceof HandleableProtocol);
 
                // Does the UNL validate?
-               if (!$protocolInstance->isValidUniversalNodeLocatorByPackageData($packageData)) {
+               if (!$protocolInstance->isValidUniversalNodeLocatorByPackageInstance($packageInstance)) {
                        // Not valid, throw exception
-                       throw new InvalidUnlException(array($this, $protocolInstance, $packageData), BaseHubSystem::EXCEPTION_INVALID_UNL);
+                       throw new InvalidUnlException(array($this, $protocolInstance, $packageInstance), BaseHubSystem::EXCEPTION_INVALID_UNL);
                } // END - if
 
                // Get the listener instance
-               $listenerInstance = $this->discoverListenerInstance($protocolInstance, $packageData);
+               $listenerInstance = $this->discoverListenerInstance($protocolInstance, $packageInstance);
 
                // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-SOCKET-DISCOVERY: listenerInstance=' . $listenerInstance . ',packageData=' . print_r($packageData, TRUE));
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-SOCKET-DISCOVERY: listenerInstance=' . $listenerInstance . ',packageInstance=' . print_r($packageInstance, TRUE));
 
                // If there is no listener who wants to have that package, we simply drop it here
                if (is_null($listenerInstance)) {
@@ -197,7 +197,7 @@ class PackageSocketDiscovery extends BaseRecipientDiscovery implements Discovera
                 * instance and pass over the whole package data to get the right
                 * socket.
                 */
-               $socketInstance = $listenerInstance->getPoolInstance()->getSocketFromPackageInstance($packageData, $connectionType);
+               $socketInstance = $listenerInstance->getPoolInstance()->getSocketFromPackageInstance($packageInstance, $connectionType);
 
                // Debug message
                /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('PACKAGE-SOCKET-DISCOVERY: socketInstance[]=%s', gettype($socketInstance)));
@@ -207,10 +207,10 @@ class PackageSocketDiscovery extends BaseRecipientDiscovery implements Discovera
                        // Try to create a new socket resource
                        try {
                                // Possibly noisy debug message
-                               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-SOCKET-DISCOVERY: Trying to establish a ' . strtoupper($listenerInstance->getProtocolName()) . ' connection to ' . $packageInstance->getRecipient() . ' ...');
+                               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-SOCKET-DISCOVERY: Trying to establish a ' . strtoupper($listenerInstance->getProtocolName()) . ' connection to ' . $packageInstance->getRecipientType() . ' ...');
 
                                // Get a socket resource from our factory (if succeeded)
-                               $socketInstance = SocketFactory::createSocketFromPackageInstance($packageData, $protocolInstance);
+                               $socketInstance = SocketFactory::createSocketFromPackageInstance($packageInstance, $protocolInstance);
                        } catch (SocketConnectionException $e) {
                                // The connection fails of being established, so log it away
                                self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-SOCKET-DISCOVERY: Caught ' . $e->__toString() . ',message=' . $e->getMessage());
@@ -226,17 +226,17 @@ class PackageSocketDiscovery extends BaseRecipientDiscovery implements Discovera
                        /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-SOCKET-DISCOVERY: Going to resolve socket from peer state and given package data ...');
 
                        // Resolve the peer's state (but ignore return value)
-                       PeerStateResolver::resolveStateByPackage($helperInstance, $packageData, $socketInstance);
+                       PeerStateResolver::resolveStateByPackage($helperInstance, $packageInstance, $socketInstance);
                } catch (InvalidSocketException $e) {
                        // This cannot be fixed, so log it away
-                       self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-SOCKET-DISCOVERY: Cannot discover socket resource for recipient ' . $packageInstance->getRecipient() . ': ' . $e->getMessage());
+                       self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-SOCKET-DISCOVERY: Cannot discover socket resource for recipient ' . $packageInstance->getRecipientType() . ': ' . $e->getMessage());
 
                        // Make any failed attempts to 'FALSE'
                        $socketInstance = NULL;
                }
 
                // And return it
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-SOCKET-DISCOVERY: socketResource=' . $socketInstance->getSocketResource() . ',packageData=' . print_r($packageData, TRUE));
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-SOCKET-DISCOVERY: socketResource=' . $socketInstance->getSocketResource() . ',packageInstance=' . print_r($packageInstance, TRUE));
                return $socketInstance;
        }
 
index 76f5e5d3067914d3743ccbd7186dbcc3b1944d59..72d027f51c2298c51ddd312fa099832da81e9baa 100644 (file)
@@ -65,7 +65,7 @@ class PackageFilterChainFactory extends ObjectFactory {
                                 * simply means the tag is not valid. This however should be
                                 * handled some calls before this method is called.
                                 */
-                               $filterInstance = self::createObjectByConfiguredName('package_tag_' . $tag . '_filter_class');
+                               $filterInstance = self::createObjectByConfiguredName(sprintf('package_tag_%s_filter_class', $tag));
 
                                // Add this filter to the chain
                                $chainInstance->addFilter($filterInstance);
index 01cc5372217e7a72545d0b1d94fbf98e2d63da97..13398f47b9bb031df147703480ce1f21ebccf64b 100644 (file)
@@ -92,7 +92,7 @@ class ProtocolHandlerFactory extends ObjectFactory {
         */
        public static final function createProtocolHandlerFromPackageInstance (DeliverablePackage $packageInstance) {
                // "Discover" the protocol type
-               $protocolType = ProtocolDiscovery::discoverProtocolByPackageData($packageData);
+               $protocolType = ProtocolDiscovery::discoverProtocolByPackageInstance($packageData);
 
                // Call super factory method
                return self::createProtocolHandlerByType($protocolType);
index eb0c684cba4bf21e4c9bc3bb05c05f304e88fc40..3532935b4db68fa77b1d9bb30b4fcdcb92098bd8 100644 (file)
@@ -68,7 +68,7 @@ class SocketFactory extends ObjectFactory {
                $socketInstance = NULL;
 
                // Construct registry key
-               $registryKey = 'socket_' . $protocolInstance->getProtocolName() . '_' . $packageInstance->getRecipient();
+               $registryKey = 'socket_' . $protocolInstance->getProtocolName() . '_' . $packageInstance->getRecipientType();
 
                // Debug message
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-FACTORY: Trying to find a socket with registryKey=' . $registryKey);
index f96bcf451c82ac7b6de629460d9391055fa5847b..0f2f95d379be9ca8ab9aa64d4f41dfbdde9a1ad7 100644 (file)
@@ -102,7 +102,7 @@ class PeerStateFactory extends ObjectFactory {
                        /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PEER-STATE-FACTORY: errorCode=' . $errorCode);
 
                        // Register the new peer with its session id
-                       $tableInstance->registerPeerByPackageData($packageData, $socketInstance);
+                       $tableInstance->registerPeerByPackageInstance($packageData, $socketInstance);
 
                        /*
                         * It is a new peer so create the state instance based on error
index dccea157d931591a34fa587838d1c9e5d047394d..6ba29c1defef6dfac1ff7480b148672171df935c 100644 (file)
@@ -74,7 +74,7 @@ abstract class BaseHubFilter extends BaseFilter {
                assert(isset($messageData[NetworkPackageHandler::PACKAGE_CONTENT_TAGS]));
 
                // Get a template instance from the factory
-               $templateInstance = XmlTemplateEngineFactory::createXmlTemplateEngineInstance('node_' . $messageType . '_template_class');
+               $templateInstance = XmlTemplateEngineFactory::createXmlTemplateEngineInstance(sprintf('node_%s_template_class', $messageType));
 
                // Get message content
                $messageContent = $messageData[NetworkPackageHandler::PACKAGE_CONTENT_MESSAGE];
@@ -90,7 +90,7 @@ abstract class BaseHubFilter extends BaseFilter {
                 * variables, so simply get them. If there is an invalid XML node
                 * inside the message, the above method call will cause exceptions.
                 */
-               foreach ($this->dataXmlNodes as $key => $dummy) {
+               foreach (array_keys($this->dataXmlNodes) as $key) {
                        // Call it
                        $value = $templateInstance->readXmlData($key);
 
index ed4fd024029fbc0f77b77e100e6975d81b31351a..e861c610d5261867187c921bfd899b40b0e53839 100644 (file)
@@ -226,7 +226,7 @@ abstract class BaseHubHandler extends BaseHandler implements Handleable, HubInte
         * @param       $privateKeyHash         The new private key hash
         * @return      void
         */
-       protected final function setPrivateKeyHash ($privateKeyHash) {
+       protected final function setNodePrivateKeyHash ($privateKeyHash) {
                throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
        }
 
@@ -235,7 +235,7 @@ abstract class BaseHubHandler extends BaseHandler implements Handleable, HubInte
         *
         * @return      $privateKeyHash         Current private key hash
         */
-       public final function getPrivateKeyHash () {
+       public final function getNodePrivateKeyHash () {
                throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
        }
 
index 076b9c23f5de4b0b3253783ed84e0e3838c67a3b..3416e41b4de37a73cbb7ba59ad4f9fb5184b5c1a 100644 (file)
@@ -14,6 +14,7 @@ use Org\Shipsimu\Hub\Factory\Handler\Message\MessageTypeHandlerFactory;
 use Org\Shipsimu\Hub\Factory\Information\Connection\ConnectionInfoFactory;
 use Org\Shipsimu\Hub\Factory\Network\PackageDataFactory;
 use Org\Shipsimu\Hub\Factory\Node\NodeObjectFactory;
+use Org\Shipsimu\Hub\Generic\BaseHubSystem;
 use Org\Shipsimu\Hub\Handler\BaseHubHandler;
 use Org\Shipsimu\Hub\Handler\Network\RawData\HandleableRawData;
 use Org\Shipsimu\Hub\Helper\Connection\ConnectionHelper;
@@ -403,7 +404,8 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei
                $dhtInstance = DhtObjectFactory::createDhtInstance('node');
 
                // Ask DHT for session id
-               $senderData = $dhtInstance->findNodeLocalBySessionId($packageInstance->getContentSender());
+               /* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: Finding local node data for packageInstance->senderId=%s ...', $packageInstance->getSenderId()));
+               $senderData = $dhtInstance->findNodeLocalBySessionId($packageInstance->getSenderId());
 
                // Debugging:
                //* DEBUG-DIE: */ die(sprintf('[%s:%d]: senderData=%s', __METHOD__, __LINE__, print_r($senderData, TRUE)));
@@ -411,13 +413,13 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei
                // Is an entry found?
                if (count($senderData) > 0) {
                        // Make sure the element 'private_key_hash' is there
-                       //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: senderData=' . print_r($senderData, TRUE));
+                       //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: senderData=' . print_r($senderData, TRUE));
                        assert(isset($senderData[NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_PRIVATE_KEY_HASH]));
 
                        // Don't accept empty hashes
                        if (empty($senderData[NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_PRIVATE_KEY_HASH])) {
                                // Don't accept
-                               throw new InvalidPrivateKeyHashException(array($this, $senderData, 'empty hash in senderData'), self::EXCEPTION_INVALID_PRIVATE_KEY_HASH);
+                               throw new InvalidPrivateKeyHashException(array($this, $senderData, 'empty hash in senderData'), BaseHubSystem::EXCEPTION_INVALID_PRIVATE_KEY_HASH);
                        } // END - if
 
                        // Return it
@@ -425,13 +427,13 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei
                } // END - if
 
                // Don't accept empty keys
-               if (empty($packageInstance->getContentPrivateKeyHash())) {
+               if (empty($packageInstance->getSenderPrivateKeyHash())) {
                        // This needs fixing
-                       throw new InvalidPrivateKeyHashException(array($this, $senderData, 'empty hash in decodedData'), self::EXCEPTION_INVALID_PRIVATE_KEY_HASH);
+                       throw new InvalidPrivateKeyHashException(array($this, $senderData, 'empty hash in decodedData'), BaseHubSystem::EXCEPTION_INVALID_PRIVATE_KEY_HASH);
                } // END - if
 
                // There is no DHT entry so, accept the hash from decoded data
-               return $packageInstance->getContentPrivateKeyHash();
+               return $packageInstance->getSenderPrivateKeyHash();
        }
 
        /**
@@ -442,7 +444,7 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei
         */
        private function getHashFromContent ($content) {
                // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: content[md5]=' . md5($content) . ',sender=' . $this->getNodeInstance()->getSessionId() . ',compressor=' . $this->getCompressorInstance()->getCompressorExtension());
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: content[md5]=' . md5($content) . ',sender=' . $this->getNodeInstance()->getSessionId() . ',compressor=' . $this->getCompressorInstance()->getCompressorExtension());
 
                // Create the hash
                // @TODO md5() is very weak, but it needs to be fast
@@ -455,7 +457,7 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei
                );
 
                // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: content[md5]=' . md5($content) . ',sender=' . $this->getNodeInstance()->getSessionId() . ',hash=' . $hash . ',compressor=' . $this->getCompressorInstance()->getCompressorExtension());
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: content[md5]=' . md5($content) . ',sender=' . $this->getNodeInstance()->getSessionId() . ',hash=' . $hash . ',compressor=' . $this->getCompressorInstance()->getCompressorExtension());
 
                // And return it
                return $hash;
@@ -516,7 +518,7 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei
         */
        public function getHashFromContentSessionId (array $decodedContent, $sessionId) {
                // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: content[md5]=' . md5($decodedContent[self::PACKAGE_CONTENT_MESSAGE]) . ',sender=' . $sessionId . ',compressor=' . $decodedContent[self::PACKAGE_CONTENT_EXTENSION]);
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: content[md5]=' . md5($decodedContent[self::PACKAGE_CONTENT_MESSAGE]) . ',sender=' . $sessionId . ',compressor=' . $decodedContent[self::PACKAGE_CONTENT_EXTENSION]);
 
                // Create the hash
                // @TODO md5() is very weak, but it needs to be fast
@@ -539,7 +541,7 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei
        /**
         * Declares the given An instance of a DeliverablePackage class by discovering recipients
         *
-        * @param       $packageData    An instance of a DeliverablePackage class in an array
+        * @param       $packageInstance        An instance of a DeliverablePackage class in an array
         * @return      void
         */
        private function declareRawPackageData (DeliverablePackage $packageInstance) {
@@ -552,7 +554,7 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei
                $discoveryInstance = PackageDiscoveryFactory::createPackageDiscoveryInstance();
 
                // Discover all recipients, this may throw an exception
-               $discoveryInstance->discoverRecipients($packageData);
+               $discoveryInstance->discoverRecipients($packageInstance);
 
                // Now get an iterator
                $iteratorInstance = $discoveryInstance->getIterator();
@@ -569,16 +571,16 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei
                        $currentRecipient = $iteratorInstance->current();
 
                        // Debug message
-                       //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: Setting recipient to ' . $currentRecipient . ',previous=' . packageInstance->getRecipient());
+                       //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: Setting recipient to ' . $currentRecipient . ',previous=' . $packageInstance->getRecipientType());
 
                        // Set the recipient
                        $packageInstance->setRecipient($currentRecipient);
 
                        // Push the declared package to the next stack.
-                       $this->getStackInstance()->pushNamed(self::STACKER_NAME_DECLARED, $packageData);
+                       $this->getStackInstance()->pushNamed(self::STACKER_NAME_DECLARED, $packageInstance);
 
                        // Debug message
-                       //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: Package declared for recipient ' . $currentRecipient);
+                       //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: Package declared for recipient ' . $currentRecipient);
 
                        // Skip to next entry
                        $iteratorInstance->next();
@@ -598,12 +600,12 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei
         * the package), register the socket with the connection (handler/helper?)
         * instance and finally push the raw data on our outgoing queue.
         *
-        * @param       $packageData    An instance of a DeliverablePackage class in an array
+        * @param       $packageInstance        An instance of a DeliverablePackage class in an array
         * @return      void
         */
        private function deliverRawPackageData (DeliverablePackage $packageInstance) {
                // Trace message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE: packageData()=%d - CALLED!', count($packageData)));
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: packageInstance=%s - CALLED!', $packageInstance->__toString()));
 
                /*
                 * This package may become big, depending on the shared object size or
@@ -620,16 +622,16 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei
                $discoveryInstance = SocketDiscoveryFactory::createSocketDiscoveryInstance();
 
                // Now discover the right socket instance from given package data
-               $socketInstance = $discoveryInstance->discoverSocket($packageData, StorableSocket::CONNECTION_TYPE_OUTGOING);
+               $socketInstance = $discoveryInstance->discoverSocket($packageInstance, StorableSocket::CONNECTION_TYPE_OUTGOING);
 
                // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: Reached line ' . __LINE__ . ' after discoverSocket() has been called.');
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: Reached line ' . __LINE__ . ' after discoverSocket() has been called.');
 
                // Get the connection helper from registry
                $helperInstance = GenericRegistry::getRegistry()->getInstance('connection');
 
                // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: stateInstance=' . $helperInstance->getStateInstance());
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: stateInstance=' . $helperInstance->getStateInstance());
 
                // And make sure it is valid
                assert($helperInstance instanceof ConnectionHelper);
@@ -641,54 +643,54 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei
                $infoInstance->fillWithConnectionHelperInformation($helperInstance);
 
                // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: Reached line ' . __LINE__ . ' before isSocketRegistered() has been called.');
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: Reached line ' . __LINE__ . ' before isSocketRegistered() has been called.');
 
                // Is it not there?
                if (($socketInstance->isValidSocket()) && (!$this->getRegistryInstance()->isSocketRegistered($infoInstance, $socketInstance))) {
                        // Debug message
-                       //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: Registering socket ' . $socketInstance . ' ...');
+                       //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: Registering socket ' . $socketInstance . ' ...');
 
                        // Then register it
                        $this->getRegistryInstance()->registerSocketInstance($infoInstance, $socketInstance);
                } elseif (!$helperInstance->getStateInstance()->isPeerStateConnected()) {
                        // Is not connected, then we cannot send
-                       self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: Unexpected peer state ' . $helperInstance->getStateInstance()->__toString() . ' detected.');
+                       self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: Unexpected peer state ' . $helperInstance->getStateInstance()->__toString() . ' detected.');
 
                        // Shutdown the socket
                        $socketInstance->shutdownSocket();
                }
 
                // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: Reached line ' . __LINE__ . ' after isSocketRegistered() has been called.');
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: Reached line ' . __LINE__ . ' after isSocketRegistered() has been called.');
 
                // Make sure the connection is up
                $helperInstance->getStateInstance()->validatePeerStateConnected();
 
                // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: Reached line ' . __LINE__ . ' after validatePeerStateConnected() has been called.');
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: Reached line ' . __LINE__ . ' after validatePeerStateConnected() has been called.');
 
                // Enqueue it again on the out-going queue, the connection is up and working at this point
-               $this->getStackInstance()->pushNamed(self::STACKER_NAME_OUTGOING, $packageData);
+               $this->getStackInstance()->pushNamed(self::STACKER_NAME_OUTGOING, $packageInstance);
 
                // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: Reached line ' . __LINE__ . ' after pushNamed() has been called.');
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: Reached line ' . __LINE__ . ' after pushNamed() has been called.');
        }
 
        /**
         * Sends waiting packages
         *
-        * @param       $packageData    An instance of a DeliverablePackage class
+        * @param       $packageInstance        An instance of a DeliverablePackage class
         * @return      void
         */
        private function sendOutgoingRawPackageData (DeliverablePackage $packageInstance) {
                // Trace message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE: packageData()=%d - CALLED!', count($packageData)));
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: packageInstance=%s - CALLED!', $packageInstance->__toString()));
 
                // Init sent bytes
                $sentBytes = 0;
 
                // Get the right connection instance
-               $infoInstance = $this->getRegistryInstance()->getInfoInstanceFromPackageInstance($packageData);
+               $infoInstance = $this->getRegistryInstance()->getInfoInstanceFromPackageInstance($packageInstance);
 
                // Test helper instance
                assert($infoInstance instanceof ShareableInfo);
@@ -709,10 +711,10 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei
                } // END - if
 
                // Sent out package data
-               $helperInstance->sendRawPackageData($packageData);
+               $helperInstance->sendRawPackageData($packageInstance);
 
                // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: EXIT!');
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: EXIT!');
        }
 
        /**
@@ -724,7 +726,7 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei
         */
        private function generatePackageHash ($content, $senderId) {
                // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: content()=' . strlen($content) . ',senderId=' . $senderId . ' - CALLED!');
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: content()=' . strlen($content) . ',senderId=' . $senderId . ' - CALLED!');
 
                // Assert on variables
                assert(!empty($content));
@@ -733,33 +735,30 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei
                // Is the feature enabled?
                if (!FrameworkFeature::isFeatureAvailable('hubcoin_reward')) {
                        // Feature is not enabled
-                       //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: Feature "hubcoin_reward" not available, not generating package hash. Returning NULL ...');
+                       //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: Feature "hubcoin_reward" not available, not generating package hash. Returning NULL ...');
                        return NULL;
                } // END - if
 
                // Fake package instance
-               $packageInstance = new NetworkPackageHandler();
+               $packageInstance = PackageDataFactory::createPackageDataInstance();
 
                // Set all fields
-               //$packageInstance->set
-               $data = array(
-                       self::PACKAGE_CONTENT_SENDER           => $senderId,
-                       self::PACKAGE_CONTENT_MESSAGE          => $content,
-                       self::PACKAGE_CONTENT_PRIVATE_KEY_HASH => $this->getNodeInstance()->getPrivateKeyHash(),
-               );
+               $packageInstance->setSenderId($senderId);
+               $packageInstance->setPackageContent($content);
+               $packageInstance->setSenderPrivateKeyHash($this->getNodeInstance()->getNodePrivateKeyHash());
 
                // Hash content and sender id together, use scrypt
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: senderId=' . $senderId . ',content()=' . strlen($content));
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: senderId=' . $senderId . ',content()=' . strlen($content));
                $hash = FrameworkFeature::callFeature('hubcoin_reward', 'generateHash', array(
                        sprintf('%s:%s:%s',
                                $senderId,
                                $content,
-                               $this->determineSenderPrivateKeyHash($data)
+                               $this->determineSenderPrivateKeyHash($packageInstance)
                        )
                ));
 
                // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: hash=' . $hash . ' - EXIT!');
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: hash=' . $hash . ' - EXIT!');
 
                // Return it
                return $hash;
@@ -775,7 +774,7 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei
         */
        private function isPackageHashValid (array $decodedArray) {
                // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: decodedArray=' . print_r($decodedArray, TRUE) . ' - CALLED!');
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: decodedArray=' . print_r($decodedArray, TRUE) . ' - CALLED!');
 
                // Make sure the required array elements are there
                assert(isset($decodedArray[self::PACKAGE_CONTENT_SENDER]));
@@ -786,17 +785,17 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei
                // Is the feature enabled?
                if (!FrameworkFeature::isFeatureAvailable('hubcoin_reward')) {
                        // Feature is not enabled, so hashes are always valid
-                       //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: Feature "hubcoin_reward" not available, not checking hash. Returning TRUE ...');
+                       //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: Feature "hubcoin_reward" not available, not checking hash. Returning TRUE ...');
                        return TRUE;
                } // END - if
 
                // Check validity
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: senderId=' . $decodedArray[self::PACKAGE_CONTENT_SENDER] . ',message()=' . strlen($decodedArray[self::PACKAGE_CONTENT_MESSAGE]) . ',hash=' . $decodedArray[self::PACKAGE_CONTENT_HASH]);
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: senderId=' . $decodedArray[self::PACKAGE_CONTENT_SENDER] . ',message()=' . strlen($decodedArray[self::PACKAGE_CONTENT_MESSAGE]) . ',hash=' . $decodedArray[self::PACKAGE_CONTENT_HASH]);
                //* DEBUG-DIE: */ die(__METHOD__ . ': decodedArray=' . print_r($decodedArray, TRUE));
                $isHashValid = FrameworkFeature::callFeature('hubcoin_reward', 'checkHash', array($decodedArray[self::PACKAGE_CONTENT_SENDER] . ':' . $decodedArray[self::PACKAGE_CONTENT_MESSAGE] . ':' . $this->determineSenderPrivateKeyHash($decodedArray), $decodedArray[self::PACKAGE_CONTENT_HASH]));
 
                // Return it
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: isHashValid=' . intval($isHashValid) . ' - EXIT!');
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: isHashValid=' . intval($isHashValid) . ' - EXIT!');
                return $isHashValid;
        }
 
@@ -810,7 +809,7 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei
         */
        public function enqueueRawDataFromTemplate (HubHelper $helperInstance) {
                // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: CALLED!');
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: CALLED!');
 
                // Get the raw content ...
                $content = $helperInstance->getTemplateInstance()->getRawTemplateData();
@@ -838,7 +837,7 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei
                );
 
                // Make sure required data is there
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: Enqueueing package for recipientType=' . $helperInstance->getRecipientType() . ' ...');
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: Enqueueing package for recipientType=' . $helperInstance->getRecipientType() . ' ...');
                assert(!empty($content));
                assert($this->getNodeInstance()->getSessionId() != '');
 
@@ -852,14 +851,14 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei
                $packageInstance->setPackageContent($packageContent);
                $packageInstance->setStatus(self::PACKAGE_STATUS_NEW);
                $packageInstance->setContentHash($this->generatePackageHash($content, $this->getNodeInstance()->getSessionId()));
-               $packageInstance->setPrivateKeyHash($this->getNodeInstance()->getPrivateKeyHash());
+               $packageInstance->setSenderPrivateKeyHash($this->getNodeInstance()->getNodePrivateKeyHash());
 
                // Now prepare the temporary array and push it on the 'undeclared' stack
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE: Pushing packageInstance=%s to stack %s ...', $packageInstance->__toString(), self::STACKER_NAME_UNDECLARED));
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: Pushing packageInstance=%s to stack %s ...', $packageInstance->__toString(), self::STACKER_NAME_UNDECLARED));
                $this->getStackInstance()->pushNamed(self::STACKER_NAME_UNDECLARED, $packageInstance);
 
                // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: EXIT!');
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: EXIT!');
        }
 
        /**
@@ -869,7 +868,7 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei
         */
        public function isPackageEnqueued () {
                // Check whether the stacker is not empty
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: CALLED!');
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: CALLED!');
                $isEnqueued = (
                        ($this->getStackInstance()->isStackInitialized(self::STACKER_NAME_UNDECLARED)) &&
                        (!$this->getStackInstance()->isStackEmpty(self::STACKER_NAME_UNDECLARED))
@@ -877,7 +876,7 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei
 
 
                // Return the result
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE: isEnqueued=%d - EXIT!', intval($isEnqueued)));
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: isEnqueued=%d - EXIT!', intval($isEnqueued)));
                return $isEnqueued;
        }
 
@@ -888,14 +887,14 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei
         */
        public function isPackageDeclared () {
                // Check whether the stacker is not empty
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: CALLED!');
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: CALLED!');
                $isDeclared = (
                        ($this->getStackInstance()->isStackInitialized(self::STACKER_NAME_DECLARED)) &&
                        (!$this->getStackInstance()->isStackEmpty(self::STACKER_NAME_DECLARED))
                );
 
                // Return the result
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE: isDeclared=%d - EXIT!', intval($isDeclared)));
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: isDeclared=%d - EXIT!', intval($isDeclared)));
                return $isDeclared;
        }
 
@@ -906,11 +905,11 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei
         */
        public function isPackageWaitingForDelivery () {
                // Check whether the stacker is not empty
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: CALLED!');
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: CALLED!');
                $isWaitingDelivery = (($this->getStackInstance()->isStackInitialized(self::STACKER_NAME_OUTGOING)) && (!$this->getStackInstance()->isStackEmpty(self::STACKER_NAME_OUTGOING)));
 
                // Return the result
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE: isWaitingDelivery=%d - EXIT!', intval($isWaitingDelivery)));
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: isWaitingDelivery=%d - EXIT!', intval($isWaitingDelivery)));
                return $isWaitingDelivery;
        }
 
@@ -921,11 +920,11 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei
         */
        public function isEncodedDataPending () {
                // Check whether the stacker is not empty
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: CALLED!');
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: CALLED!');
                $isPending = (($this->getStackInstance()->isStackInitialized(self::STACKER_NAME_OUTGOING_STREAM)) && (!$this->getStackInstance()->isStackEmpty(self::STACKER_NAME_OUTGOING_STREAM)));
 
                // Return the result
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE: isPending=%d - EXIT!', intval($isPending)));
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: isPending=%d - EXIT!', intval($isPending)));
                return $isPending;
        }
 
@@ -941,12 +940,12 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei
         */
        public function declareEnqueuedPackage () {
                // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: CALLED!');
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: CALLED!');
 
                // Make sure this method isn't working if there is no package enqueued
                if (!$this->isPackageEnqueued()) {
                        // This is not fatal but should be avoided
-                       self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: No raw package data waiting declaration, but ' . __METHOD__ . ' has been called!');
+                       self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: No raw package data waiting declaration, but ' . __METHOD__ . ' has been called!');
                        return;
                } // END - if
 
@@ -954,13 +953,13 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei
                 * Now there are for sure packages to deliver, so start with the first
                 * one.
                 */
-               $packageData = $this->getStackInstance()->popNamed(self::STACKER_NAME_UNDECLARED);
+               $packageInstance = $this->getStackInstance()->popNamed(self::STACKER_NAME_UNDECLARED);
 
                // Declare the raw package data for delivery
-               $this->declareRawPackageData($packageData);
+               $this->declareRawPackageData($packageInstance);
 
                // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: EXIT!');
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: EXIT!');
        }
 
        /**
@@ -972,12 +971,12 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei
         */
        public function processDeclaredPackage () {
                // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: CALLED!');
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: CALLED!');
 
                // Sanity check if we have packages declared
                if (!$this->isPackageDeclared()) {
                        // This is not fatal but should be avoided
-                       self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: No package has been declared, but ' . __METHOD__ . ' has been called!');
+                       self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: No package has been declared, but ' . __METHOD__ . ' has been called!');
                        return;
                } // END - if
 
@@ -993,14 +992,14 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei
                        $this->getStackInstance()->popNamed(self::STACKER_NAME_DECLARED);
                } catch (UnexpectedStateException $e) {
                        // The state is not excepected (shall be 'connected')
-                       self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: Caught ' . $e->__toString() . ',message=' . $e->getMessage());
+                       self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: Caught ' . $e->__toString() . ',message=' . $e->getMessage());
 
                        // Mark the package with status failed
                        $this->changePackageStatus($packageInstance, self::STACKER_NAME_DECLARED, self::PACKAGE_STATUS_FAILED);
                }
 
                // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: EXIT!');
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: EXIT!');
        }
 
        /**
@@ -1010,12 +1009,12 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei
         */
        public function sendWaitingPackage () {
                // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: CALLED!');
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: CALLED!');
 
                // Sanity check if we have packages waiting for delivery
                if (!$this->isPackageWaitingForDelivery()) {
                        // This is not fatal but should be avoided
-                       self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: No package is waiting for delivery, but ' . __METHOD__ . ' was called.');
+                       self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: No package is waiting for delivery, but ' . __METHOD__ . ' was called.');
                        return;
                } // END - if
 
@@ -1030,14 +1029,14 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei
                        $this->getStackInstance()->popNamed(self::STACKER_NAME_OUTGOING);
                } catch (InvalidSocketException $e) {
                        // Output exception message
-                       self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: Package was not delivered: ' . $e->getMessage());
+                       self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: Package was not delivered: ' . $e->getMessage());
 
                        // Mark package as failed
                        $this->changePackageStatus($packageInstance, self::STACKER_NAME_OUTGOING, self::PACKAGE_STATUS_FAILED);
                }
 
                // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: EXIT!');
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: EXIT!');
        }
 
        /**
@@ -1047,7 +1046,7 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei
         */
        public function sendEncodedData () {
                // Debug message
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: CALLED!');
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: CALLED!');
 
                // Make sure there is pending encoded data
                assert($this->isEncodedDataPending());
@@ -1068,7 +1067,7 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei
                $encodedDataArray[self::RAW_INDEX_SOCKET_INSTANCE] = NULL;
 
                // Trace message
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE: Calling socketInstance->writeBufferToSocketByArray(%d,%d) ...', count($encodedDataArray), $sentBytes));
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: Calling socketInstance->writeBufferToSocketByArray(%d,%d) ...', count($encodedDataArray), $sentBytes));
 
                // And deliver it
                if (!$socketInstance->writeBufferToSocketByArray($encodedDataArray, $sentBytes)) {
@@ -1077,7 +1076,7 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei
                } // END - if
 
                // Debug message
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE: sentBytes[%s]=%d', gettype($sentBytes), $sentBytes));
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: sentBytes[%s]=%d', gettype($sentBytes), $sentBytes));
 
                // If there was an error, don't continue here
                if (($sentBytes === 0) && (strlen($encodedDataArray[self::RAW_INDEX_ENCODED_DATA]) > 0)) {
@@ -1100,7 +1099,7 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei
                $this->getStackInstance()->pushNamed(self::STACKER_NAME_OUTGOING_STREAM, $encodedDataArray);
 
                // Debug message
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: EXIT!');
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: EXIT!');
        }
 
        ///////////////////////////////////////////////////////////////////////////
@@ -1114,13 +1113,13 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei
         */
        private function isRawDataPending () {
                // Trace message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: CALLED!');
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: CALLED!');
 
                // Just return whether the stack is not empty
                $isPending = (!$this->getStackInstance()->isStackEmpty(self::STACKER_NAME_DECODED_INCOMING));
 
                // Trace message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE: isPending=%d - EXIT!', intval($isPending)));
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: isPending=%d - EXIT!', intval($isPending)));
 
                // Return the status
                return $isPending;
@@ -1133,7 +1132,7 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei
         */
        public function isNewRawDataPending () {
                // Trace message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE: Calling this->getListenerPoolInstance()->accept(%s) ... - CALLED!', $this->getVisitorInstance()));
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: Calling this->getListenerPoolInstance()->accept(%s) ... - CALLED!', $this->getVisitorInstance()));
 
                // Visit the pool. This monitors the pool for incoming raw data.
                $this->getListenerPoolInstance()->accept($this->getVisitorInstance());
@@ -1142,7 +1141,7 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei
                $hasArrived = $this->isRawDataPending();
 
                // Trace message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE: hasArrived=%d - EXIT!', intval($hasArrived)));
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: hasArrived=%d - EXIT!', intval($hasArrived)));
 
                // Return the status
                return $hasArrived;
@@ -1162,12 +1161,12 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei
                 */
                if (!$this->isRawDataPending()) {
                        // This is not fatal but should be avoided
-                       self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: No raw (decoded?) data is pending, but ' . __METHOD__ . ' has been called!');
+                       self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: No raw (decoded?) data is pending, but ' . __METHOD__ . ' has been called!');
                        return;
                } // END - if
 
                // Very noisy debug message:
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: Stacker size is ' . $this->getStackInstance()->getStackCount(self::STACKER_NAME_DECODED_INCOMING) . ' entries.');
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: Stacker size is ' . $this->getStackInstance()->getStackCount(self::STACKER_NAME_DECODED_INCOMING) . ' entries.');
 
                // "Pop" the next entry (the same array again) from the stack
                $packageInstance = $this->getStackInstance()->popNamed(self::STACKER_NAME_DECODED_INCOMING);
@@ -1177,14 +1176,14 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei
                 * only want to handle unhandled packages here.
                 */
                // Remove the last chunk SEPARATOR (because there is no need for it)
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: errorCode=' . $packageInstance->getErrorCode() . '(' . StorableSocket::SOCKET_ERROR_UNHANDLED . ')');
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: errorCode=' . $packageInstance->getErrorCode() . '(' . StorableSocket::SOCKET_ERROR_UNHANDLED . ')');
                if (substr($packageInstance->getRawData(), -1, 1) == PackageFragmenter::CHUNK_SEPARATOR) {
                        // It is there and should be removed
                        $packageInstance->setRawData(substr($packageInstance->getRawData(), 0, -1));
                } // END - if
 
                // This package is "handled" and can be pushed on the next stack
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: Pushing ' . strlen($packageInstance->getRawData()) . ' bytes to stack ' . self::STACKER_NAME_DECODED_HANDLED . ' ...');
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: Pushing ' . strlen($packageInstance->getRawData()) . ' bytes to stack ' . self::STACKER_NAME_DECODED_HANDLED . ' ...');
                $this->getStackInstance()->pushNamed(self::STACKER_NAME_DECODED_HANDLED, $packageInstance);
        }
 
@@ -1202,7 +1201,7 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei
                $packageInstance = $handlerInstance->getNextRawData();
 
                // Very noisy debug message:
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: decodedData[' . gettype($packageInstance) . ']=' . print_r($packageInstance, TRUE));
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: decodedData[' . gettype($packageInstance) . ']=' . print_r($packageInstance, TRUE));
 
                // And push it on our stack
                $this->getStackInstance()->pushNamed(self::STACKER_NAME_DECODED_INCOMING, $packageInstance);
@@ -1255,7 +1254,7 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei
         */
        public function handleAssemblerPendingData () {
                // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: Calling this->getAssemblerInstance()->handlePendingData() ...');
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: Calling this->getAssemblerInstance()->handlePendingData() ...');
 
                // Handle it
                $this->getAssemblerInstance()->handlePendingData();
@@ -1268,7 +1267,7 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei
         */
        public function handleMultipleMessages () {
                // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: Calling this->getAssemblerInstance()->handleMultipleMessages() ...');
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: Calling this->getAssemblerInstance()->handleMultipleMessages() ...');
 
                // Handle it
                $this->getAssemblerInstance()->handleMultipleMessages();
@@ -1302,7 +1301,7 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei
                $this->getStackInstance()->popNamed(self::STACKER_NAME_DECODED_HANDLED);
 
                // ... and push it on the 'chunked' stacker
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: Pushing ' . strlen($packageContent[HandleableRawData::PACKAGE_RAW_DATA]) . ' bytes on stack ' . self::STACKER_NAME_DECODED_CHUNKED . ',packageContent=' . print_r($packageContent, TRUE));
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: Pushing ' . strlen($packageContent[HandleableRawData::PACKAGE_RAW_DATA]) . ' bytes on stack ' . self::STACKER_NAME_DECODED_CHUNKED . ',packageContent=' . print_r($packageContent, TRUE));
                $this->getStackInstance()->pushNamed(self::STACKER_NAME_DECODED_CHUNKED, $packageContent);
        }
 
@@ -1314,7 +1313,7 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei
         */
        public function accept (Visitor $visitorInstance) {
                // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: ' . $visitorInstance->__toString() . ' has visited - CALLED!');
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: ' . $visitorInstance->__toString() . ' has visited - CALLED!');
 
                // Visit the package
                $visitorInstance->visitNetworkPackageHandler($this);
@@ -1323,7 +1322,7 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei
                $this->getAssemblerInstance()->accept($visitorInstance);
 
                // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: ' . $visitorInstance->__toString() . ' has visited - EXIT!');
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: ' . $visitorInstance->__toString() . ' has visited - EXIT!');
        }
 
        /**
@@ -1336,7 +1335,7 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei
                $this->initStacks(TRUE);
 
                // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: All stacker have been re-initialized.');
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: All stacker have been re-initialized.');
        }
 
        /**
@@ -1349,7 +1348,7 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei
         */
        public function removeFirstFailedPackage () {
                // Get the package again
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: CALLED!');
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: CALLED!');
                $packageInstance = $this->getStackInstance()->getNamed(self::STACKER_NAME_DECLARED);
 
                // Is the package status 'failed'?
@@ -1362,7 +1361,7 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei
                $this->getStackInstance()->popNamed(self::STACKER_NAME_DECLARED);
 
                // Trace message
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: EXIT!');
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: EXIT!');
        }
 
        /**
@@ -1373,11 +1372,11 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei
         */
        public function decodeRawContent ($rawPackageContent) {
                // Use the separator '#' to "decode" it
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE: rawPackageContent()=%d - CALLED!', strlen($rawPackageContent)));
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: rawPackageContent()=%d - CALLED!', strlen($rawPackageContent)));
                $decodedArray = explode(self::PACKAGE_DATA_SEPARATOR, $rawPackageContent);
 
                // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: decodedArray=' . print_r($decodedArray, TRUE));
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: decodedArray=' . print_r($decodedArray, TRUE));
 
                // Assert on count (should be always 3)
                assert(count($decodedArray) == self::DECODED_DATA_ARRAY_SIZE);
@@ -1392,10 +1391,10 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei
                $packageInstance->setPackageContent($decodedArray[self::INDEX_PACKAGE_CONTENT]);
                $packageInstance->setStatus(self::PACKAGE_STATUS_DECODED);
                $packageInstance->setContentHash($decodedArray[self::INDEX_PACKAGE_HASH]);
-               $packageInstance->setPrivateKeyHash($decodedArray[self::INDEX_PACKAGE_PRIVATE_KEY_HASH]);
+               $packageInstance->setSenderPrivateKeyHash($decodedArray[self::INDEX_PACKAGE_PRIVATE_KEY_HASH]);
 
                // And return it
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE: packageInstance=%s - EXIT!', $packageInstance->__toString()));
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: packageInstance=%s - EXIT!', $packageInstance->__toString()));
                return $packageInstance;
        }
 
@@ -1413,7 +1412,7 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei
                 * details of the array elements, see comments for constant
                 * PACKAGE_MASK.
                 */
-               $decodedContent = explode(self::PACKAGE_MASK_SEPARATOR, $packageInstance->getContent());
+               $decodedContent = explode(self::PACKAGE_MASK_SEPARATOR, $packageInstance->getPackageContent());
 
                // Assert on array count for a very basic validation
                assert(count($decodedContent) == self::PACKAGE_CONTENT_ARRAY_SIZE);
@@ -1436,7 +1435,7 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei
                        // Hash from decoded raw data
                        self::PACKAGE_CONTENT_HASH             => $packageInstance->getHash(),
                        // Hash of private key
-                       self::PACKAGE_CONTENT_PRIVATE_KEY_HASH => $packageInstance->getPrivateKeyHash()
+                       self::PACKAGE_CONTENT_PRIVATE_KEY_HASH => $packageInstance->getSenderPrivateKeyHash()
                );
 
                // Is the checksum valid?
@@ -1529,7 +1528,7 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei
                $messageArray[self::MESSAGE_ARRAY_DATA][self::MESSAGE_ARRAY_TYPE] = $messageArray[self::MESSAGE_ARRAY_TYPE];
 
                // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: messageArray=' . print_r($messageArray, TRUE));
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: messageArray=' . print_r($messageArray, TRUE));
 
                // Create a handler instance from given message type
                $handlerInstance = MessageTypeHandlerFactory::createMessageTypeHandlerInstance($messageArray[self::MESSAGE_ARRAY_TYPE]);
@@ -1553,7 +1552,7 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei
         */
        public function feedHashToMiner (array $messageData) {
                // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE: messageData()=%d - CALLED!', count($messageData)));
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: messageData()=%d - CALLED!', count($messageData)));
 
                // Is the feature enabled?
                if (!FrameworkFeature::isFeatureAvailable('hubcoin_reward')) {
@@ -1577,7 +1576,7 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei
                unset($messageData[self::MESSAGE_ARRAY_DATA]);
 
                // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: messageData=' . print_r($messageData, TRUE));
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-HANDLER: messageData=' . print_r($messageData, TRUE));
 
                // Resolve session id ('sender' is a session id) into node id
                $nodeId = HubTools::resolveNodeIdBySessionId($messageData[self::MESSAGE_ARRAY_SENDER]);
index 918a40b011f27411683a0a521d876c857fb593bd..e1de79c23a6075a5988a97f7aba14765d3ab3b85 100644 (file)
@@ -74,26 +74,26 @@ abstract class BaseIpV4ProtocolHandler extends BaseProtocolHandler {
         * Validates given 'recipient' if it is a valid UNL. This means that the UNL
         * can be parsed by the protocol handler.
         *
-        * @param       $packageData    Valid raw package data
+        * @param       $packageInstance        Valid raw package data
         * @return      $isValid                Whether the UNL can be validated
         */
-       public function isValidUniversalNodeLocatorByPackageData (DeliverablePackage $packageInstance) {
+       public function isValidUniversalNodeLocatorByPackageInstance (DeliverablePackage $packageInstance) {
                // Debug message
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('IPV4-PROTOCOL-HANDLER: CALLED!');
 
                // Is the correct handler choosen?
-               assert(substr($packageInstance->getRecipient(), 0, strlen($this->getHandlerName())) != $this->getHandlerName());
+               assert(substr($packageInstance->getRecipientType(), 0, strlen($this->getHandlerName())) != $this->getHandlerName());
 
                // Default is from generic validation
-               $isValid = NodeLocatorUtils::isValidUniversalNodeLocator($packageInstance->getRecipient());
+               $isValid = NodeLocatorUtils::isValidUniversalNodeLocator($packageInstance->getRecipientType());
 
                // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('IPV4-PROTOCOL-HANDLER: packageInstance.recipient=' . $packageInstance->getRecipient() . ',isValid[' . gettype($isValid) . ']=' . intval($isValid));
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('IPV4-PROTOCOL-HANDLER: packageInstance.recipient=' . $packageInstance->getRecipientType() . ',isValid[' . gettype($isValid) . ']=' . intval($isValid));
 
                // If this doesn't fail, continue validating the IP:port combination
                if ($isValid === TRUE) {
                        // ... and validate IP:port, first "parse" the UNL
-                       $unlInstance = UniversalNodeLocatorFactory::createUnlInstanceFromString($packageInstance->getRecipient());
+                       $unlInstance = UniversalNodeLocatorFactory::createUnlInstanceFromString($packageInstance->getRecipientType());
 
                        // Set whole UNL instance
                        // @TODO don't do this in a isValidFoo() method
index d025a7c2e39be83905f138aa4326006a698632fa..69f44a6f085c8088af4c47f35677eeaa5796ef34 100644 (file)
@@ -139,19 +139,19 @@ abstract class BaseRawDataHandler extends BaseHubHandler implements HandleableRa
         * Checks whether the 'recipient' field matches our own an universal node
         * locator.
         *
-        * @param       $packageData    An instance of a DeliverablePackage class
+        * @param       $packageInstance        An instance of a DeliverablePackage class
         * @return      $matches                Whether it matches
         * @todo        This method will be moved to a better place
         */
        protected function ifRecipientMatchesOwnUniversalNodeLocator (DeliverablePackage $packageInstance) {
                // Trace message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('RAW-DATA-HANDLER: packageData()=%d - CALLED!', strlen($packageData)));
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('RAW-DATA-HANDLER: packageInstance=%s - CALLED!', $packageInstance->__toString()));
 
                // Construct own address first
                $ownAddress = NodeObjectFactory::createNodeInstance()->determineUniversalNodeLocator();
 
                // Does it match?
-               $matches = ($ownAddress === $packageInstance->getRecipient());
+               $matches = ($ownAddress === $packageInstance->getRecipientType());
 
                // Trace message
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('RAW-DATA-HANDLER: matches=%d - EXIT!', intval($matches)));
index 04f808f7bd9560589ab2e1482af2412e9412c2dd..68038e271ad2cccc3c676a0322f85a5bf367db91 100644 (file)
@@ -85,23 +85,23 @@ class TcpConnectionHelper extends BaseIpV4ConnectionHelper implements Connection
                        $helperInstance->setHandlerInstance($handlerInstance);
                } catch (NoValidHostnameException $e) {
                        // Debug message
-                       self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CONNECTION-HELPER: Failed to resolve ' . $packageInstance->getRecipient() . ':' . $e->getMessage());
+                       self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CONNECTION-HELPER: Failed to resolve ' . $packageInstance->getRecipientType() . ':' . $e->getMessage());
 
                        // Is the recipient equal as configured UNL?
-                       if (substr($packageInstance->getRecipient(), 0, strlen($helperInstance->getConfigInstance()->getConfigEntry('external_address'))) == $helperInstance->getConfigInstance()->getConfigEntry('external_address')) {
+                       if (substr($packageInstance->getRecipientType(), 0, strlen($helperInstance->getConfigInstance()->getConfigEntry('external_address'))) == $helperInstance->getConfigInstance()->getConfigEntry('external_address')) {
                                // This may connect to shipsimu.org and requests 'ip.php' which will return our external IP address
                                $unlAddress = HubTools::determineExternalAddress();
 
                                // Do we have ip:port match?
                                // @TODO Rewrite this test for UNLs
-                               if (strpos($packageInstance->getRecipient(), ':') === FALSE) {
+                               if (strpos($packageInstance->getRecipientType(), ':') === FALSE) {
                                        // No ip:port!
-                                       $helperInstance->debugInstance(sprintf('[%s:%d]: recipient=%s does not contain ":". Please fix this.', __METHOD__, __LINE__, $packageInstance->getRecipient()));
+                                       $helperInstance->debugInstance(sprintf('[%s:%d]: recipient=%s does not contain ":". Please fix this.', __METHOD__, __LINE__, $packageInstance->getRecipientType()));
                                } // END - if
 
                                // "explode" the ip:port, so index 1 will be the port number
                                // @TODO Rewrite this test for UNLs
-                               $recipientArray = explode(':', $packageInstance->getRecipient());
+                               $recipientArray = explode(':', $packageInstance->getRecipientType());
 
                                // Add the port
                                $unlPort = $recipientArray[LocateableNode::UNL_PART_PORT];
@@ -111,7 +111,7 @@ class TcpConnectionHelper extends BaseIpV4ConnectionHelper implements Connection
                                //$unlInstance =;
                        } else {
                                // It doesn't match, we need to take care of this later
-                               $helperInstance->debugInstance(sprintf('[%s:%d]: recipient=%s!=%s', __METHOD__, __LINE__, $packageInstance->getRecipient(), $helperInstance->getConfigInstance()->getConfigEntry('external_address')));
+                               $helperInstance->debugInstance(sprintf('[%s:%d]: recipient=%s!=%s', __METHOD__, __LINE__, $packageInstance->getRecipientType(), $helperInstance->getConfigInstance()->getConfigEntry('external_address')));
                        }
                }
 
index ad696f9f8a51b0b05ddafcdc1be75ec304c1ca12..e4baf86c7d8afd7be69638ef5a8f063fe5b5f457 100644 (file)
@@ -436,7 +436,7 @@ abstract class BaseListener extends BaseHubSystem implements Visitable {
                $socketProtocol = $this->getSocketInstance()->getSocketProtocol();
 
                // Get UNL instance
-               $unlInstance = UniversalNodeLocatorFactory::createUnlInstanceFromString($packageInstance->getRecipient());
+               $unlInstance = UniversalNodeLocatorFactory::createUnlInstanceFromString($packageInstance->getRecipientType());
 
                // Get protocol from it
                $unlProtocol = $unlInstance->getUnlProtocol();
index a7f5f87f20d19ab12749630e889b0aecadf32c92..e4fcb578c7a0c0d7b13daa3772b435ddb279ae5a 100644 (file)
@@ -290,7 +290,7 @@ abstract class BaseListenerDecorator extends BaseDecorator implements Visitable
         *
         * @return      $privateKeyHash         Current private key hash
         */
-       public function getPrivateKeyHash () {
+       public function getNodePrivateKeyHash () {
                $this->partialSub('Please implement this method.');
        }
 
index c97cf022220b634e041b5b0ccc22d4224c223e77..bbe3a881f038fb810e536f239f19ccd2c42187e6 100644 (file)
@@ -146,13 +146,13 @@ abstract class BaseHubNode extends BaseHubSystem implements Updateable, AddableC
 
                // Hash and encrypt the string so we become a node id (also documented as "hub id")
                $this->setPrivateKey($this->getCryptoInstance()->encryptString($randomString));
-               $this->setPrivateKeyHash($this->getCryptoInstance()->hashString($this->getPrivateKey()));
+               $this->setNodePrivateKeyHash($this->getCryptoInstance()->hashString($this->getPrivateKey()));
 
                // Register the node id with our wrapper
                $this->getWrapperInstance()->registerPrivateKey($this, $searchInstance);
 
                // Output message
-               self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BOOTSTRAP: Created new private key with hash: ' . $this->getPrivateKeyHash() . '');
+               self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BOOTSTRAP: Created new private key with hash: ' . $this->getNodePrivateKeyHash() . '');
        }
 
        /**
@@ -373,10 +373,10 @@ abstract class BaseHubNode extends BaseHubSystem implements Updateable, AddableC
                        } else {
                                // Get the node id from result and set it
                                $this->setPrivateKey(base64_decode($this->getField(NodeInformationDatabaseWrapper::DB_COLUMN_PRIVATE_KEY)));
-                               $this->setPrivateKeyHash($this->getField(NodeInformationDatabaseWrapper::DB_COLUMN_PRIVATE_KEY_HASH));
+                               $this->setNodePrivateKeyHash($this->getField(NodeInformationDatabaseWrapper::DB_COLUMN_PRIVATE_KEY_HASH));
 
                                // Output message
-                               self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BOOTSTRAP: Re-using found private key hash: ' . $this->getPrivateKeyHash() . '');
+                               self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BOOTSTRAP: Re-using found private key hash: ' . $this->getNodePrivateKeyHash() . '');
                        }
                } else {
                        /*
@@ -412,7 +412,7 @@ abstract class BaseHubNode extends BaseHubSystem implements Updateable, AddableC
                // Add the private key if acquired
                if ($this->getPrivateKey() != '') {
                        $criteriaInstance->addCriteria(NodeInformationDatabaseWrapper::DB_COLUMN_PRIVATE_KEY, base64_encode($this->getPrivateKey()));
-                       $criteriaInstance->addCriteria(NodeInformationDatabaseWrapper::DB_COLUMN_PRIVATE_KEY_HASH, $this->getPrivateKeyHash());
+                       $criteriaInstance->addCriteria(NodeInformationDatabaseWrapper::DB_COLUMN_PRIVATE_KEY_HASH, $this->getNodePrivateKeyHash());
                } // END - if
 
                // Add own external and internal addresses as UNLs
@@ -879,7 +879,7 @@ abstract class BaseHubNode extends BaseHubSystem implements Updateable, AddableC
                // Add the private key if acquired
                if ($this->getPrivateKey() != '') {
                        $nodeData[NodeInformationDatabaseWrapper::DB_COLUMN_PRIVATE_KEY] = base64_encode($this->getPrivateKey());
-                       $nodeData[NodeInformationDatabaseWrapper::DB_COLUMN_PRIVATE_KEY_HASH] = $this->getPrivateKeyHash();
+                       $nodeData[NodeInformationDatabaseWrapper::DB_COLUMN_PRIVATE_KEY_HASH] = $this->getNodePrivateKeyHash();
                } // END - if
 
                // Debugging:
index 56bc31ee375b8be75a1ba4f86d7a48a557de5f51..7958b837932a4233e17a0d617a1e5d16d8887fdd 100644 (file)
@@ -47,6 +47,11 @@ class PackageData extends BaseHubSystem implements DeliverablePackage, Registera
         */
        private $senderAddress;
 
+       /**
+        * Sender id
+        */
+       private $senderId;
+
        /**
         * Sender port
         */
@@ -62,6 +67,11 @@ class PackageData extends BaseHubSystem implements DeliverablePackage, Registera
         */
        private $status;
 
+       /**
+        * Private key's hash
+        */
+       private $senderPrivateKeyHash;
+
        /**
         * Protected constructor
         *
@@ -107,22 +117,41 @@ class PackageData extends BaseHubSystem implements DeliverablePackage, Registera
        /**
         * Getter for sender address
         *
-        * @return      $senderAddress          Sender address
+        * @return      $senderAddress  Sender address
         */
        public function getSenderAddress () {
                return $this->senderAddress;
        }
 
        /**
-        * Setter for sender address
+        * Setter for sender id
         *
-        * @param       $senderAddress          Sender address
+        * @param       $senderAddress  Sender id
         * @return      void
         */
        public function setSenderAddress ($senderAddress) {
                $this->senderAddress = $senderAddress;
        }
 
+       /**
+        * Getter for sender id
+        *
+        * @return      $senderId       Sender id
+        */
+       public function getSenderId () {
+               return $this->senderId;
+       }
+
+       /**
+        * Setter for sender id
+        *
+        * @param       $senderId               Sender id
+        * @return      void
+        */
+       public function setSenderId ($senderId) {
+               $this->senderId = $senderId;
+       }
+
        /**
         * Getter for sender port
         *
@@ -199,4 +228,23 @@ class PackageData extends BaseHubSystem implements DeliverablePackage, Registera
                $this->contentHash = $contentHash;
        }
 
+       /**
+        * Setter for private key hash
+        *
+        * @param       $senderPrivateKeyHash           The new private key hash
+        * @return      void
+        */
+       public final function setSenderPrivateKeyHash ($senderPrivateKeyHash) {
+               $this->senderPrivateKeyHash = $senderPrivateKeyHash;
+       }
+
+       /**
+        * Getter for private key hash
+        *
+        * @return      $senderPrivateKeyHash           Current private key hash
+        */
+       public final function getSenderPrivateKeyHash () {
+               return $this->senderPrivateKeyHash;
+       }
+
 }
index 0b487b356fdf7f097e45b11d0353e04fda3ee208..9876361e3e4a1489093be58f0ac9dbfeee50f2c9 100644 (file)
@@ -172,9 +172,9 @@ class PackageFragmenter extends BaseHubSystem implements Fragmentable, Registera
         */
        private function getProcessedPackagesIndex (DeliverablePackage $packageInstance) {
                return (
-                       $packageInstance->getSenderAddress() . NetworkPackageHandler::PACKAGE_DATA_SEPARATOR .
-                       $packageInstance->getRecipient()     . NetworkPackageHandler::PACKAGE_DATA_SEPARATOR .
-                       $packageInstance->getContent()       . NetworkPackageHandler::PACKAGE_DATA_SEPARATOR
+                       $packageInstance->getSenderAddress()  . NetworkPackageHandler::PACKAGE_DATA_SEPARATOR .
+                       $packageInstance->getRecipientType()  . NetworkPackageHandler::PACKAGE_DATA_SEPARATOR .
+                       $packageInstance->getPackageContent() . NetworkPackageHandler::PACKAGE_DATA_SEPARATOR
                );
        }
 
index 92b15b6148582630221b4d34d813b3dd98ba9abe..781c077e459d6d01b61618c6db6b679e3cae5b89 100644 (file)
@@ -82,7 +82,7 @@ class DhtRecipient extends BaseRecipient implements Recipient {
                $discoverInstance = ObjectFactory::createObjectByConfiguredName('dht_recipient_discovery_class');
 
                // "Discover" recipients by given package data
-               $recipients = $discoverInstance->resolveRecipientsByPackageData($packageInstance);
+               $recipients = $discoverInstance->resolveRecipientsByPackageInstance($packageInstance);
 
                // Now "walk" through all elements and add them to the list
                foreach ($recipients as $recipient) {
index 6d5a42d1cd3f1256aedda34fd9c2a8255c010548..c3eb55e95f225379dd0993c7407678484001eae7 100644 (file)
@@ -311,7 +311,7 @@ class SocketRegistry extends BaseRegistry implements Register, RegisterableSocke
                                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-REGISTRY: key=' . $key . ',subKey=' . $subKey . ',socketInstance=' . $socketInstance->__toString());
 
                                // Is this a StorableSocket instance and is the address the same?
-                               if (($socketInstance instanceof StorableSocket) && ($socketInstance->ifAddressMatches($packageInstance->getRecipient()))) {
+                               if (($socketInstance instanceof StorableSocket) && ($socketInstance->ifAddressMatches($packageInstance->getRecipientType()))) {
                                        // Debug die
                                        //* DEBUG-DIE: */ die(__METHOD__ . ': socketInstance=' . print_r($socketInstance, TRUE));
 
index bcf0c093a71c9f0c80970881181f60e38e6b55b4..0e08f5b0f44f9e136eed04856d2aa078da111c2d 100644 (file)
@@ -121,7 +121,7 @@ class PackageTags extends BaseTag implements Tagable {
                 * We take a look at the tags (in most cases only one is needed) so
                 * first we need the content data splitted up into all it's parts.
                 */
-               $contentData = explode(NetworkPackageHandler::PACKAGE_MASK_SEPARATOR, $packageInstance->getContent());
+               $contentData = explode(NetworkPackageHandler::PACKAGE_MASK_SEPARATOR, $packageInstance->getPackageContent());
 
                // Get the tags and store them locally
                $this->setTags(explode(NetworkPackageHandler::PACKAGE_TAGS_SEPARATOR, $contentData[NetworkPackageHandler::INDEX_TAGS]));
index b389c1166d886d42c4becac9ec6f2a08a8ce15e7..3e8d6df18d08fef6deae76e141e59535f2ee90e8 100644 (file)
@@ -118,7 +118,7 @@ class XmlObjectRegistryTemplateEngine extends BaseXmlTemplateEngine implements C
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('TAGS: Checking nodeName=%s ...', $nodeName));
                if ($nodeName == self::OBJECT_TYPE_DATA_NAME) {
                        // Output debug message
-                       //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('TAGS: Adding object type ' . $characters . ' to registry.');
+                       /* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('TAGS: Adding object type ' . $characters . ' to registry.');
                        $this->objectRegistryInstance->addEntry($nodeName, $characters);
                } // END - if
 
index 1b40bd057a60508f7c31e95754b47ea2463fc5cf..1d7db4f547facbbe4970ba824b6c12167ff18898 100644 (file)
@@ -37,12 +37,12 @@ class UnexpectedPackageStatusException extends FrameworkException {
         */
        public function __construct (array $messageArray, $code) {
                // Construct the message
-               $message = sprintf('[%s:%d] Unexpected package status %s!=%s detected, recipient=%s, sender=%s:%d, hash=%s.',
+               $message = sprintf('[%s:%d] Unexpected package status %s!=%s detected, recipientType=%s, sender=%s:%d, hash=%s.',
                        $messageArray[0]->__toString(),
                        $this->getLine(),
                        $messageArray[1]->getPackageStatus(),
                        $messageArray[2],
-                       $messageArray[1]->getRecipient(),
+                       $messageArray[1]->getRecipientType(),
                        $messageArray[1]->getSenderAddress(),
                        $messageArray[1]->getSenderPort(),
                        $messageArray[1]->getHash()
index d8b525806026e519cae64285a16f32b6a6d63a1c..b1a6c071afa90865a385f2b5cab18daabcf3968f 100644 (file)
@@ -44,7 +44,7 @@ class InvalidUnlException extends FrameworkException {
                        $messageArray[0]->__toString(),
                        $this->getLine(),
                        $messageArray[1]->__toString(),
-                       $messageArray[2]->getRecipient()
+                       $messageArray[2]->getRecipientType()
                );
 
                // Call parent exception constructor
index 98a986a8fb31cda12b54a0fafdc6d58c417d39da..0eaa9f30807be695442cda57a05d0d937ac62a5a 100644 (file)
@@ -74,7 +74,7 @@ interface HubInterface extends FrameworkInterface {
         *
         * @return      $privateKeyHash         Current private key hash
         */
-       function getPrivateKeyHash ();
+       function getNodePrivateKeyHash ();
 
        /**
         * Getter for session id
index 95ebd9d06837a73193530aa31cf497cd5d360f17..710d9a2af057a046c4cf6d41698c516c7db060c3 100644 (file)
@@ -35,6 +35,6 @@ interface DiscoverableDhtRecipient extends DiscoverableRecipient {
         * @param       $packageInstance        An instance of a DeliverablePackage class
         * @return      $recipients             An indexed array with DHT recipients
         */
-       function resolveRecipientsByPackageData (DeliverablePackage $packageInstance);
+       function resolveRecipientsByPackageInstance (DeliverablePackage $packageInstance);
 
 }
index d37f20f2ecc558964b1061c7eebd8b0f0ed0b56d..1388ed7dcc3549b3fef8b510d5f28281bfd50f90 100644 (file)
@@ -89,7 +89,7 @@ interface Distributable extends HubInterface {
         * @param       $packageInstance        An instance of a DeliverablePackage class
         * @return      $recipients             An indexed array with DHT recipients
         */
-       function findRecipientsByPackageData (DeliverablePackage $packageInstance);
+       function findRecipientsByPackageInstance (DeliverablePackage $packageInstance);
 
        /**
         * Whether the DHT has fully bootstrapped (after state 'booting')
index 4a17eee0b8b5027a905e6a60ef0d76761c5ed3a9..d531a43a306657e6fbc1083b001787dddfd8bed9 100644 (file)
@@ -61,7 +61,7 @@ interface HandleableProtocol extends Handleable, HubInterface {
         * @param       $packageInstance        Valid raw package data
         * @return      $isValid                Whether the UNL can be validated
         */
-       function isValidUniversalNodeLocatorByPackageData (DeliverablePackage $packageInstance);
+       function isValidUniversalNodeLocatorByPackageInstance (DeliverablePackage $packageInstance);
 
        /**
         * If the found UNL (address) matches own external or internal address
index b7a24c7d236f8789352660abb768381254519dde..d3e839fb244b5d12482e31b875c19e7ae5154905 100644 (file)
@@ -50,7 +50,7 @@ interface LookupablePeerState extends Lookupable {
         * @param       $socketInstance         An instance of a StorableSocket class
         * @return      void
         */
-       function registerPeerByPackageData (DeliverablePackage $packageInstance, StorableSocket $socketInstance);
+       function registerPeerByPackageInstance (DeliverablePackage $packageInstance, StorableSocket $socketInstance);
 
        /**
         * Registers the given peer state and An instance of a DeliverablePackage class