]> git.mxchange.org Git - hub.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Mon, 29 May 2017 19:22:54 +0000 (21:22 +0200)
committerRoland Häder <roland@mxchange.org>
Fri, 21 Aug 2020 16:50:09 +0000 (18:50 +0200)
- method renamed to getConnectionClassNameFromSocket() which now only accepts a StorableSocket class
- resolveStateByPackage() now accepts StorableSocket instead of socket resource
- also extend HubInterface
- introduced BaseHubHandler to implement HubInterface (or what is missing + protected setter/getter)
- introduced BaseHubDatabaseWrapper to implement HubInterface
- more debug messages
- other stuff improved
- imported (Base|Peer)StateResolver
- imported StorableSocket
- imported (Lookupable)PeerState
- imported PeerStateable
- created new namespaces
- moved classes around

Signed-off-by: Roland Häder <roland@mxchange.org>
103 files changed:
application/hub/classes/class_BaseHubSystem.php
application/hub/classes/container/socket/class_SocketContainer.php
application/hub/classes/database/frontend/class_BaseHubDatabaseWrapper.php [new file with mode: 0644]
application/hub/classes/database/frontend/cruncher/class_CruncherUnitDatabaseWrapper.php
application/hub/classes/database/frontend/node/class_NodeDistributedHashTableDatabaseWrapper.php
application/hub/classes/database/frontend/node/class_NodeInformationDatabaseWrapper.php
application/hub/classes/database/frontend/states/class_PeerStateLookupDatabaseWrapper.php
application/hub/classes/discovery/recipient/socket/class_PackageSocketDiscovery.php
application/hub/classes/handler/answer-status/.htaccess [deleted file]
application/hub/classes/handler/answer-status/announcement/.htaccess [deleted file]
application/hub/classes/handler/answer-status/announcement/class_NodeAnnouncementAnswerOkayHandler.php [deleted file]
application/hub/classes/handler/answer-status/class_ [deleted file]
application/hub/classes/handler/answer-status/class_BaseAnserStatusHandler.php [deleted file]
application/hub/classes/handler/answer-status/requests/.htaccess [deleted file]
application/hub/classes/handler/answer-status/requests/class_RequestNodeListAnswerOkayHandler.php [deleted file]
application/hub/classes/handler/chunks/class_ChunkHandler.php
application/hub/classes/handler/class_BaseHubHandler.php [new file with mode: 0644]
application/hub/classes/handler/data/.htaccess [new file with mode: 0644]
application/hub/classes/handler/data/answer-status/.htaccess [new file with mode: 0644]
application/hub/classes/handler/data/answer-status/announcement/.htaccess [new file with mode: 0644]
application/hub/classes/handler/data/answer-status/announcement/class_NodeAnnouncementAnswerOkayHandler.php [new file with mode: 0644]
application/hub/classes/handler/data/answer-status/class_ [new file with mode: 0644]
application/hub/classes/handler/data/answer-status/class_BaseAnserStatusHandler.php [new file with mode: 0644]
application/hub/classes/handler/data/answer-status/requests/.htaccess [new file with mode: 0644]
application/hub/classes/handler/data/answer-status/requests/class_RequestNodeListAnswerOkayHandler.php [new file with mode: 0644]
application/hub/classes/handler/data/class_ [new file with mode: 0644]
application/hub/classes/handler/data/class_BaseDataHandler.php [new file with mode: 0644]
application/hub/classes/handler/data/message-types/.htaccess [new file with mode: 0644]
application/hub/classes/handler/data/message-types/announcement/.htaccess [new file with mode: 0644]
application/hub/classes/handler/data/message-types/announcement/class_NodeMessageAnnouncementHandler.php [new file with mode: 0644]
application/hub/classes/handler/data/message-types/answer/.htaccess [new file with mode: 0644]
application/hub/classes/handler/data/message-types/answer/class_NodeMessageAnnouncementAnswerHandler.php [new file with mode: 0644]
application/hub/classes/handler/data/message-types/answer/class_NodeMessageDhtBootstrapAnswerHandler.php [new file with mode: 0644]
application/hub/classes/handler/data/message-types/answer/class_NodeMessageRequestNodeListAnswerHandler.php [new file with mode: 0644]
application/hub/classes/handler/data/message-types/class_ [new file with mode: 0644]
application/hub/classes/handler/data/message-types/class_BaseMessageHandler.php [new file with mode: 0644]
application/hub/classes/handler/data/message-types/dht/.htaccess [new file with mode: 0644]
application/hub/classes/handler/data/message-types/dht/class_NodeMessageDhtBootstrapHandler.php [new file with mode: 0644]
application/hub/classes/handler/data/message-types/requests/.htaccess [new file with mode: 0644]
application/hub/classes/handler/data/message-types/requests/class_NodeMessageRequestNodeListHandler.php [new file with mode: 0644]
application/hub/classes/handler/data/message-types/self-connect/.htaccess [new file with mode: 0644]
application/hub/classes/handler/data/message-types/self-connect/class_NodeMessageSelfConnectHandler.php [new file with mode: 0644]
application/hub/classes/handler/message-types/.htaccess [deleted file]
application/hub/classes/handler/message-types/announcement/.htaccess [deleted file]
application/hub/classes/handler/message-types/announcement/class_NodeMessageAnnouncementHandler.php [deleted file]
application/hub/classes/handler/message-types/answer/.htaccess [deleted file]
application/hub/classes/handler/message-types/answer/class_NodeMessageAnnouncementAnswerHandler.php [deleted file]
application/hub/classes/handler/message-types/answer/class_NodeMessageDhtBootstrapAnswerHandler.php [deleted file]
application/hub/classes/handler/message-types/answer/class_NodeMessageRequestNodeListAnswerHandler.php [deleted file]
application/hub/classes/handler/message-types/class_ [deleted file]
application/hub/classes/handler/message-types/class_BaseMessageHandler.php [deleted file]
application/hub/classes/handler/message-types/dht/.htaccess [deleted file]
application/hub/classes/handler/message-types/dht/class_NodeMessageDhtBootstrapHandler.php [deleted file]
application/hub/classes/handler/message-types/requests/.htaccess [deleted file]
application/hub/classes/handler/message-types/requests/class_NodeMessageRequestNodeListHandler.php [deleted file]
application/hub/classes/handler/message-types/self-connect/.htaccess [deleted file]
application/hub/classes/handler/message-types/self-connect/class_NodeMessageSelfConnectHandler.php [deleted file]
application/hub/classes/handler/network/.htaccess [deleted file]
application/hub/classes/handler/network/socket/.htaccess [deleted file]
application/hub/classes/handler/network/socket/class_SocketRawDataHandler.php [deleted file]
application/hub/classes/handler/network/tcp/.htaccess [deleted file]
application/hub/classes/handler/network/tcp/class_ [deleted file]
application/hub/classes/handler/network/tcp/class_TcpRawDataHandler.php [deleted file]
application/hub/classes/handler/network/udp/.htaccess [deleted file]
application/hub/classes/handler/network/udp/class_UdpRawDataHandler.php [deleted file]
application/hub/classes/handler/protocol/class_BaseProtocolHandler.php
application/hub/classes/handler/raw_data/class_
application/hub/classes/handler/raw_data/class_BaseDataHandler.php [deleted file]
application/hub/classes/handler/raw_data/class_BaseRawDataHandler.php [new file with mode: 0644]
application/hub/classes/handler/raw_data/network/.htaccess [deleted file]
application/hub/classes/handler/raw_data/network/class_ [deleted file]
application/hub/classes/handler/raw_data/network/class_BaseRawDataHandler.php [deleted file]
application/hub/classes/handler/raw_data/socket/.htaccess [new file with mode: 0644]
application/hub/classes/handler/raw_data/socket/class_SocketRawDataHandler.php [new file with mode: 0644]
application/hub/classes/handler/raw_data/tcp/.htaccess [new file with mode: 0644]
application/hub/classes/handler/raw_data/tcp/class_ [new file with mode: 0644]
application/hub/classes/handler/raw_data/tcp/class_TcpRawDataHandler.php [new file with mode: 0644]
application/hub/classes/handler/raw_data/udp/.htaccess [new file with mode: 0644]
application/hub/classes/handler/raw_data/udp/class_UdpRawDataHandler.php [new file with mode: 0644]
application/hub/classes/helper/connection/class_BaseConnectionHelper.php
application/hub/classes/listener/class_BaseListenerDecorator.php
application/hub/classes/resolver/state/peer/class_PeerStateResolver.php
application/hub/classes/states/peer/class_
application/hub/classes/states/peer/connected/class_ConnectedPeerState.php
application/hub/classes/states/peer/errors/class_ConnectionRefusedPeerState.php
application/hub/classes/states/peer/errors/class_ConnectionTimedOutPeerState.php
application/hub/classes/states/peer/errors/class_NoRouteToHostPeerState.php
application/hub/classes/states/peer/errors/class_OperationAlreadyProgressPeerState.php
application/hub/classes/states/peer/errors/class_ProblemPeerState.php
application/hub/classes/states/peer/errors/class_TransportEndpointGonePeerState.php
application/hub/classes/states/peer/init/class_InitPeerState.php
application/hub/config.php
application/hub/interfaces/class_HubInterface.php
application/hub/interfaces/handler/answer-status/class_HandleableAnswerStatus.php
application/hub/interfaces/handler/chunks/class_HandleableChunks.php
application/hub/interfaces/handler/message-types/class_HandleableMessage.php
application/hub/interfaces/handler/network/class_Networkable.php
application/hub/interfaces/handler/protocol/class_HandleableProtocol.php
application/hub/interfaces/helper/connections/class_ConnectionHelper.php
application/hub/interfaces/lookup/node_states/class_LookupableNodeState.php
application/hub/interfaces/lookup/peer_states/class_LookupablePeerState.php
application/hub/interfaces/resolver/state/class_StateResolver.php
application/hub/interfaces/states/peer/class_PeerStateable.php

index dbad5a7783de28cf54793d231d87ac2bd9b6a814..dff2ac434d2c18d61c8bb09f8d6cbd0351f600ea 100644 (file)
@@ -9,6 +9,7 @@ use Hub\Handler\Network\RawData\BaseRawDataHandler;
 use Hub\Information\ShareableInfo;
 use Hub\Listener\BaseListener;
 use Hub\Listener\Listenable;
+use Hub\Locator\Node\LocateableNode;
 use Hub\Network\Deliver\Deliverable;
 use Hub\Network\Package\Assembler\Assembler;
 use Hub\Network\Package\Fragment\Fragmentable;
@@ -114,6 +115,11 @@ class BaseHubSystem extends BaseFrameworkSystem implements HubInterface {
         */
        private $socketInstance = NULL;
 
+       /**
+        * An instance of a LocateableNode class
+        */
+       private $universalNodeLocatorInstance = NULL;
+
        /**
         * Name of used protocol
         */
@@ -416,4 +422,25 @@ class BaseHubSystem extends BaseFrameworkSystem implements HubInterface {
                return $this->socketInstance;
        }
 
+       /**
+        * Setter for UNL instance
+        *
+        * @para        $unlInstance    An instance of a LocateableNode class
+        * @return      void
+        */
+       protected final function setUniversalNodeLocatorInstance (LocateableNode $unlInstance) {
+               // Set new UNL data array
+               $this->universalNodeLocatorInstance = $unlInstance;
+       }
+
+       /**
+        * Getter for UNL instance
+        *
+        * @return      $unlData        An instance of a LocateableNode class
+        */
+       public final function getUniversalNodeLocatorInstance () {
+               // Return UNL data array
+               return $this->universalNodeLocatorInstance;
+       }
+
 }
index c4d88636cd06df083e96d8d1d6015c9d217e54dd..52ef686dcd6cd5adf901b0740dc3694cf587304c 100644 (file)
@@ -465,6 +465,9 @@ class SocketContainer extends BaseContainer implements StorableSocket, Visitable
         * @throws      InvalidSocketException  If stored socket is invalid
         */
        public function connectToSocketRecipient () {
+               // Trace message
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: CALLED!', strtoupper($this->getSocketProtocol())));
+
                // Should be valid socket
                if (!$this->isValidSocket()) {
                        // Throw exception
@@ -480,6 +483,9 @@ class SocketContainer extends BaseContainer implements StorableSocket, Visitable
                // Try to connect to it
                $result = socket_connect($this->getSocketResource(), $unlInstance->getUnlAddress(), $unlInstance->getUnlPort());
 
+               // Trace message
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: result=%d - EXIT!', strtoupper($this->getSocketProtocol()), intval($result)));
+
                // Return result
                return $result;
        }
@@ -489,7 +495,7 @@ class SocketContainer extends BaseContainer implements StorableSocket, Visitable
         *
         * @return      void
         * @throws      SocketShutdownException         If the current socket could not be shut down
-        * @throws      BaseMethodCallException         If this method is possibly called twice
+        * @throws      BadMethodCallException          If this method is possibly called twice
         * @todo        We may want to implement a filter for ease notification of other objects like our pool
         * @todo        rewrite this!
         */
@@ -497,7 +503,7 @@ class SocketContainer extends BaseContainer implements StorableSocket, Visitable
                // Should be valid socket
                if (!$this->isValidSocket()) {
                        // Throw exception
-                       throw new BaseMethodCallException(sprintf('[%s:%d]: Shutdown on invalid socket. Maybe called already?', __METHOD__, __LINE__), self::EXCEPTION_INVALID_SOCKET);
+                       throw new BadMethodCallException(sprintf('[%s:%d]: Shutdown on invalid socket. Maybe called already?', __METHOD__, __LINE__), self::EXCEPTION_INVALID_SOCKET);
                } // END - if
 
                // Debug message
diff --git a/application/hub/classes/database/frontend/class_BaseHubDatabaseWrapper.php b/application/hub/classes/database/frontend/class_BaseHubDatabaseWrapper.php
new file mode 100644 (file)
index 0000000..de83717
--- /dev/null
@@ -0,0 +1,229 @@
+<?php
+// Own namespace
+namespace Hub\Database\Frontend;
+
+// Import application-specific stuff
+use Hub\Container\Socket\StorableSocket;
+use Hub\Handler\Network\RawData\BaseRawDataHandler;
+use Hub\Generic\HubInterface;
+use Hub\Information\ShareableInfo;
+use Hub\Locator\Node\LocateableNode;
+use Hub\Pool\Poolable;
+
+// Import framework stuff
+use CoreFramework\Database\Frontend\BaseDatabaseWrapper;
+
+/**
+ * A database wrapper for cruncher work/test units
+ *
+ * @author             Roland Haeder <webmaster@shipsimu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2011 - 2014 Cruncher Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.shipsimu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class BaseHubDatabaseWrapper extends BaseDatabaseWrapper implements HubInterface {
+
+       /**
+        * Listener pool instance
+        */
+       private $listenerPoolInstance = NULL;
+
+       /**
+        * Info instance
+        */
+       private $infoInstance = NULL;
+
+       /**
+        * A StorableSocket instance
+        */
+       private $socketInstance = NULL;
+
+       /**
+        * An instance of a LocateableNode class
+        */
+       private $universalNodeLocatorInstance = NULL;
+
+       /**
+        * Protected constructor
+        *
+        * @param       $className      Name of the class
+        * @return      void
+        */
+       protected function __construct ($className) {
+               // Call parent constructor
+               parent::__construct($className);
+       }
+
+       /**
+        * Checks whether start/end marker are set
+        *
+        * @param       $data   Data to be checked
+        * @return      $isset  Whether start/end marker are set
+        */
+       public final function ifStartEndMarkersSet ($data) {
+               // Determine it
+               $isset = ((substr($data, 0, strlen(BaseRawDataHandler::STREAM_START_MARKER)) == BaseRawDataHandler::STREAM_START_MARKER) && (substr($data, -1 * strlen(BaseRawDataHandler::STREAM_END_MARKER), strlen(BaseRawDataHandler::STREAM_END_MARKER)) == BaseRawDataHandler::STREAM_END_MARKER));
+
+               // ... and return it
+               return $isset;
+       }
+
+       /**
+        * Setter for listener pool instance
+        *
+        * @param       $listenerPoolInstance   The new listener pool instance
+        * @return      void
+        */
+       protected final function setListenerPoolInstance (Poolable $listenerPoolInstance) {
+               $this->listenerPoolInstance = $listenerPoolInstance;
+       }
+
+       /**
+        * Getter for listener pool instance
+        *
+        * @return      $listenerPoolInstance   Our current listener pool instance
+        */
+       public final function getListenerPoolInstance () {
+               return $this->listenerPoolInstance;
+       }
+
+       /**
+        * Setter for info instance
+        *
+        * @param       $infoInstance   A ShareableInfo instance
+        * @return      void
+        */
+       protected final function setInfoInstance (ShareableInfo $infoInstance) {
+               $this->infoInstance = $infoInstance;
+       }
+
+       /**
+        * Getter for info instance
+        *
+        * @return      $infoInstance   An instance of a ShareableInfo class
+        */
+       public final function getInfoInstance () {
+               return $this->infoInstance;
+       }
+
+       /**
+        * Setter for socket instance
+        *
+        * @param       $socketInstance A StorableSocket instance
+        * @return      void
+        */
+       public final function setSocketInstance (StorableSocket $socketInstance) {
+               $this->socketInstance = $socketInstance;
+       }
+
+       /**
+        * Getter for socket instance
+        *
+        * @return      $socketInstance An instance of a StorableSocket class
+        */
+       public final function getSocketInstance () {
+               return $this->socketInstance;
+       }
+
+       /**
+        * Setter for UNL instance
+        *
+        * @para        $unlInstance    An instance of a LocateableNode class
+        * @return      void
+        */
+       protected final function setUniversalNodeLocatorInstance (LocateableNode $unlInstance) {
+               // Set new UNL data array
+               $this->universalNodeLocatorInstance = $unlInstance;
+       }
+
+       /**
+        * Getter for UNL instance
+        *
+        * @return      $unlData        An instance of a LocateableNode class
+        */
+       public final function getUniversalNodeLocatorInstance () {
+               // Return UNL data array
+               return $this->universalNodeLocatorInstance;
+       }
+
+       /**
+        * Setter for node id
+        *
+        * @param       $nodeId         The new node id
+        * @return      void
+        */
+       protected final function setNodeId ($nodeId) {
+               throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
+       }
+
+       /**
+        * Getter for node id
+        *
+        * @return      $nodeId         Current node id
+        */
+       public final function getNodeId () {
+               throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
+       }
+
+       /**
+        * Setter for private key
+        *
+        * @param       $privateKey             The new private key
+        * @return      void
+        */
+       protected final function setPrivateKey ($privateKey) {
+               throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
+       }
+
+       /**
+        * Getter for private key
+        *
+        * @return      $privateKey             Current private key
+        */
+       public final function getPrivateKey () {
+               throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
+       }
+
+       /**
+        * Setter for private key hash
+        *
+        * @param       $privateKeyHash         The new private key hash
+        * @return      void
+        */
+       protected final function setPrivateKeyHash ($privateKeyHash) {
+               throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
+       }
+
+       /**
+        * Getter for private key hash
+        *
+        * @return      $privateKeyHash         Current private key hash
+        */
+       public final function getPrivateKeyHash () {
+               throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
+       }
+
+       /**
+        * Getter for session id
+        *
+        * @return      $sessionId      Current session id
+        */
+       public final function getSessionId () {
+               throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
+       }
+
+}
index ce93c37f9b8efe315344333866b74ae5fc7a18ba..f48f6e4a2ed0f2d8c1232ed9482287a8a405c299 100644 (file)
@@ -2,8 +2,10 @@
 // Own namespace
 namespace Hub\Database\Frontend\Cruncher\Unit;
 
+// Import application-specific stuff
+use Hub\Database\Frontend\BaseHubDatabaseWrapper;
+
 // Import framework stuff
-use CoreFramework\Database\Frontend\BaseDatabaseWrapper;
 use CoreFramework\Factory\ObjectFactory;
 use CoreFramework\Registry\Registerable;
 
@@ -29,7 +31,7 @@ use CoreFramework\Registry\Registerable;
  * You should have received a copy of the GNU General Public License
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
-class CruncherUnitDatabaseWrapper extends BaseDatabaseWrapper implements UnitDatabaseWrapper, Registerable {
+class CruncherUnitDatabaseWrapper extends BaseHubDatabaseWrapper implements UnitDatabaseWrapper, Registerable {
        // Constants for database table names
        const DB_TABLE_CRUNCHER_UNITS = 'cruncher_units';
 
index b8c64aa69acdf9ccb1ac77d1e901c44b47b28e1f..a4a8ce8d7627c39f9656a7e6b4132e3765983ba6 100644 (file)
@@ -3,6 +3,7 @@
 namespace Hub\Database\Frontend\Node\Dht;
 
 // Import application-specific stuff
+use Hub\Database\Frontend\BaseHubDatabaseWrapper;
 use Hub\Database\Frontend\Node\Information\NodeInformationDatabaseWrapper;
 use Hub\Factory\Node\NodeObjectFactory;
 use Hub\Network\Package\NetworkPackage;
@@ -12,7 +13,6 @@ use Hub\Node\BaseHubNode;
 use CoreFramework\Bootstrap\FrameworkBootstrap;
 use CoreFramework\Criteria\Local\LocalSearchCriteria;
 use CoreFramework\Criteria\Storing\StoreableCriteria;
-use CoreFramework\Database\Frontend\BaseDatabaseWrapper;
 use CoreFramework\Factory\ObjectFactory;
 use CoreFramework\Handler\DataSet\HandleableDataSet;
 use CoreFramework\Registry\Registerable;
@@ -39,7 +39,7 @@ use CoreFramework\Registry\Registerable;
  * You should have received a copy of the GNU General Public License
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
-class NodeDistributedHashTableDatabaseWrapper extends BaseDatabaseWrapper implements NodeDhtWrapper, Registerable {
+class NodeDistributedHashTableDatabaseWrapper extends BaseHubDatabaseWrapper implements NodeDhtWrapper, Registerable {
        /**
         * "Cached" results for dabase for looking for unpublished entries
         */
index 92fb1b5d3aaac144788a495adad5743b68818181..a7e40a57cf62dcc60dd97fb0283f0af50e432f33 100644 (file)
@@ -3,6 +3,7 @@
 namespace Hub\Database\Frontend\Node\Information;
 
 // Import application-specific stuff
+use Hub\Database\Frontend\BaseHubDatabaseWrapper;
 use Hub\Database\Frontend\Node\NodeInformationWrapper;
 use Hub\Node\BaseHubNode;
 use Hub\Helper\Node\NodeHelper;
@@ -10,7 +11,6 @@ use Hub\Helper\Node\NodeHelper;
 // Import framework stuff
 use CoreFramework\Bootstrap\FrameworkBootstrap;
 use CoreFramework\Criteria\Local\LocalSearchCriteria;
-use CoreFramework\Database\Frontend\BaseDatabaseWrapper;
 use CoreFramework\Factory\ObjectFactory;
 use CoreFramework\Registry\Registerable;
 use CoreFramework\Request\Requestable;
@@ -37,7 +37,7 @@ use CoreFramework\Request\Requestable;
  * You should have received a copy of the GNU General Public License
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
-class NodeInformationDatabaseWrapper extends BaseDatabaseWrapper implements NodeInformationWrapper, Registerable {
+class NodeInformationDatabaseWrapper extends BaseHubDatabaseWrapper implements NodeInformationWrapper, Registerable {
        // Constants for database table names
        const DB_TABLE_NODE_INFORMATION = 'node_data';
 
index 594416bc4dc85b04e5400c8eb7c2c78e0c03e51d..1f305f78024b7f2e99955d44e15283e2f43cff45 100644 (file)
@@ -3,14 +3,18 @@
 namespace Hub\Database\Frontend\Node\PeerState;
 
 // Import application-specific sutff
+use Hub\Container\Socket\StorableSocket;
+use Hub\Database\Frontend\BaseHubDatabaseWrapper;
 use Hub\Helper\Connection\ConnectionHelper;
 use Hub\Network\Package\NetworkPackage;
+use Hub\LookupTable\Lookupable;
+use Hub\State\Peer\Lookup\LookupablePeerState;
+use Hub\State\Peer\PeerStateable;
 use Hub\Tools\HubTools;
 
 // Import framework stuff
 use CoreFramework\Criteria\Local\LocalSearchCriteria;
 use CoreFramework\Criteria\Storing\StoreableCriteria;
-use CoreFramework\Database\Frontend\BaseDatabaseWrapper;
 use CoreFramework\Factory\ObjectFactory;
 
 /**
@@ -35,7 +39,7 @@ use CoreFramework\Factory\ObjectFactory;
  * You should have received a copy of the GNU General Public License
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
-class PeerStateLookupDatabaseWrapper extends BaseDatabaseWrapper implements LookupablePeerState {
+class PeerStateLookupDatabaseWrapper extends BaseHubDatabaseWrapper implements LookupablePeerState {
        // Exception constants
        const EXCEPTION_PEER_ALREADY_REGISTERED = 0x300;
 
@@ -137,11 +141,11 @@ class PeerStateLookupDatabaseWrapper extends BaseDatabaseWrapper implements Look
         * Registers a new peer with given package data. We use the session id from it.
         *
         * @param       $packageData            Raw package data
-        * @param       $socketResource         A valid socket resource
+        * @param       $socketResource         An instance of a StorableSocket class
         * @return      void
         * @throws      PeerAlreadyRegisteredException  If a peer is already registered
         */
-       public function registerPeerByPackageData (array $packageData, $socketResource) {
+       public function registerPeerByPackageData (array $packageData, StorableSocket $socketInstance) {
                // Make sure only new peers can be registered with package data
                if (!$this->isSenderNewPeer($packageData)) {
                        // Throw an exception because this should normally not happen
@@ -162,9 +166,9 @@ class PeerStateLookupDatabaseWrapper extends BaseDatabaseWrapper implements Look
                $peerPort    = '0';
 
                // Get peer name
-               if (!@socket_getpeername($socketResource, $peerAddress, $peerPort)) {
+               if (!@socket_getpeername($socketInstance, $peerAddress, $peerPort)) {
                        // Get last error
-                       $lastError = socket_last_error($socketResource);
+                       $lastError = socket_last_error($socketInstance);
 
                        // ... and cleartext message from it and put both into criteria
                        $dataSetInstance->addCriteria(self::DB_COLUMN_SOCKET_ERROR_CODE, $lastError);
@@ -228,19 +232,19 @@ class PeerStateLookupDatabaseWrapper extends BaseDatabaseWrapper implements Look
        /**
         * Purges old entries of given socket resource. We use the IP address from that resource.
         *
-        * @param       $socketResource         A valid socket resource
+        * @param       $socketInstance         An instance of a StorableSocket class
         * @return      void
         * @throws      InvalidSocketException  If the socket resource was invalid
         * @todo        Unfinished area, please rewrite!
         */
-       public function purgeOldEntriesBySocketResource ($socketResource) {
+       public function purgeOldEntriesBysocketInstance (StorableSocket $socketInstance) {
                // Get peer name
-               if (!@socket_getpeername($socketResource, $peerAddress, $peerPort)) {
+               if (!@socket_getpeername($socketInstance, $peerAddress, $peerPort)) {
                        // Get last error
-                       $lastError = socket_last_error($socketResource);
+                       $lastError = socket_last_error($socketInstance);
 
                        // Doesn't work!
-                       throw new InvalidSocketException(array($this, $socketResource, $lastError, socket_strerror($lastError)), self::EXCEPTION_INVALID_SOCKET);
+                       throw new InvalidSocketException(array($this, $socketInstance, $lastError, socket_strerror($lastError)), self::EXCEPTION_INVALID_SOCKET);
                } // END - if
 
                // Debug message
index dc1205db11f07b308a7d01f5f5eeff8c4748db69..6f80c04f5303a117f58bd1b5513be18fe27a9714 100644 (file)
@@ -13,6 +13,7 @@ use Hub\Generic\BaseHubSystem;
 use Hub\Handler\Protocol\HandleableProtocol;
 use Hub\Listener\Listenable;
 use Hub\Network\Package\NetworkPackage;
+use Hub\Resolver\State\Peer\PeerStateResolver;
 
 // Import framework stuff
 use CoreFramework\Generic\NullPointerException;
diff --git a/application/hub/classes/handler/answer-status/.htaccess b/application/hub/classes/handler/answer-status/.htaccess
deleted file mode 100644 (file)
index 3a42882..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Deny from all
diff --git a/application/hub/classes/handler/answer-status/announcement/.htaccess b/application/hub/classes/handler/answer-status/announcement/.htaccess
deleted file mode 100644 (file)
index 3a42882..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Deny from all
diff --git a/application/hub/classes/handler/answer-status/announcement/class_NodeAnnouncementAnswerOkayHandler.php b/application/hub/classes/handler/answer-status/announcement/class_NodeAnnouncementAnswerOkayHandler.php
deleted file mode 100644 (file)
index fae3032..0000000
+++ /dev/null
@@ -1,148 +0,0 @@
-<?php
-// Own namespace
-namespace Hub\Handler\Node\Announcement\Answer;
-
-// Import application-specific stuff
-use Hub\Database\Frontend\Node\Dht\NodeDistributedHashTableDatabaseWrapper;
-use Hub\Factory\Dht\DhtObjectFactory;
-use Hub\Factory\Node\NodeObjectFactory;
-use Hub\Network\Receive\Receivable;
-use Hub\Node\BaseHubNode;
-
-// Import framework stuff
-use CoreFramework\Registry\Registerable;
-use CoreFramework\Registry\Registry;
-
-/**
- * A AnnouncementAnswerOkay handler
- *
- * @author             Roland Haeder <webmaster@shipsimu.org>
- * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team
- * @license            GNU GPL 3.0 or any newer version
- * @link               http://www.shipsimu.org
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-class NodeAnnouncementAnswerOkayHandler extends BaseAnserStatusHandler implements HandleableAnswerStatus, Registerable {
-       /**
-        * Protected constructor
-        *
-        * @return      void
-        */
-       protected function __construct () {
-               // Call parent constructor
-               parent::__construct(__CLASS__);
-
-               // Init array
-               $this->searchData = array(
-                       XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID,
-                       XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS,
-               );
-
-               // Set handler name
-               $this->setHandlerName('announcement_answer_okay');
-       }
-
-       /**
-        * Creates an instance of this class
-        *
-        * @return      $handlerInstance        An instance of a HandleableMessage class
-        */
-       public final static function createNodeAnnouncementAnswerOkayHandler () {
-               // Get new instance
-               $handlerInstance = new NodeAnnouncementAnswerOkayHandler();
-
-               // Return the prepared instance
-               return $handlerInstance;
-       }
-
-       /**
-        * Handles given message data array
-        *
-        * @param       $messageData            An array of message data
-        * @param       $packageInstance        An instance of a Receivable class
-        * @return      void
-        * @todo        Do some more here: Handle karma, et cetera?
-        */
-       public function handleAnswerMessageData (array $messageData, Receivable $packageInstance) {
-               /*
-                * Query DHT and force update (which will throw an exception if the
-                * node is not found).
-                */
-               DhtObjectFactory::createDhtInstance('node')->registerNodeByMessageData($messageData, $this, TRUE);
-
-               // Get handler instance
-               $handlerInstance = Registry::getRegistry()->getInstance('task_handler');
-
-               // Generate DHT bootstrap task
-               $taskInstance = ObjectFactory::createObjectByConfiguredName('node_dht_late_bootstrap_task_class');
-
-               // Register it as well
-               $handlerInstance->registerTask('dht_late_bootstrap', $taskInstance);
-
-               // Get the node instance
-               $nodeInstance = NodeObjectFactory::createNodeInstance();
-
-               // Change state
-               $nodeInstance->getStateInstance()->nodeAnnouncementSuccessful();
-
-               // Prepare next message
-               $this->prepareNextMessage($messageData, $packageInstance);
-       }
-
-       /**
-        * Initializes configuration data from given message data array
-        *
-        * The following array is being handled over:
-        *
-        *   my-external-address => 1.2.3.4
-        *   my-internal-address => 5.6.7.8
-        *   my-status           => reachable
-        *   my-node-id          => aaabbbcccdddeeefff123456789
-        *   my-session-id       => aaabbbcccdddeeefff123456789
-        *   my-tcp-port         => 9060
-        *   my-udp-port         => 9060
-        *   answer-status       => OKAY
-        *   message_type        => announcement_answer
-        *
-        * @param       $messageData    An array with all message data
-        * @return      void
-        */
-       protected function initMessageConfigurationData (array $messageData) {
-               // Get node instance
-               $nodeInstance = NodeObjectFactory::createNodeInstance();
-
-               // Get an array of all accepted object types
-               $objectList = $nodeInstance->getListFromAcceptedObjectTypes();
-
-               // Add missing (temporary) configuration 'accepted_object_types'
-               $this->getConfigInstance()->setConfigEntry(NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_ACCEPTED_OBJECTS, implode(BaseHubNode::OBJECT_LIST_SEPARATOR, $objectList));
-       }
-
-       /**
-        * Removes configuration data with given message data array from global
-        * configuration. For content of $messageData see method comment above.
-        *
-        * @param       $messageData    An array with all message data
-        * @return      void
-        */
-       protected function removeMessageConfigurationData (array $messageData) {
-               // Remove temporay configuration
-               $this->getConfigInstance()->unsetConfigEntry(NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_ACCEPTED_OBJECTS);
-       }
-}
-
-// [EOF]
-?>
diff --git a/application/hub/classes/handler/answer-status/class_ b/application/hub/classes/handler/answer-status/class_
deleted file mode 100644 (file)
index b792e7b..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-<?php
-/**
- * A ??? handler
- *
- * @author             Roland Haeder <webmaster@ship-simu.org>
- * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team
- * @license            GNU GPL 3.0 or any newer version
- * @link               http://www.ship-simu.org
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-class ???Handler extends BaseAnserStatusHandler implements HandleableAnswerStatus, Registerable {
-       /**
-        * Protected constructor
-        *
-        * @return      void
-        */
-       protected function __construct () {
-               // Call parent constructor
-               parent::__construct(__CLASS__);
-
-               // Set handler name
-               $this->setHandlerName('|||_answer_===');
-       }
-
-       /**
-        * Creates an instance of this class
-        *
-        * @return      $handlerInstance        An instance of a HandleableMessage class
-        */
-       public final static function create???Handler () {
-               // Get new instance
-               $handlerInstance = new ???Handler();
-
-               // Return the prepared instance
-               return $handlerInstance;
-       }
-
-       /**
-        * Handles given message data array
-        *
-         * @param      $messageData    An array of message data
-         * @return     void
-         */
-       public function handleAnswerMessageData (array $messageData) {
-               $this->partialStub('Please implement this method.');
-       }
-}
-
-// [EOF]
-?>
diff --git a/application/hub/classes/handler/answer-status/class_BaseAnserStatusHandler.php b/application/hub/classes/handler/answer-status/class_BaseAnserStatusHandler.php
deleted file mode 100644 (file)
index 540bb1c..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-<?php
-/**
- * A general answer-status handler. So called "answer-status handler" are
- * classes which handles a message field 'answer-status' which is, alongside
- * many other node-relevant data, the main part of the answer message. These
- * answer messages, by the way, are never sent unrequested. This, however,
- * sounds logical because the answer is a reply from a node that has responded
- * on a message.
- *
- * The answer-status field gives information back to the requesting node if the
- * receiving node could handle the message properly (all verfication steps are
- * passed, message type was understood, correct receiver, et cetera) and how
- * it handles it. Some messages may be rejected, e.g. when the requesting node
- * is blacklisted or its behavour has changed.
- *
- * @author             Roland Haeder <webmaster@shipsimu.org>
- * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team
- * @license            GNU GPL 3.0 or any newer version
- * @link               http://www.shipsimu.org
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-abstract class BaseAnserStatusHandler extends BaseDataHandler {
-       /**
-        * Protected constructor
-        *
-        * @param       $className      Name of the class
-        * @return      void
-        */
-       protected function __construct ($className) {
-               // Call parent constructor
-               parent::__construct($className);
-       }
-}
-
-// [EOF]
-?>
diff --git a/application/hub/classes/handler/answer-status/requests/.htaccess b/application/hub/classes/handler/answer-status/requests/.htaccess
deleted file mode 100644 (file)
index 3a42882..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Deny from all
diff --git a/application/hub/classes/handler/answer-status/requests/class_RequestNodeListAnswerOkayHandler.php b/application/hub/classes/handler/answer-status/requests/class_RequestNodeListAnswerOkayHandler.php
deleted file mode 100644 (file)
index f3c4a47..0000000
+++ /dev/null
@@ -1,133 +0,0 @@
-<?php
-// Own namespace
-namespace Hub\Handler\Answer\Okay\NodeList;
-
-// Import application-specific stuff
-use Hub\Factory\Dht\DhtObjectFactory;
-use Hub\Network\Receive\Receivable;
-
-// Import framework stuff
-use CoreFramework\Registry\Registerable;
-
-/**
- * A RequestNodeListAnswerOkay handler
- *
- * @author             Roland Haeder <webmaster@shipsimu.org>
- * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team
- * @license            GNU GPL 3.0 or any newer version
- * @link               http://www.shipsimu.org
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-class RequestNodeListAnswerOkayHandler extends BaseAnserStatusHandler implements HandleableAnswerStatus, Registerable {
-       /**
-        * Protected constructor
-        *
-        * @return      void
-        */
-       protected function __construct () {
-               // Call parent constructor
-               parent::__construct(__CLASS__);
-
-               // Init array
-               $this->searchData = array(
-                       XmlRequestNodeListAnswerTemplateEngine::REQUEST_DATA_SESSION_ID,
-               );
-
-               // Set handler name
-               $this->setHandlerName('request_node_list_answer_okay');
-       }
-
-       /**
-        * Creates an instance of this class
-        *
-        * @return      $handlerInstance        An instance of a HandleableMessage class
-        */
-       public final static function createRequestNodeListAnswerOkayHandler () {
-               // Get new instance
-               $handlerInstance = new RequestNodeListAnswerOkayHandler();
-
-               // Return the prepared instance
-               return $handlerInstance;
-       }
-
-       /**
-        * Handles given message data array
-        *
-        * @param       $messageData            An array of message data
-        * @param       $packageInstance        An instance of a Receivable class
-        * @return      void
-        * @throws      NodeSessionIdVerficationException       If the provided session id is not matching
-        * @todo        Do some more here: Handle karma, et cetera?
-        */
-       public function handleAnswerMessageData (array $messageData, Receivable $packageInstance) {
-               // Make sure node-list is found in array
-               assert(isset($messageData[XmlRequestNodeListAnswerTemplateEngine::REQUEST_DATA_NODE_LIST]));
-
-               // Save node list
-               $nodeList = json_decode(base64_decode($messageData[XmlRequestNodeListAnswerTemplateEngine::REQUEST_DATA_NODE_LIST]));
-
-               // Make sure it is completely decoded
-               assert(is_array($nodeList));
-
-               // ... and remove it as it should not be included now
-               unset($messageData[XmlRequestNodeListAnswerTemplateEngine::REQUEST_DATA_NODE_LIST]);
-
-               // Write node list to DHT
-               DhtObjectFactory::createDhtInstance('node')->insertNodeList($nodeList);
-
-               /*
-                * Query DHT and force update (which will throw an exception if the
-                * node is not found).
-                */
-               DhtObjectFactory::createDhtInstance('node')->registerNodeByMessageData($messageData, $this, TRUE);
-
-               // Prepare next message ("hello" message to all returned nodes)
-               //$this->prepareNextMessage($messageData, $packageInstance);
-       }
-
-       /**
-        * Initializes configuration data from given message data array
-        *
-        * The following array is being handled over:
-        *
-        *   session-id    => aaabbbcccdddeeefff123456789
-        *   node-list     => aabb:ccdd:eeff
-        *   answer-status => OKAY
-        *   message_type  => request_node_list_answer
-        *
-        * @param       $messageData    An array with all message data
-        * @return      void
-        * @todo        0% done
-        */
-       protected function initMessageConfigurationData (array $messageData) {
-               $this->partialStub('Please implement this method.');
-       }
-
-       /**
-        * Removes configuration data with given message data array from global
-        * configuration. For content of $messageData see method comment above.
-        *
-        * @param       $messageData    An array with all message data
-        * @return      void
-        * @todo        0% done
-        */
-       protected function removeMessageConfigurationData (array $messageData) {
-               $this->partialStub('Please implement this method.');
-       }
-}
-
-// [EOF]
-?>
index f9469078ae34732b5ec5ee51d7a604ad7017aa40..e8331438753cba0dbc580d49326185813e1cc928 100644 (file)
@@ -4,11 +4,11 @@ namespace Hub\Handler\Network\RawData\Chunks;
 
 // Import application-specific stuff
 use Hub\Factory\Fragmenter\FragmenterFactory;
+use Hub\Handler\BaseHubHandler;
 use Hub\Network\Package\Fragment\PackageFragmenter;
 
 // Import framework stuff
 use CoreFramework\Factory\ObjectFactory;
-use CoreFramework\Handler\BaseHandler;
 use CoreFramework\Registry\Registerable;
 
 /**
@@ -33,7 +33,7 @@ use CoreFramework\Registry\Registerable;
  * You should have received a copy of the GNU General Public License
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
-class ChunkHandler extends BaseHandler implements HandleableChunks, Registerable {
+class ChunkHandler extends BaseHubHandler implements HandleableChunks, Registerable {
        /**
         * Stacker for chunks with final EOP
         */
diff --git a/application/hub/classes/handler/class_BaseHubHandler.php b/application/hub/classes/handler/class_BaseHubHandler.php
new file mode 100644 (file)
index 0000000..a0d4861
--- /dev/null
@@ -0,0 +1,229 @@
+<?php
+// Own namespace
+namespace Hub\Handler;
+
+// Import application-specific stuff
+use Hub\Container\Socket\StorableSocket;
+use Hub\Handler\Network\RawData\BaseRawDataHandler;
+use Hub\Generic\HubInterface;
+use Hub\Information\ShareableInfo;
+use Hub\Locator\Node\LocateableNode;
+use Hub\Pool\Poolable;
+
+// Import framework stuff
+use CoreFramework\Handler\BaseHandler;
+use CoreFramework\Handler\Handleable;
+
+/**
+ * A general hub handler
+ *
+ * @author             Roland Haeder <webmaster@shipsimu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.shipsimu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+class BaseHubHandler extends BaseHandler implements Handleable, HubInterface {
+       /**
+        * Listener pool instance
+        */
+       private $listenerPoolInstance = NULL;
+
+       /**
+        * Info instance
+        */
+       private $infoInstance = NULL;
+
+       /**
+        * A StorableSocket instance
+        */
+       private $socketInstance = NULL;
+
+       /**
+        * An instance of a LocateableNode class
+        */
+       private $universalNodeLocatorInstance = NULL;
+
+       /**
+        * Protected constructor
+        *
+        * @param       $className      Name of the class
+        * @return      void
+        */
+       protected function __construct ($className) {
+               // Call parent constructor
+               parent::__construct($className);
+       }
+
+       /**
+        * Checks whether start/end marker are set
+        *
+        * @param       $data   Data to be checked
+        * @return      $isset  Whether start/end marker are set
+        */
+       public final function ifStartEndMarkersSet ($data) {
+               // Determine it
+               $isset = ((substr($data, 0, strlen(BaseRawDataHandler::STREAM_START_MARKER)) == BaseRawDataHandler::STREAM_START_MARKER) && (substr($data, -1 * strlen(BaseRawDataHandler::STREAM_END_MARKER), strlen(BaseRawDataHandler::STREAM_END_MARKER)) == BaseRawDataHandler::STREAM_END_MARKER));
+
+               // ... and return it
+               return $isset;
+       }
+
+       /**
+        * Setter for listener pool instance
+        *
+        * @param       $listenerPoolInstance   The new listener pool instance
+        * @return      void
+        */
+       protected final function setListenerPoolInstance (Poolable $listenerPoolInstance) {
+               $this->listenerPoolInstance = $listenerPoolInstance;
+       }
+
+       /**
+        * Getter for listener pool instance
+        *
+        * @return      $listenerPoolInstance   Our current listener pool instance
+        */
+       public final function getListenerPoolInstance () {
+               return $this->listenerPoolInstance;
+       }
+
+       /**
+        * Setter for info instance
+        *
+        * @param       $infoInstance   A ShareableInfo instance
+        * @return      void
+        */
+       protected final function setInfoInstance (ShareableInfo $infoInstance) {
+               $this->infoInstance = $infoInstance;
+       }
+
+       /**
+        * Getter for info instance
+        *
+        * @return      $infoInstance   An instance of a ShareableInfo class
+        */
+       public final function getInfoInstance () {
+               return $this->infoInstance;
+       }
+
+       /**
+        * Setter for socket instance
+        *
+        * @param       $socketInstance A StorableSocket instance
+        * @return      void
+        */
+       public final function setSocketInstance (StorableSocket $socketInstance) {
+               $this->socketInstance = $socketInstance;
+       }
+
+       /**
+        * Getter for socket instance
+        *
+        * @return      $socketInstance An instance of a StorableSocket class
+        */
+       public final function getSocketInstance () {
+               return $this->socketInstance;
+       }
+
+       /**
+        * Setter for UNL instance
+        *
+        * @para        $unlInstance    An instance of a LocateableNode class
+        * @return      void
+        */
+       protected final function setUniversalNodeLocatorInstance (LocateableNode $unlInstance) {
+               // Set new UNL data array
+               $this->universalNodeLocatorInstance = $unlInstance;
+       }
+
+       /**
+        * Getter for UNL instance
+        *
+        * @return      $unlData        An instance of a LocateableNode class
+        */
+       public final function getUniversalNodeLocatorInstance () {
+               // Return UNL data array
+               return $this->universalNodeLocatorInstance;
+       }
+
+       /**
+        * Setter for node id
+        *
+        * @param       $nodeId         The new node id
+        * @return      void
+        */
+       protected final function setNodeId ($nodeId) {
+               throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
+       }
+
+       /**
+        * Getter for node id
+        *
+        * @return      $nodeId         Current node id
+        */
+       public final function getNodeId () {
+               throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
+       }
+
+       /**
+        * Setter for private key
+        *
+        * @param       $privateKey             The new private key
+        * @return      void
+        */
+       protected final function setPrivateKey ($privateKey) {
+               throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
+       }
+
+       /**
+        * Getter for private key
+        *
+        * @return      $privateKey             Current private key
+        */
+       public final function getPrivateKey () {
+               throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
+       }
+
+       /**
+        * Setter for private key hash
+        *
+        * @param       $privateKeyHash         The new private key hash
+        * @return      void
+        */
+       protected final function setPrivateKeyHash ($privateKeyHash) {
+               throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
+       }
+
+       /**
+        * Getter for private key hash
+        *
+        * @return      $privateKeyHash         Current private key hash
+        */
+       public final function getPrivateKeyHash () {
+               throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
+       }
+
+       /**
+        * Getter for session id
+        *
+        * @return      $sessionId      Current session id
+        */
+       public final function getSessionId () {
+               throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
+       }
+
+}
diff --git a/application/hub/classes/handler/data/.htaccess b/application/hub/classes/handler/data/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/classes/handler/data/answer-status/.htaccess b/application/hub/classes/handler/data/answer-status/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/classes/handler/data/answer-status/announcement/.htaccess b/application/hub/classes/handler/data/answer-status/announcement/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/classes/handler/data/answer-status/announcement/class_NodeAnnouncementAnswerOkayHandler.php b/application/hub/classes/handler/data/answer-status/announcement/class_NodeAnnouncementAnswerOkayHandler.php
new file mode 100644 (file)
index 0000000..fae3032
--- /dev/null
@@ -0,0 +1,148 @@
+<?php
+// Own namespace
+namespace Hub\Handler\Node\Announcement\Answer;
+
+// Import application-specific stuff
+use Hub\Database\Frontend\Node\Dht\NodeDistributedHashTableDatabaseWrapper;
+use Hub\Factory\Dht\DhtObjectFactory;
+use Hub\Factory\Node\NodeObjectFactory;
+use Hub\Network\Receive\Receivable;
+use Hub\Node\BaseHubNode;
+
+// Import framework stuff
+use CoreFramework\Registry\Registerable;
+use CoreFramework\Registry\Registry;
+
+/**
+ * A AnnouncementAnswerOkay handler
+ *
+ * @author             Roland Haeder <webmaster@shipsimu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.shipsimu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+class NodeAnnouncementAnswerOkayHandler extends BaseAnserStatusHandler implements HandleableAnswerStatus, Registerable {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+
+               // Init array
+               $this->searchData = array(
+                       XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID,
+                       XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS,
+               );
+
+               // Set handler name
+               $this->setHandlerName('announcement_answer_okay');
+       }
+
+       /**
+        * Creates an instance of this class
+        *
+        * @return      $handlerInstance        An instance of a HandleableMessage class
+        */
+       public final static function createNodeAnnouncementAnswerOkayHandler () {
+               // Get new instance
+               $handlerInstance = new NodeAnnouncementAnswerOkayHandler();
+
+               // Return the prepared instance
+               return $handlerInstance;
+       }
+
+       /**
+        * Handles given message data array
+        *
+        * @param       $messageData            An array of message data
+        * @param       $packageInstance        An instance of a Receivable class
+        * @return      void
+        * @todo        Do some more here: Handle karma, et cetera?
+        */
+       public function handleAnswerMessageData (array $messageData, Receivable $packageInstance) {
+               /*
+                * Query DHT and force update (which will throw an exception if the
+                * node is not found).
+                */
+               DhtObjectFactory::createDhtInstance('node')->registerNodeByMessageData($messageData, $this, TRUE);
+
+               // Get handler instance
+               $handlerInstance = Registry::getRegistry()->getInstance('task_handler');
+
+               // Generate DHT bootstrap task
+               $taskInstance = ObjectFactory::createObjectByConfiguredName('node_dht_late_bootstrap_task_class');
+
+               // Register it as well
+               $handlerInstance->registerTask('dht_late_bootstrap', $taskInstance);
+
+               // Get the node instance
+               $nodeInstance = NodeObjectFactory::createNodeInstance();
+
+               // Change state
+               $nodeInstance->getStateInstance()->nodeAnnouncementSuccessful();
+
+               // Prepare next message
+               $this->prepareNextMessage($messageData, $packageInstance);
+       }
+
+       /**
+        * Initializes configuration data from given message data array
+        *
+        * The following array is being handled over:
+        *
+        *   my-external-address => 1.2.3.4
+        *   my-internal-address => 5.6.7.8
+        *   my-status           => reachable
+        *   my-node-id          => aaabbbcccdddeeefff123456789
+        *   my-session-id       => aaabbbcccdddeeefff123456789
+        *   my-tcp-port         => 9060
+        *   my-udp-port         => 9060
+        *   answer-status       => OKAY
+        *   message_type        => announcement_answer
+        *
+        * @param       $messageData    An array with all message data
+        * @return      void
+        */
+       protected function initMessageConfigurationData (array $messageData) {
+               // Get node instance
+               $nodeInstance = NodeObjectFactory::createNodeInstance();
+
+               // Get an array of all accepted object types
+               $objectList = $nodeInstance->getListFromAcceptedObjectTypes();
+
+               // Add missing (temporary) configuration 'accepted_object_types'
+               $this->getConfigInstance()->setConfigEntry(NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_ACCEPTED_OBJECTS, implode(BaseHubNode::OBJECT_LIST_SEPARATOR, $objectList));
+       }
+
+       /**
+        * Removes configuration data with given message data array from global
+        * configuration. For content of $messageData see method comment above.
+        *
+        * @param       $messageData    An array with all message data
+        * @return      void
+        */
+       protected function removeMessageConfigurationData (array $messageData) {
+               // Remove temporay configuration
+               $this->getConfigInstance()->unsetConfigEntry(NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_ACCEPTED_OBJECTS);
+       }
+}
+
+// [EOF]
+?>
diff --git a/application/hub/classes/handler/data/answer-status/class_ b/application/hub/classes/handler/data/answer-status/class_
new file mode 100644 (file)
index 0000000..b792e7b
--- /dev/null
@@ -0,0 +1,63 @@
+<?php
+/**
+ * A ??? handler
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+class ???Handler extends BaseAnserStatusHandler implements HandleableAnswerStatus, Registerable {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+
+               // Set handler name
+               $this->setHandlerName('|||_answer_===');
+       }
+
+       /**
+        * Creates an instance of this class
+        *
+        * @return      $handlerInstance        An instance of a HandleableMessage class
+        */
+       public final static function create???Handler () {
+               // Get new instance
+               $handlerInstance = new ???Handler();
+
+               // Return the prepared instance
+               return $handlerInstance;
+       }
+
+       /**
+        * Handles given message data array
+        *
+         * @param      $messageData    An array of message data
+         * @return     void
+         */
+       public function handleAnswerMessageData (array $messageData) {
+               $this->partialStub('Please implement this method.');
+       }
+}
+
+// [EOF]
+?>
diff --git a/application/hub/classes/handler/data/answer-status/class_BaseAnserStatusHandler.php b/application/hub/classes/handler/data/answer-status/class_BaseAnserStatusHandler.php
new file mode 100644 (file)
index 0000000..540bb1c
--- /dev/null
@@ -0,0 +1,49 @@
+<?php
+/**
+ * A general answer-status handler. So called "answer-status handler" are
+ * classes which handles a message field 'answer-status' which is, alongside
+ * many other node-relevant data, the main part of the answer message. These
+ * answer messages, by the way, are never sent unrequested. This, however,
+ * sounds logical because the answer is a reply from a node that has responded
+ * on a message.
+ *
+ * The answer-status field gives information back to the requesting node if the
+ * receiving node could handle the message properly (all verfication steps are
+ * passed, message type was understood, correct receiver, et cetera) and how
+ * it handles it. Some messages may be rejected, e.g. when the requesting node
+ * is blacklisted or its behavour has changed.
+ *
+ * @author             Roland Haeder <webmaster@shipsimu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.shipsimu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+abstract class BaseAnserStatusHandler extends BaseDataHandler {
+       /**
+        * Protected constructor
+        *
+        * @param       $className      Name of the class
+        * @return      void
+        */
+       protected function __construct ($className) {
+               // Call parent constructor
+               parent::__construct($className);
+       }
+}
+
+// [EOF]
+?>
diff --git a/application/hub/classes/handler/data/answer-status/requests/.htaccess b/application/hub/classes/handler/data/answer-status/requests/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/classes/handler/data/answer-status/requests/class_RequestNodeListAnswerOkayHandler.php b/application/hub/classes/handler/data/answer-status/requests/class_RequestNodeListAnswerOkayHandler.php
new file mode 100644 (file)
index 0000000..f3c4a47
--- /dev/null
@@ -0,0 +1,133 @@
+<?php
+// Own namespace
+namespace Hub\Handler\Answer\Okay\NodeList;
+
+// Import application-specific stuff
+use Hub\Factory\Dht\DhtObjectFactory;
+use Hub\Network\Receive\Receivable;
+
+// Import framework stuff
+use CoreFramework\Registry\Registerable;
+
+/**
+ * A RequestNodeListAnswerOkay handler
+ *
+ * @author             Roland Haeder <webmaster@shipsimu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.shipsimu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+class RequestNodeListAnswerOkayHandler extends BaseAnserStatusHandler implements HandleableAnswerStatus, Registerable {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+
+               // Init array
+               $this->searchData = array(
+                       XmlRequestNodeListAnswerTemplateEngine::REQUEST_DATA_SESSION_ID,
+               );
+
+               // Set handler name
+               $this->setHandlerName('request_node_list_answer_okay');
+       }
+
+       /**
+        * Creates an instance of this class
+        *
+        * @return      $handlerInstance        An instance of a HandleableMessage class
+        */
+       public final static function createRequestNodeListAnswerOkayHandler () {
+               // Get new instance
+               $handlerInstance = new RequestNodeListAnswerOkayHandler();
+
+               // Return the prepared instance
+               return $handlerInstance;
+       }
+
+       /**
+        * Handles given message data array
+        *
+        * @param       $messageData            An array of message data
+        * @param       $packageInstance        An instance of a Receivable class
+        * @return      void
+        * @throws      NodeSessionIdVerficationException       If the provided session id is not matching
+        * @todo        Do some more here: Handle karma, et cetera?
+        */
+       public function handleAnswerMessageData (array $messageData, Receivable $packageInstance) {
+               // Make sure node-list is found in array
+               assert(isset($messageData[XmlRequestNodeListAnswerTemplateEngine::REQUEST_DATA_NODE_LIST]));
+
+               // Save node list
+               $nodeList = json_decode(base64_decode($messageData[XmlRequestNodeListAnswerTemplateEngine::REQUEST_DATA_NODE_LIST]));
+
+               // Make sure it is completely decoded
+               assert(is_array($nodeList));
+
+               // ... and remove it as it should not be included now
+               unset($messageData[XmlRequestNodeListAnswerTemplateEngine::REQUEST_DATA_NODE_LIST]);
+
+               // Write node list to DHT
+               DhtObjectFactory::createDhtInstance('node')->insertNodeList($nodeList);
+
+               /*
+                * Query DHT and force update (which will throw an exception if the
+                * node is not found).
+                */
+               DhtObjectFactory::createDhtInstance('node')->registerNodeByMessageData($messageData, $this, TRUE);
+
+               // Prepare next message ("hello" message to all returned nodes)
+               //$this->prepareNextMessage($messageData, $packageInstance);
+       }
+
+       /**
+        * Initializes configuration data from given message data array
+        *
+        * The following array is being handled over:
+        *
+        *   session-id    => aaabbbcccdddeeefff123456789
+        *   node-list     => aabb:ccdd:eeff
+        *   answer-status => OKAY
+        *   message_type  => request_node_list_answer
+        *
+        * @param       $messageData    An array with all message data
+        * @return      void
+        * @todo        0% done
+        */
+       protected function initMessageConfigurationData (array $messageData) {
+               $this->partialStub('Please implement this method.');
+       }
+
+       /**
+        * Removes configuration data with given message data array from global
+        * configuration. For content of $messageData see method comment above.
+        *
+        * @param       $messageData    An array with all message data
+        * @return      void
+        * @todo        0% done
+        */
+       protected function removeMessageConfigurationData (array $messageData) {
+               $this->partialStub('Please implement this method.');
+       }
+}
+
+// [EOF]
+?>
diff --git a/application/hub/classes/handler/data/class_ b/application/hub/classes/handler/data/class_
new file mode 100644 (file)
index 0000000..9a2846c
--- /dev/null
@@ -0,0 +1,77 @@
+<?php
+// Own namespace
+namespace Hub\Handler\Network\;
+
+// Import application-specific stuff
+use Hub\Network\Networkable;
+
+/**
+ * A ??? network package handler
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 Hub Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+class ???NetworkPackageHandler extends BaseNetworkPackageHandler implements Networkable {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+
+               // Set handler name
+               $this->setHandlerName('!!!');
+       }
+
+       /**
+        * Creates an instance of this class
+        *
+        * @return      $handlerInstance                An instance of a Networkable class
+        */
+       public final static function create???NetworkPackageHandler () {
+               // Get new instance
+               $handlerInstance = new ???NetworkPackageHandler();
+
+               // Return the prepared instance
+               return $handlerInstance;
+       }
+
+       /**
+        * Processes a package from given resource. This is mostly useful for TCP
+        * package handling and is implemented in the TcpListener class
+        *
+        * @param       $resource       A valid resource identifier
+        * @return      void
+        * @throws      InvalidResourceException        If the given resource is invalid
+        * @todo        0%
+        */
+       public function processResourcePackage ($resource) {
+               // Check the resource
+               if (!is_resource($resource)) {
+                       // Throw an exception
+                       throw new InvalidResourceException($this, self::EXCEPTION_INVALID_RESOURCE);
+               } // END - if
+
+               // Implement processing here
+               $this->partialStub('Please implement this method.');
+       }
+
+}
diff --git a/application/hub/classes/handler/data/class_BaseDataHandler.php b/application/hub/classes/handler/data/class_BaseDataHandler.php
new file mode 100644 (file)
index 0000000..744a14c
--- /dev/null
@@ -0,0 +1,202 @@
+<?php
+// Own namespace
+namespace Hub\Handler\Data;
+
+// Import application-specific stuff
+use Hub\Factory\Node\NodeObjectFactory;
+use Hub\Generic\HubInterface;
+use Hub\Handler\BaseHubHandler;
+use Hub\Network\Deliver\Deliverable;
+
+// Import framework stuff
+use CoreFramework\Factory\ObjectFactory;
+use CoreFramework\Generic\FrameworkException;
+
+/**
+ * A general data Handler
+ *
+ * @author             Roland Haeder <webmaster@shipsimu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 Hub Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.shipsimu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+abstract class BaseDataHandler extends BaseHubHandler implements HubInterface {
+       /**
+        * Last exception instance from database layer or NULL (default)
+        */
+       private $lastException = NULL;
+
+       /**
+        * Array with search criteria elements
+        */
+       protected $searchData = array();
+
+       /**
+        * Array with all data XML nodes (which hold the actual data) and their values
+        */
+       protected $messageDataElements = array();
+
+       /**
+        * Array for translating message data elements (other node's data mostly)
+        * into configuration elements.
+        */
+       protected $messageToConfig = array();
+
+       /**
+        * Array for copying configuration entries
+        */
+       protected $configCopy = array();
+
+       /**
+        * Protected constructor
+        *
+        * @param       $className      Name of the class
+        * @return      void
+        */
+       protected function __construct ($className) {
+               // Call parent constructor
+               parent::__construct($className);
+       }
+
+       /**
+        * Getter for search data array
+        *
+        * @return      $searchData             Search data array
+        */
+       public final function getSearchData () {
+               return $this->searchData;
+       }
+
+       /**
+        * Getter for last exception
+        *
+        * @return      $lastException  Last thrown exception
+        */
+       public final function getLastException () {
+               return $this->lastException;
+       }
+
+       /**
+        * Setter for last exception
+        *
+        * @param       $lastException  Last thrown exception
+        * @return      void
+        */
+       public final function setLastException (FrameworkException $exceptionInstance = NULL) {
+               $this->lastException = $exceptionInstance;
+       }
+
+       /**
+        * Prepares a message as answer for given message data for delivery.
+        *
+        * @param       $messageData            An array with all message data
+        * @param       $packageInstance        An instance of a Deliverable instance
+        * @return      void
+        */
+       protected function prepareAnswerMessage (array $messageData, Deliverable $packageInstance) {
+               // Debug message
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('MESSAGE-HANDLER: Going to send an answer message for ' . $this->getHandlerName() . ' ...');
+
+               // Get a helper instance based on this handler's name
+               $helperInstance = ObjectFactory::createObjectByConfiguredName('node_answer_' . $this->getHandlerName() . '_helper_class', array($messageData));
+
+               // Get node instance
+               $nodeInstance = NodeObjectFactory::createNodeInstance();
+
+               // Load descriptor XML
+               $helperInstance->loadDescriptorXml($nodeInstance);
+
+               /*
+                * Set missing (temporary) configuration data, mostly it needs to be
+                * copied from message data array.
+                */
+               $this->initMessageConfigurationData($messageData);
+
+               // Compile any configuration variables
+               $helperInstance->getTemplateInstance()->compileConfigInVariables();
+
+               // Deliver the package
+               $helperInstance->sendPackage($nodeInstance);
+
+               /*
+                * Remove temporary configuration
+                */
+               $this->removeMessageConfigurationData($messageData);
+
+               // Debug message
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('MESSAGE-HANDLER: Answer message has been prepared.');
+       }
+
+       /**
+        * Prepares the next message
+        *
+        * @param       $messageData            An array with all message data
+        * @param       $packageInstance        An instance of a Deliverable instance
+        * @return      void
+        */
+       protected function prepareNextMessage (array $messageData, Deliverable $packageInstance) {
+               // Debug message
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('MESSAGE-HANDLER: Going to send next message ...');
+
+               // Get a helper instance based on this handler's name
+               $helperInstance = ObjectFactory::createObjectByConfiguredName('node_next_' . $this->getHandlerName() . '_helper_class', array($messageData));
+
+               // Get node instance
+               $nodeInstance = NodeObjectFactory::createNodeInstance();
+
+               // Load descriptor XML
+               $helperInstance->loadDescriptorXml($nodeInstance);
+
+               /*
+                * Set missing (temporary) configuration data, mostly it needs to be
+                * copied from message data array.
+                */
+               $this->initMessageConfigurationData($messageData);
+
+               // Compile any configuration variables
+               $helperInstance->getTemplateInstance()->compileConfigInVariables();
+
+               // Deliver the package
+               $helperInstance->sendPackage($nodeInstance);
+
+               /*
+                * Remove temporary configuration
+                */
+               $this->removeMessageConfigurationData($messageData);
+
+               // Debug message
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('MESSAGE-HANDLER: Next message has been prepared.');
+       }
+
+       /**
+        * Initializes configuration data from given message data array
+        *
+        * @param       $messageData    An array with all message data
+        * @return      void
+        */
+       abstract protected function initMessageConfigurationData (array $messageData);
+
+       /**
+        * Removes configuration data with given message data array from global
+        * configuration
+        *
+        * @param       $messageData    An array with all message data
+        * @return      void
+        */
+       abstract protected function removeMessageConfigurationData (array $messageData);
+
+}
diff --git a/application/hub/classes/handler/data/message-types/.htaccess b/application/hub/classes/handler/data/message-types/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/classes/handler/data/message-types/announcement/.htaccess b/application/hub/classes/handler/data/message-types/announcement/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/classes/handler/data/message-types/announcement/class_NodeMessageAnnouncementHandler.php b/application/hub/classes/handler/data/message-types/announcement/class_NodeMessageAnnouncementHandler.php
new file mode 100644 (file)
index 0000000..1882fb2
--- /dev/null
@@ -0,0 +1,209 @@
+<?php
+// Own namespace
+namespace Hub\Handler\Node\Message\Announcement;
+
+// Import application-specific stuff
+use Hub\Database\Frontend\Node\Dht\NodeDistributedHashTableDatabaseWrapper;
+use Hub\Factory\Node\NodeObjectFactory;
+use Hub\Generic\BaseHubSystem;
+use Hub\Network\Receive\Receivable;
+
+// Import framework stuff
+use CoreFramework\Criteria\Storing\StoreableCriteria;
+use CoreFramework\Registry\Registerable;
+
+/**
+ * A NodeMessageAnnouncement handler
+ *
+ * @author             Roland Haeder <webmaster@shipsimu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.shipsimu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+class NodeMessageAnnouncementHandler extends BaseMessageHandler implements HandleableMessage, Registerable {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+
+               // Set handler name
+               $this->setHandlerName('message_announcement');
+
+               // Init message data array
+               $this->messageDataElements = array(
+                       XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS,
+                       XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_INTERNAL_ADDRESS,
+                       XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_NODE_STATUS,
+                       XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_NODE_MODE,
+                       XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_NODE_ID,
+                       XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID,
+                       XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_PRIVATE_KEY_HASH,
+               );
+
+               // Init message-data->configuration translation array
+               $this->messageToConfig = array(
+                       XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS => 'your_external_address',
+                       XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_INTERNAL_ADDRESS => 'your_internal_address',
+                       XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_NODE_ID          => 'your_node_id',
+                       XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID       => 'your_session_id',
+                       XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_PRIVATE_KEY_HASH => 'your_private_key_hash',
+               );
+
+               // Init config-copy array
+               $this->configCopy = array(
+                       XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS => 'external_address',
+                       XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_INTERNAL_ADDRESS => 'internal_address',
+                       XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_NODE_STATUS      => 'node_status',
+                       XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID       => 'session_id',
+                       XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_PRIVATE_KEY_HASH => 'private_key_hash',
+               );
+
+               // Init array
+               $this->searchData = array(
+                       XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS
+               );
+       }
+
+       /**
+        * Creates an instance of this class
+        *
+        * @return      $handlerInstance        An instance of a HandleableMessage class
+        */
+       public final static function createNodeMessageAnnouncementHandler () {
+               // Get new instance
+               $handlerInstance = new NodeMessageAnnouncementHandler();
+
+               // Return the prepared instance
+               return $handlerInstance;
+       }
+
+       /**
+        * Handles data array of the message
+        *
+        * @param       $messageData            An array with message data to handle
+        * @param       $packageInstance        An instance of a Receivable class
+        * @return      void
+        * @throws      AnnouncementNotAcceptedException        If this node does not accept announcements
+        */
+       public function handleMessageData (array $messageData, Receivable $packageInstance) {
+               // Get node instance
+               $nodeInstance = NodeObjectFactory::createNodeInstance();
+
+               // Is this node accepting announcements?
+               if (!$nodeInstance->isAcceptingAnnouncements()) {
+                       /*
+                        * This node is not accepting announcements, then someone wants to
+                        * announce his node to a non-bootstrap and non-master node.
+                        */
+                       throw new AnnouncementNotAcceptedException(array($this, $nodeInstance, $messageData), BaseHubSystem::EXCEPTION_ANNOUNCEMENT_NOT_ACCEPTED);
+               } // END - if
+
+               // Register the announcing node with this node
+               $this->registerNodeByMessageData($messageData);
+
+               // Prepare answer message to be delivered back to the other node
+               $this->prepareAnswerMessage($messageData, $packageInstance);
+       }
+
+       /**
+        * Adds all required elements from given array into data set instance
+        *
+        * @param       $dataSetInstance        An instance of a StoreableCriteria class
+        * @param       $messageData            An array with all message data
+        * @return      void
+        */
+       public function addArrayToDataSet (StoreableCriteria $dataSetInstance, array $messageData) {
+               // Add generic first
+               parent::addArrayToDataSet($dataSetInstance, $messageData);
+
+               // Add all ements
+               foreach ($this->messageDataElements as $key) {
+                       // Is it there?
+                       assert(isset($messageData[$key]));
+
+                       // Add it
+                       /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('ANNOUNCEMENT-HANDLER: Adding messageData[' . $key . ']=' . $messageData[$key] . ' ...');
+                       $dataSetInstance->addCriteria($key, $messageData[$key]);
+               } // END - foreach
+       }
+
+       /**
+        * Initializes configuration data from given message data array
+        *
+        * @param       $messageData    An array with all message data
+        * @return      void
+        */
+       protected function initMessageConfigurationData (array $messageData) {
+               // Debug message
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('ANNOUNCEMENT-HANDLER: messageData=' . print_r($messageData, TRUE));
+
+               // "Walk" throught the translation array
+               foreach ($this->messageToConfig as $messageKey => $configKey) {
+                       // Debug message
+                       //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('ANNOUNCEMENT-HANDLER: Setting messageKey=' . $messageKey . ',configKey=' . $configKey . ':' . $messageData[$messageKey]);
+
+                       // Set the element in configuration
+                       $this->getConfigInstance()->setConfigEntry($configKey, $messageData[$messageKey]);
+               } // END - foreach
+
+               // "Walk" throught the config-copy array
+               foreach ($this->configCopy as $targetKey => $sourceKey) {
+                       // Debug message
+                       //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('ANNOUNCEMENT-HANDLER: Copying from sourceKey=' . $sourceKey . ' to targetKey=' . $targetKey . '...');
+
+                       // Copy from source to targetKey
+                       $this->getConfigInstance()->setConfigEntry($targetKey, $this->getConfigInstance()->getConfigEntry($sourceKey));
+               } // END - foreach
+
+               // Translate last exception into a status code
+               $statusCode = $this->getTranslatedStatusFromLastException();
+
+               // Set it in configuration (temporarily)
+               $this->getConfigInstance()->setConfigEntry(NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_ANSWER_STATUS, $statusCode);
+       }
+
+       /**
+        * Removes configuration data with given message data array from global
+        * configuration
+        *
+        * @param       $messageData    An array with all message data
+        * @return      void
+        */
+       protected function removeMessageConfigurationData (array $messageData) {
+               // "Walk" throught the translation array again
+               foreach ($this->messageToConfig as $dummy => $configKey) {
+                       // Now unset this configuration entry (to save some memory)
+                       $this->getConfigInstance()->unsetConfigEntry($configKey);
+               } // END - foreach
+
+               // "Walk" throught the config-copy array again
+               foreach ($this->configCopy as $configKey => $dummy) {
+                       // Now unset this configuration entry (to save some memory again)
+                       $this->getConfigInstance()->unsetConfigEntry($configKey);
+               } // END - foreach
+
+               // Remove NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_ANSWER_STATUS as well
+               $this->getConfigInstance()->unsetConfigEntry(NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_ANSWER_STATUS);
+       }
+}
+
+// [EOF]
+?>
diff --git a/application/hub/classes/handler/data/message-types/answer/.htaccess b/application/hub/classes/handler/data/message-types/answer/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/classes/handler/data/message-types/answer/class_NodeMessageAnnouncementAnswerHandler.php b/application/hub/classes/handler/data/message-types/answer/class_NodeMessageAnnouncementAnswerHandler.php
new file mode 100644 (file)
index 0000000..932b647
--- /dev/null
@@ -0,0 +1,179 @@
+<?php
+// Own namespace
+namespace Hub\Handler\Node\Answer\Announcement;
+
+// Import application-specific stuff
+use Hub\Factory\Node\NodeObjectFactory;
+use Hub\Network\Receive\Receivable;
+use Hub\Template\Engine\Xml\Network\Answer\BaseXmlAnswerTemplateEngine;
+
+// Import framework stuff
+use CoreFramework\Criteria\Storing\StoreableCriteria;
+use CoreFramework\Generic\UnsupportedOperationException;
+use CoreFramework\Registry\Registerable;
+
+/**
+ * A NodeMessageAnnouncementAnswer handler
+ *
+ * @author             Roland Haeder <webmaster@shipsimu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.shipsimu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+class NodeMessageAnnouncementAnswerHandler extends BaseMessageHandler implements HandleableMessage, Registerable {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+
+               // Set handler name
+               $this->setHandlerName('message_announcement_answer');
+
+               // Init message data array
+               $this->messageDataElements = array(
+                       XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS,
+                       XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_INTERNAL_ADDRESS,
+                       XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_NODE_STATUS,
+                       XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_NODE_ID,
+                       XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID,
+                       XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_PRIVATE_KEY_HASH,
+                       BaseXmlAnswerTemplateEngine::ANSWER_STATUS,
+               );
+
+               // Init message-data->configuration translation array
+               $this->messageToConfig = array(
+               /*
+                       XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS => 'your_external_address',
+                       XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_INTERNAL_ADDRESS => 'your_internal_address',
+                       XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID       => 'your_session_id'
+                       XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_PRIVATE_KEY_HASH => 'your_private_key_hash'
+               */
+               );
+
+               // Init config-copy array
+               $this->configCopy = array(
+                       XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS => 'external_address',
+                       XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_INTERNAL_ADDRESS => 'internal_address',
+                       XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_NODE_STATUS      => 'node_status',
+                       XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID       => 'session_id',
+                       XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_PRIVATE_KEY_HASH => 'private_key_hash',
+               );
+
+               // Init array
+               $this->searchData = array(
+                       XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID,
+                       XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS,
+               );
+       }
+
+       /**
+        * Creates an instance of this class
+        *
+        * @return      $handlerInstance        An instance of a HandleableMessage class
+        */
+       public final static function createNodeMessageAnnouncementAnswerHandler () {
+               // Get new instance
+               $handlerInstance = new NodeMessageAnnouncementAnswerHandler();
+
+               // Return the prepared instance
+               return $handlerInstance;
+       }
+
+       /**
+        * Handles data array of the message
+        *
+        * @param       $messageData            An array with message data to handle
+        * @param       $packageInstance        An instance of a Receivable class
+        * @return      void
+        * @throws      NoAnnouncementAttemptedException        If this node has not attempted to announce itself
+        */
+       public function handleMessageData (array $messageData, Receivable $packageInstance) {
+               // Get node instance
+               $nodeInstance = NodeObjectFactory::createNodeInstance();
+
+               // Has this node attempted to announce itself?
+               if (!$nodeInstance->ifNodeIsAnnouncing()) {
+                       /*
+                        * This node has never announced itself, so it doesn't expect
+                        * announcement answer messages.
+                        */
+                       throw new NoAnnouncementAttemptedException(array($this, $nodeInstance, $messageData), self::EXCEPTION_ANNOUNCEMENT_NOT_ATTEMPTED);
+               } // END - if
+
+               // Register the announcing node with this node
+               $this->registerNodeByMessageData($messageData);
+
+               // Handle the answer status element
+               $nodeInstance->handleAnswerStatusByMessageData($messageData, $packageInstance);
+       }
+
+       /**
+        * Adds all required elements from given array into data set instance
+        *
+        * @param       $dataSetInstance        An instance of a StoreableCriteria class
+        * @param       $messageData            An array with all message data
+        * @return      void
+        */
+       public function addArrayToDataSet (StoreableCriteria $dataSetInstance, array $messageData) {
+               // Add generic first
+               parent::addArrayToDataSet($dataSetInstance, $messageData);
+
+               // Add all ements
+               foreach ($this->messageDataElements as $key) {
+                       // Is it there?
+                       assert(isset($messageData[$key]));
+
+                       /*
+                        * Add it, but remove any 'my-' prefixes as they are not used in
+                        * database layer.
+                        */
+                       $dataSetInstance->addCriteria(str_replace('my-', '', $key), $messageData[$key]);
+               } // END - foreach
+       }
+
+       /**
+        * Initializes configuration data from given message data array
+        *
+        * @param       $messageData    An array with all message data
+        * @return      void
+        * @throws      UnsupportedOperationException   If this method is called
+        */
+       protected function initMessageConfigurationData (array $messageData) {
+               // Please don't call this method
+               throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
+       }
+
+       /**
+        * Removes configuration data with given message data array from global
+        * configuration
+        *
+        * @param       $messageData    An array with all message data
+        * @return      void
+        * @throws      UnsupportedOperationException   If this method is called
+        */
+       protected function removeMessageConfigurationData (array $messageData) {
+               // Please don't call this method
+               throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
+       }
+}
+
+// [EOF]
+?>
diff --git a/application/hub/classes/handler/data/message-types/answer/class_NodeMessageDhtBootstrapAnswerHandler.php b/application/hub/classes/handler/data/message-types/answer/class_NodeMessageDhtBootstrapAnswerHandler.php
new file mode 100644 (file)
index 0000000..e47c57a
--- /dev/null
@@ -0,0 +1,175 @@
+<?php
+// Own namespace
+namespace Hub\Handler\Answer\Node\DhtBootstrap;
+
+// Import application-specific stuff
+use Hub\Factory\Dht\DhtObjectFactory;
+use Hub\Network\Receive\Receivable;
+use Hub\Template\Engine\Xml\Dht\Bootstrap\XmlDhtBootstrapTemplateEngine;
+use Hub\Template\Engine\Xml\Network\Answer\BaseXmlAnswerTemplateEngine;
+
+// Import framework stuff
+use CoreFramework\Criteria\Storing\StoreableCriteria;
+use CoreFramework\Generic\UnsupportedOperationException;
+use CoreFramework\Registry\Registerable;
+
+/**
+ * A NodeMessageDhtBootstrapAnswer handler
+ *
+ * @author             Roland Haeder <webmaster@shipsimu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.shipsimu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+class NodeMessageDhtBootstrapAnswerHandler extends BaseMessageHandler implements HandleableMessage, Registerable {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+
+               // Set handler name
+               $this->setHandlerName('message_announcement_answer');
+
+               // Init message data array
+               $this->messageDataElements = array(
+                       XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_EXTERNAL_ADDRESS,
+                       XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_INTERNAL_ADDRESS,
+                       XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_NODE_STATUS,
+                       XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_SESSION_ID,
+                       BaseXmlAnswerTemplateEngine::ANSWER_STATUS,
+               );
+
+               // Init message-data->configuration translation array
+               $this->messageToConfig = array(
+               /*
+                       @TODO Why commented out?
+                       XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_EXTERNAL_ADDRESS => 'your_external_address',
+                       XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_INTERNAL_ADDRESS => 'your_internal_address',
+                       XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_SESSION_ID       => 'your_session_id'
+               */
+               );
+
+               // Init config-copy array
+               $this->configCopy = array(
+                       XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_EXTERNAL_ADDRESS => 'external_address',
+                       XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_INTERNAL_ADDRESS => 'internal_address',
+                       XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_NODE_STATUS      => 'node_status',
+                       XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_SESSION_ID       => 'session_id',
+               );
+
+               // Init array
+               $this->searchData = array(
+                       XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_SESSION_ID,
+                       XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_EXTERNAL_ADDRESS,
+               );
+       }
+
+       /**
+        * Creates an instance of this class
+        *
+        * @return      $handlerInstance        An instance of a HandleableMessage class
+        */
+       public final static function createNodeMessageDhtBootstrapAnswerHandler () {
+               // Get new instance
+               $handlerInstance = new NodeMessageDhtBootstrapAnswerHandler();
+
+               // Return the prepared instance
+               return $handlerInstance;
+       }
+
+       /**
+        * Handles data array of the message
+        *
+        * @param       $messageData            An array with message data to handle
+        * @param       $packageInstance        An instance of a Receivable class
+        * @return      void
+        * @throws      NoDhtBootstrapAttemptedException        If this DHT has not attempted to bootstrap
+        * @todo        ~30% done
+        */
+       public function handleMessageData (array $messageData, Receivable $packageInstance) {
+               // Get DHT instance
+               $dhtInstance = DhtObjectFactory::createDhtInstance('node');
+
+               // Has this DHT attempted to bootstrap?
+               if (!$dhtInstance->ifDhtIsBooting()) {
+                       /*
+                        * This DHT has never bootstrapped, so it doesn't expect
+                        * announcement answer messages.
+                        */
+                       throw new NoDhtBootstrapAttemptedException(array($this, $dhtInstance, $messageData), self::EXCEPTION_DHT_BOOTSTRAP_NOT_ATTEMPTED);
+               } // END - if
+
+               // Unfinished
+               $this->partialStub('UNHANDLED: messageData=' . print_r($messageData, TRUE));
+       }
+
+       /**
+        * Adds all required elements from given array into data set instance
+        *
+        * @param       $dataSetInstance        An instance of a StoreableCriteria class
+        * @param       $messageData            An array with all message data
+        * @return      void
+        */
+       public function addArrayToDataSet (StoreableCriteria $dataSetInstance, array $messageData) {
+               // Add generic first
+               parent::addArrayToDataSet($dataSetInstance, $messageData);
+
+               // Add all ements
+               foreach ($this->messageDataElements as $key) {
+                       // Is it there?
+                       assert(isset($messageData[$key]));
+
+                       /*
+                        * Add it, but remove any 'my-' prefixes as they are not used in
+                        * database layer.
+                        */
+                       $dataSetInstance->addCriteria(str_replace('my-', '', $key), $messageData[$key]);
+               } // END - foreach
+       }
+
+       /**
+        * Initializes configuration data from given message data array
+        *
+        * @param       $messageData    An array with all message data
+        * @return      void
+        * @throws      UnsupportedOperationException   If this method is called
+        */
+       protected function initMessageConfigurationData (array $messageData) {
+               // Please don't call this method
+               throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
+       }
+
+       /**
+        * Removes configuration data with given message data array from global
+        * configuration
+        *
+        * @param       $messageData    An array with all message data
+        * @return      void
+        * @throws      UnsupportedOperationException   If this method is called
+        */
+       protected function removeMessageConfigurationData (array $messageData) {
+               // Please don't call this method
+               throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
+       }
+}
+
+// [EOF]
+?>
diff --git a/application/hub/classes/handler/data/message-types/answer/class_NodeMessageRequestNodeListAnswerHandler.php b/application/hub/classes/handler/data/message-types/answer/class_NodeMessageRequestNodeListAnswerHandler.php
new file mode 100644 (file)
index 0000000..f2a4aa3
--- /dev/null
@@ -0,0 +1,168 @@
+<?php
+// Own namespace
+namespace Hub\Handler\Node\Answer\Request\NodeList;
+
+// Import application-specific stuff
+use Hub\Factory\Node\NodeObjectFactory;
+use Hub\Network\Receive\Receivable;
+use Hub\Template\Engine\Xml\Network\Answer\BaseXmlAnswerTemplateEngine;
+
+// Import framework stuff
+use CoreFramework\Criteria\Storing\StoreableCriteria;
+use CoreFramework\Generic\UnsupportedOperationException;
+use CoreFramework\Registry\Registerable;
+
+/**
+ * A NodeMessageRequestNodeListAnswer handler
+ *
+ * @author             Roland Haeder <webmaster@shipsimu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.shipsimu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+class NodeMessageRequestNodeListAnswerHandler extends BaseMessageHandler implements HandleableMessage, Registerable {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+
+               // Set handler name
+               $this->setHandlerName('message_request_node_list_answer');
+
+               // Init message data array
+               $this->messageDataElements = array(
+                       XmlRequestNodeListAnswerTemplateEngine::REQUEST_DATA_SESSION_ID,
+                       XmlRequestNodeListAnswerTemplateEngine::REQUEST_DATA_NODE_LIST,
+                       BaseXmlAnswerTemplateEngine::ANSWER_STATUS,
+               );
+
+               // Init message-data->configuration translation array
+               $this->messageToConfig = array(
+               /*
+                       XmlRequestNodeListTemplateEngine::REQUEST_DATA_SESSION_ID  => 'your_session_id'
+               */
+               );
+
+               // Init search data array
+               $this->searchData = array(
+                       XmlRequestNodeListAnswerTemplateEngine::REQUEST_DATA_SESSION_ID,
+               );
+       }
+
+       /**
+        * Creates an instance of this class
+        *
+        * @return      $handlerInstance        An instance of a HandleableMessage class
+        */
+       public final static function createNodeMessageRequestNodeListAnswerHandler () {
+               // Get new instance
+               $handlerInstance = new NodeMessageRequestNodeListAnswerHandler();
+
+               // Return the prepared instance
+               return $handlerInstance;
+       }
+
+       /**
+        * Handles data array of the message
+        *
+        * @param       $messageData            An array with message data to handle
+        * @param       $packageInstance        An instance of a Receivable class
+        * @return      void
+        * @throws      NoRequestNodeListAttemptedException     If this node has not attempted to announce itself
+        */
+       public function handleMessageData (array $messageData, Receivable $packageInstance) {
+               // Get node instance
+               $nodeInstance = NodeObjectFactory::createNodeInstance();
+
+               // Has this node attempted to announce itself?
+               if (!$nodeInstance->ifNodeHasAnnouncementCompleted()) {
+                       /*
+                        * This node has never announced itself, so it doesn't expect
+                        * request-node-list answer messages.
+                        */
+                       throw new NoRequestNodeListAttemptedException(array($this, $nodeInstance, $messageData), self::EXCEPTION_ANNOUNCEMENT_NOT_ATTEMPTED);
+               } // END - if
+
+               // Register the announcing node with this node
+               $this->registerNodeByMessageData($messageData);
+
+               // Handle the answer status element
+               $nodeInstance->handleAnswerStatusByMessageData($messageData, $packageInstance);
+       }
+
+       /**
+        * Adds all required elements from given array into data set instance
+        *
+        * @param       $dataSetInstance        An instance of a StoreableCriteria class
+        * @param       $messageData            An array with all message data
+        * @return      void
+        */
+       public function addArrayToDataSet (StoreableCriteria $dataSetInstance, array $messageData) {
+               // Add generic first
+               parent::addArrayToDataSet($dataSetInstance, $messageData);
+
+               // Debug message
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('ANSWER-HANDLER: messageData=' . print_r($messageData, TRUE));
+
+               // Add all ements
+               foreach ($this->messageDataElements as $key) {
+                       // Debug message
+                       //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('ANSWER-HANDLER: messageData[' . $key . ']=' . $messageData[$key]);
+
+                       // Is it there?
+                       assert(isset($messageData[$key]));
+
+                       /*
+                        * Add it, but remove any 'my-' prefixes as they are not used in
+                        * database layer.
+                        */
+                       $dataSetInstance->addCriteria(str_replace('my-', '', $key), $messageData[$key]);
+               } // END - foreach
+       }
+
+       /**
+        * Initializes configuration data from given message data array
+        *
+        * @param       $messageData    An array with all message data
+        * @return      void
+        * @throws      UnsupportedOperationException   If this method is called
+        */
+       protected function initMessageConfigurationData (array $messageData) {
+               // Please don't call this method
+               throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
+       }
+
+       /**
+        * Removes configuration data with given message data array from global
+        * configuration
+        *
+        * @param       $messageData    An array with all message data
+        * @return      void
+        * @throws      UnsupportedOperationException   If this method is called
+        */
+       protected function removeMessageConfigurationData (array $messageData) {
+               // Please don't call this method
+               throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
+       }
+}
+
+// [EOF]
+?>
diff --git a/application/hub/classes/handler/data/message-types/class_ b/application/hub/classes/handler/data/message-types/class_
new file mode 100644 (file)
index 0000000..0a4077e
--- /dev/null
@@ -0,0 +1,121 @@
+<?php
+// Own namespace
+namespace Hub\Handler\Message\;
+
+// Import framework stuff
+use CoreFramework\Criteria\Storing\StoreableCriteria;
+
+/**
+ * A NodeMessage??? handler
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+class NodeMessage???Handler extends BaseMessageHandler implements HandleableMessage, Registerable {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+
+               // Set handler name
+               $this->setHandlerName('message_===');
+
+               // Init message data array
+               $this->messageDataElements = array(
+                       Xml???TemplateEngine::!!!_DATA_EXTERNAL_ADDRESS,
+                       Xml???TemplateEngine::!!!_DATA_NODE_STATUS,
+                       Xml???TemplateEngine::!!!_DATA_SESSION_ID,
+                       Xml???TemplateEngine::!!!_DATA_LISTEN_PORT,
+               );
+       }
+
+       /**
+        * Creates an instance of this class
+        *
+        * @return      $handlerInstance        An instance of a HandleableMessage class
+        */
+       public final static function createNodeMessage???Handler () {
+               // Get new instance
+               $handlerInstance = new NodeMessage???Handler();
+
+               // Return the prepared instance
+               return $handlerInstance;
+       }
+
+       /**
+        * Handles data array of the message
+        *
+        * @param       $messageData            An array with message data to handle
+        * @param       $packageInstance        An instance of a Receivable class
+        * @return      void
+        */
+       public function handleMessageData (array $messageData, Receivable $packageInstance) {
+               // Register the announcing node with this node
+               $this->registerNodeByMessageData($messageData);
+
+               // Prepare answer message to be delivered back to the other node
+               $this->prepareAnswerMessage($messageData, $packageInstance);
+       }
+
+       /**
+        * Adds all required elements from given array into data set instance
+        *
+        * @param       $dataSetInstance        An instance of a StoreableCriteria class
+        * @param       $messageData            An array with all message data
+        * @return      void
+        */
+       public function addArrayToDataSet (StoreableCriteria $dataSetInstance, array $messageData) {
+               // Add all ements
+               foreach ($this->messageDataElements as $key) {
+                       // Is it there?
+                       assert(isset($messageData[$key]));
+
+                       // Add it
+                       $dataSetInstance->addCriteria($key, $messageData[$key]);
+               } // END - foreach
+       }
+
+       /**
+        * Initializes configuration data from given message data array
+        *
+        * @param       $messageData    An array with all message data
+        * @return      void
+        */
+       protected function initMessageConfigurationData (array $messageData) {
+               $this->partialStub('Please implement this method.');
+       }
+
+       /**
+        * Removes configuration data with given message data array from global
+        * configuration
+        *
+        * @param       $messageData    An array with all message data
+        * @return      void
+        */
+       protected function removeMessageConfigurationData (array $messageData) {
+               $this->partialStub('Please implement this method.');
+       }
+}
+
+// [EOF]
+?>
diff --git a/application/hub/classes/handler/data/message-types/class_BaseMessageHandler.php b/application/hub/classes/handler/data/message-types/class_BaseMessageHandler.php
new file mode 100644 (file)
index 0000000..4d55637
--- /dev/null
@@ -0,0 +1,101 @@
+<?php
+// Own namespace
+namespace Hub\Handler\Message;
+
+// Import hub-specific stuff
+use Hub\Factory\Dht\DhtObjectFactory;
+use Hub\Generic\BaseHubSystem;
+use Hub\Network\Receive\Receivable;
+
+// Import framework stuff
+use CoreFramework\Generic\FrameworkException;
+
+/**
+ * A general message handler, this class must be abstract to make the template
+ * method pattern working.
+ *
+ * @author             Roland Haeder <webmaster@shipsimu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.shipsimu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+abstract class BaseMessageHandler extends BaseDataHandler {
+       /**
+        * Protected constructor
+        *
+        * @param       $className      Name of the class
+        * @return      void
+        */
+       protected function __construct ($className) {
+               // Call parent constructor
+               parent::__construct($className);
+       }
+
+       /**
+        * "Getter" for a translated last exception as a status code
+        *
+        * @return      $statusCode             Translated status code from last exception
+        */
+       protected function getTranslatedStatusFromLastException () {
+               // Default is all fine
+               $statusCode = BaseHubSystem::MESSAGE_STATUS_CODE_OKAY;
+
+               // Is the last exception not NULL?
+               if ($this->getLastException() instanceof FrameworkException) {
+                       // "Determine" the right status code (may differ from exception to exception)
+                       $this->debugInstance(sprintf('[%s:%d]: lastException=%s,message=%s is unfinished.', __METHOD__, __LINE__, $this->getLastException()->__toString(), $this->getLastException()->getMessage()));
+               } // END - if
+
+               // Return the status code
+               return $statusCode;
+       }
+
+       /**
+        * Registers an other node with this node by given message data. The
+        * following data must always be present:
+        *
+        * - session-id  (for finding the node's record together with below data)
+        * - external-address (hostname or IP number)
+        * - listen-port (TCP/UDP listen port for inbound connections)
+        *
+        * @param       $messageArray   An array with all minimum message data
+        * @return      void
+        */
+       protected function registerNodeByMessageData (array $messageData) {
+               // Check if searchData has entries
+               assert(count($this->getSearchData()) > 0);
+
+               // Let the DHT facade do the work
+               DhtObjectFactory::createDhtInstance('node')->registerNodeByMessageData($messageData, $this);
+       }
+
+       /**
+        * Posty-handles data array of the message
+        *
+        * @param       $messageData            An array with message data to handle
+        * @param       $packageInstance        An instance of a Receivable class
+        * @return      void
+        */
+       public function postHandleMessageData (array $messageData, Receivable $packageInstance) {
+               /*
+                * Feed hash to miner by handling over the whole array as also the
+                * sender and tags are needed.
+                */
+               $packageInstance->feedHashToMiner($messageData);
+       }
+
+}
diff --git a/application/hub/classes/handler/data/message-types/dht/.htaccess b/application/hub/classes/handler/data/message-types/dht/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/classes/handler/data/message-types/dht/class_NodeMessageDhtBootstrapHandler.php b/application/hub/classes/handler/data/message-types/dht/class_NodeMessageDhtBootstrapHandler.php
new file mode 100644 (file)
index 0000000..dfaa234
--- /dev/null
@@ -0,0 +1,215 @@
+<?php
+// Own namespace
+namespace Hub\Handler\Node\Answer\Dht\Bootstrap;
+
+// Import application-specific stuff
+use Hub\Database\Frontend\Node\Dht\NodeDistributedHashTableDatabaseWrapper;
+use Hub\Factory\Dht\DhtObjectFactory;
+use Hub\Factory\Node\NodeObjectFactory;
+use Hub\Network\Receive\Receivable;
+use Hub\Template\Engine\Xml\Dht\Bootstrap\XmlDhtBootstrapTemplateEngine;
+
+// Import framework stuff
+use CoreFramework\Criteria\Storing\StoreableCriteria;
+use CoreFramework\Registry\Registerable;
+
+/**
+ * A NodeMessageDhtBootstrap handler
+ *
+ * @author             Roland Haeder <webmaster@shipsimu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.shipsimu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+class NodeMessageDhtBootstrapHandler extends BaseMessageHandler implements HandleableMessage, Registerable {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+
+               // Set handler name
+               $this->setHandlerName('message_dht_bootstrap');
+
+               // Init message data array
+               $this->messageDataElements = array(
+                       XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_EXTERNAL_ADDRESS,
+                       XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_INTERNAL_ADDRESS,
+                       XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_NODE_STATUS,
+                       XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_NODE_MODE,
+                       XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_SESSION_ID,
+               );
+
+               // Init message-data->configuration translation array
+               $this->messageToConfig = array(
+                       XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_EXTERNAL_ADDRESS => 'your_external_address',
+                       XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_INTERNAL_ADDRESS => 'your_internal_address',
+                       XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_SESSION_ID       => 'your_session_id'
+               );
+
+               // Init config-copy array
+               $this->configCopy = array(
+                       XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_EXTERNAL_ADDRESS => 'external_address',
+                       XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_INTERNAL_ADDRESS => 'internal_address',
+                       XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_NODE_STATUS      => 'node_status',
+                       XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_SESSION_ID       => 'session_id',
+               );
+
+               // Init array
+               $this->searchData = array(
+                       XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_EXTERNAL_ADDRESS,
+               );
+       }
+
+       /**
+        * Creates an instance of this class
+        *
+        * @return      $handlerInstance        An instance of a HandleableMessage class
+        */
+       public final static function createNodeMessageDhtBootstrapHandler () {
+               // Get new instance
+               $handlerInstance = new NodeMessageDhtBootstrapHandler();
+
+               // Return the prepared instance
+               return $handlerInstance;
+       }
+
+       /**
+        * Handles data array of the message
+        *
+        * @param       $messageData            An array with message data to handle
+        * @param       $packageInstance        An instance of a Receivable class
+        * @return      void
+        * @throws      DhtBootstrapNotAcceptedException        If this node does not accept DHT bootstrap requests
+        */
+       public function handleMessageData (array $messageData, Receivable $packageInstance) {
+               // Is this node accepting DHT bootstrap requests?
+               if (!NodeObjectFactory::createNodeInstance()->isAcceptingDhtBootstrap()) {
+                       /*
+                        * This node is not accepting DHT bootstrap requests.
+                        */
+                       throw new DhtBootstrapNotAcceptedException(array($this, $messageData), self::EXCEPTION_DHT_BOOTSTRAP_NOT_ACCEPTED);
+               } // END - if
+
+               // Register the DHT bootstrap requesting node with this node
+               $this->registerNodeByMessageData($messageData);
+
+               // Prepare answer message to be delivered back to the other node
+               $this->prepareAnswerMessage($messageData, $packageInstance);
+       }
+
+       /**
+        * Adds all required elements from given array into data set instance
+        *
+        * @param       $dataSetInstance        An instance of a StoreableCriteria class
+        * @param       $messageData            An array with all message data
+        * @return      void
+        */
+       public function addArrayToDataSet (StoreableCriteria $dataSetInstance, array $messageData) {
+               // Add generic first
+               parent::addArrayToDataSet($dataSetInstance, $messageData);
+
+               // Add all ements
+               foreach ($this->messageDataElements as $key) {
+                       // Is it there?
+                       assert(isset($messageData[$key]));
+
+                       // Add it
+                       $dataSetInstance->addCriteria($key, $messageData[$key]);
+               } // END - foreach
+       }
+
+       /**
+        * Initializes configuration data from given message data array
+        *
+        * @param       $messageData    An array with all message data
+        * @return      void
+        */
+       protected function initMessageConfigurationData (array $messageData) {
+               // Debug message
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-BOOTSTRAP-HANDLER: messageData=' . print_r($messageData, TRUE));
+
+               // "Walk" throught the translation array
+               foreach ($this->messageToConfig as $messageKey => $configKey) {
+                       // Debug message
+                       //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-BOOTSTRAP-HANDLER: Setting messageKey=' . $messageKey . ',configKey=' . $configKey . ':' . $messageData[$messageKey]);
+
+                       // Set the element in configuration
+                       $this->getConfigInstance()->setConfigEntry($configKey, $messageData[$messageKey]);
+               } // END - foreach
+
+               // "Walk" throught the config-copy array
+               foreach ($this->configCopy as $targetKey => $sourceKey) {
+                       // Debug message
+                       //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-BOOTSTRAP-HANDLER: Copying from sourceKey=' . $sourceKey . ' to targetKey=' . $targetKey . '...');
+
+                       // Copy from source to target key
+                       $this->getConfigInstance()->setConfigEntry($targetKey, $this->getConfigInstance()->getConfigEntry($sourceKey));
+               } // END - foreach
+
+               // Translate last exception into a status code
+               $statusCode = $this->getTranslatedStatusFromLastException();
+
+               // Set it in configuration (temporarily)
+               $this->getConfigInstance()->setConfigEntry(NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_ANSWER_STATUS, $statusCode);
+
+               /*
+                * Use the DHT instance to get a list of recipients. This means that all
+                * DHT nodes that accept bootstrap requests are read from the DHT
+                * database.
+                */
+               $nodeList = DhtObjectFactory::createDhtInstance('node')->findRecipientsByKey(NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_ACCEPT_BOOTSTRAP, 'Y');
+
+               // Make sure it is an array and has at least one entry
+               assert(is_array($nodeList));
+               assert(count($nodeList) > 0);
+
+               // Set it in configuration
+               $this->getConfigInstance()->setConfigEntry('dht_nodes', base64_encode(json_encode($nodeList)));
+       }
+
+       /**
+        * Removes configuration data with given message data array from global
+        * configuration
+        *
+        * @param       $messageData    An array with all message data
+        * @return      void
+        */
+       protected function removeMessageConfigurationData (array $messageData) {
+               // "Walk" throught the translation array again
+               foreach ($this->messageToConfig as $dummy => $configKey) {
+                       // Now unset this configuration entry (to save some memory)
+                       $this->getConfigInstance()->unsetConfigEntry($configKey);
+               } // END - foreach
+
+               // "Walk" throught the config-copy array again
+               foreach ($this->configCopy as $configKey => $dummy) {
+                       // Now unset this configuration entry (to save some memory again)
+                       $this->getConfigInstance()->unsetConfigEntry($configKey);
+               } // END - foreach
+
+               // Remove temporary "special" values as well
+               $this->getConfigInstance()->unsetConfigEntry(NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_ANSWER_STATUS);
+               $this->getConfigInstance()->unsetConfigEntry('dht_nodes');
+       }
+}
+
+// [EOF]
+?>
diff --git a/application/hub/classes/handler/data/message-types/requests/.htaccess b/application/hub/classes/handler/data/message-types/requests/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/classes/handler/data/message-types/requests/class_NodeMessageRequestNodeListHandler.php b/application/hub/classes/handler/data/message-types/requests/class_NodeMessageRequestNodeListHandler.php
new file mode 100644 (file)
index 0000000..e74527a
--- /dev/null
@@ -0,0 +1,190 @@
+<?php
+// Own namespace
+namespace Hub\Handler\Node\Message\Request\NodeList;
+
+// Import application-specific stuff
+use Hub\Database\Frontend\Node\Dht\NodeDistributedHashTableDatabaseWrapper;
+use Hub\Factory\Dht\DhtObjectFactory;
+use Hub\Factory\Node\NodeObjectFactory;
+use Hub\Network\Receive\Receivable;
+use Hub\Node\BaseHubNode;
+
+// Import framework stuff
+use CoreFramework\Criteria\Storing\StoreableCriteria;
+use CoreFramework\Registry\Registerable;
+
+/**
+ * A NodeMessageRequestNodeList handler
+ *
+ * @author             Roland Haeder <webmaster@shipsimu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.shipsimu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+class NodeMessageRequestNodeListHandler extends BaseMessageHandler implements HandleableMessage, Registerable {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+
+               // Set handler name
+               $this->setHandlerName('message_request_node_list');
+
+               // Init message data array
+               $this->messageDataElements = array(
+                       XmlRequestNodeListTemplateEngine::REQUEST_DATA_ACCEPTED_OBJECT_TYPES,
+               );
+
+               // Init config-copy array
+               $this->configCopy = array(
+               );
+
+               // Init search data array
+               $this->searchData = array(
+                       XmlRequestNodeListTemplateEngine::REQUEST_DATA_SESSION_ID,
+               );
+       }
+
+       /**
+        * Creates an instance of this class
+        *
+        * @return      $handlerInstance        An instance of a HandleableMessage class
+        */
+       public final static function createNodeMessageRequestNodeListHandler () {
+               // Get new instance
+               $handlerInstance = new NodeMessageRequestNodeListHandler();
+
+               // Return the prepared instance
+               return $handlerInstance;
+       }
+
+       /**
+        * Handles data array of the message
+        *
+        * @param       $messageData            An array with message data to handle
+        * @param       $packageInstance        An instance of a Receivable class
+        * @return      void
+        * @throws      RequestNotAcceptedException             If this node does not accept this request
+        */
+       public function handleMessageData (array $messageData, Receivable $packageInstance) {
+               // Get node instance
+               $nodeInstance = NodeObjectFactory::createNodeInstance();
+
+               // Is this node accepting announcements?
+               if (!$nodeInstance->isAcceptingNodeListRequests()) {
+                       /*
+                        * This node is not accepting node list requests. Throw an
+                        * exception to abort any further processing.
+                        */
+                       throw new RequestNotAcceptedException(array($this, $nodeInstance, $messageData), self::EXCEPTION_REQUEST_NOT_ACCEPTED);
+               } // END - if
+
+               // Register the announcing node with this node
+               $this->registerNodeByMessageData($messageData);
+
+               // Prepare answer message to be delivered back to the other node
+               $this->prepareAnswerMessage($messageData, $packageInstance);
+       }
+
+       /**
+        * Adds all required elements from given array into data set instance
+        *
+        * @param       $dataSetInstance        An instance of a StoreableCriteria class
+        * @param       $messageData            An array with all message data
+        * @return      void
+        */
+       public function addArrayToDataSet (StoreableCriteria $dataSetInstance, array $messageData) {
+               // Add generic first
+               parent::addArrayToDataSet($dataSetInstance, $messageData);
+
+               // Add all ements
+               foreach ($this->messageDataElements as $key) {
+                       // Is it there?
+                       assert(isset($messageData[$key]));
+
+                       // Add it
+                       $dataSetInstance->addCriteria($key, $messageData[$key]);
+               } // END - foreach
+       }
+
+       /**
+        * Initializes configuration data from given message data array
+        *
+        * @param       $messageData    An array with all message data
+        * @return      void
+        */
+       protected function initMessageConfigurationData (array $messageData) {
+               // Debug message
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('REQUEST-HANDLER: messageData=' . print_r($messageData, TRUE));
+
+               // "Walk" throught the config-copy array
+               foreach ($this->configCopy as $targetKey => $sourceKey) {
+                       // Debug message
+                       //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('REQUEST-HANDLER: Copying from sourceKey=' . $sourceKey . ' to targetKey=' . $targetKey . '...');
+
+                       // Copy from source to targetKey
+                       $this->getConfigInstance()->setConfigEntry($targetKey, $this->getConfigInstance()->getConfigEntry($sourceKey));
+               } // END - foreach
+
+               // Query local DHT for nodes except given session id
+               $nodeList = DhtObjectFactory::createDhtInstance('node')->queryLocalNodeListExceptByMessageData(
+                       $messageData,
+                       $this,
+                       XmlRequestNodeListTemplateEngine::REQUEST_DATA_SESSION_ID,
+                       XmlRequestNodeListTemplateEngine::REQUEST_DATA_ACCEPTED_OBJECT_TYPES,
+                       BaseHubNode::OBJECT_LIST_SEPARATOR
+               );
+
+               // Debug message
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('REQUEST-HANDLER: Got a node list of ' . count($nodeList) . ' entry/-ies back.');
+
+               // Set it serialized in configuration (temporarily)
+               $this->getConfigInstance()->setConfigEntry('node_list', base64_encode(json_encode($nodeList)));
+
+               // Translate last exception into a status code
+               $statusCode = $this->getTranslatedStatusFromLastException();
+
+               // Set it in configuration (temporarily)
+               $this->getConfigInstance()->setConfigEntry(NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_ANSWER_STATUS, $statusCode);
+       }
+
+       /**
+        * Removes configuration data with given message data array from global
+        * configuration
+        *
+        * @param       $messageData    An array with all message data
+        * @return      void
+        */
+       protected function removeMessageConfigurationData (array $messageData) {
+               // "Walk" throught the config-copy array again
+               foreach ($this->configCopy as $configKey => $dummy) {
+                       // Now unset this configuration entry (to save some memory again)
+                       $this->getConfigInstance()->unsetConfigEntry($configKey);
+               } // END - foreach
+
+               // Remove answer status/node list as well
+               $this->getConfigInstance()->unsetConfigEntry(NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_ANSWER_STATUS);
+               $this->getConfigInstance()->unsetConfigEntry('node_list');
+       }
+}
+
+// [EOF]
+?>
diff --git a/application/hub/classes/handler/data/message-types/self-connect/.htaccess b/application/hub/classes/handler/data/message-types/self-connect/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/classes/handler/data/message-types/self-connect/class_NodeMessageSelfConnectHandler.php b/application/hub/classes/handler/data/message-types/self-connect/class_NodeMessageSelfConnectHandler.php
new file mode 100644 (file)
index 0000000..b485f7b
--- /dev/null
@@ -0,0 +1,130 @@
+<?php
+// Own namespace
+namespace Hub\Handler\Node\Message\SelfConnect;
+
+// Import application-specific stuff
+use Hub\Factory\Node\NodeObjectFactory;
+use Hub\Network\Receive\Receivable;
+
+// Import framework stuff
+use CoreFramework\Criteria\Storing\StoreableCriteria;
+use CoreFramework\Generic\UnsupportedOperationException;
+use CoreFramework\Registry\Registerable;
+
+/**
+ * A NodeMessageSelfConnect handler
+ *
+ * @author             Roland Haeder <webmaster@shipsimu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.shipsimu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+class NodeMessageSelfConnectHandler extends BaseMessageHandler implements HandleableMessage, Registerable {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+
+               // Set handler name
+               $this->setHandlerName('message_self_connect');
+       }
+
+       /**
+        * Creates an instance of this class
+        *
+        * @return      $handlerInstance        An instance of a HandleableMessage class
+        */
+       public final static function createNodeMessageSelfConnectHandler () {
+               // Get new instance
+               $handlerInstance = new NodeMessageSelfConnectHandler();
+
+               // Return the prepared instance
+               return $handlerInstance;
+       }
+
+       /**
+        * Handles data array of the message
+        *
+        * @param       $messageData            An array with message data to handle
+        * @param       $packageInstance        An instance of a Receivable class
+        * @return      void
+        */
+       public function handleMessageData (array $messageData, Receivable $packageInstance) {
+               // Get node instance
+               $nodeInstance = NodeObjectFactory::createNodeInstance();
+
+               // Are node id and session id the same?
+               if (($messageData[XmlSelfConnectTemplateEngine::SELF_CONNECT_DATA_NODE_ID] == $nodeInstance->getNodeId()) && ($messageData[XmlSelfConnectTemplateEngine::SELF_CONNECT_DATA_SESSION_ID] == $nodeInstance->getSessionId())) {
+                       // Both are equal
+                       self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SELF-CONNECT: Have connected to myself, both node and session id are equal!');
+
+                       // ... and change state
+                       $nodeInstance->getStateInstance()->nodeHasSelfConnected();
+               } else {
+                       // Something really horrible happened
+                       // @TODO Throw an exception here instead of dying
+                       $this->debugInstance(sprintf('[%s:%d]: ids mismatching! messageData=%s', __METHOD__, __LINE__, print_r($messageData, TRUE)));
+               }
+       }
+
+       /**
+        * Adds all required elements from given array into data set instance
+        *
+        * @param       $dataSetInstance        An instance of a StoreableCriteria class
+        * @param       $messageData            An array with all message data
+        * @return      void
+        * @throws      UnsupportedOperationException   If this method is called
+        */
+       public function addArrayToDataSet (StoreableCriteria $dataSetInstance, array $messageData) {
+               // Add generic first
+               parent::addArrayToDataSet($dataSetInstance, $messageData);
+
+               // Please don't call this method!
+               throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
+       }
+
+       /**
+        * Initializes configuration data from given message data array
+        *
+        * @param       $messageData    An array with all message data
+        * @return      void
+        * @throws      UnsupportedOperationException   If this method is called
+        */
+       protected function initMessageConfigurationData (array $messageData) {
+               // Please don't call this method!
+               throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
+       }
+
+       /**
+        * Removes configuration data with given message data array from global configuration
+        *
+        * @param       $messageData    An array with all message data
+        * @return      void
+        * @throws      UnsupportedOperationException   If this method is called
+        */
+       protected function removeMessageConfigurationData (array $messageData) {
+               // Please don't call this method!
+               throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
+       }
+}
+
+// [EOF]
+?>
diff --git a/application/hub/classes/handler/message-types/.htaccess b/application/hub/classes/handler/message-types/.htaccess
deleted file mode 100644 (file)
index 3a42882..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Deny from all
diff --git a/application/hub/classes/handler/message-types/announcement/.htaccess b/application/hub/classes/handler/message-types/announcement/.htaccess
deleted file mode 100644 (file)
index 3a42882..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Deny from all
diff --git a/application/hub/classes/handler/message-types/announcement/class_NodeMessageAnnouncementHandler.php b/application/hub/classes/handler/message-types/announcement/class_NodeMessageAnnouncementHandler.php
deleted file mode 100644 (file)
index 1882fb2..0000000
+++ /dev/null
@@ -1,209 +0,0 @@
-<?php
-// Own namespace
-namespace Hub\Handler\Node\Message\Announcement;
-
-// Import application-specific stuff
-use Hub\Database\Frontend\Node\Dht\NodeDistributedHashTableDatabaseWrapper;
-use Hub\Factory\Node\NodeObjectFactory;
-use Hub\Generic\BaseHubSystem;
-use Hub\Network\Receive\Receivable;
-
-// Import framework stuff
-use CoreFramework\Criteria\Storing\StoreableCriteria;
-use CoreFramework\Registry\Registerable;
-
-/**
- * A NodeMessageAnnouncement handler
- *
- * @author             Roland Haeder <webmaster@shipsimu.org>
- * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team
- * @license            GNU GPL 3.0 or any newer version
- * @link               http://www.shipsimu.org
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-class NodeMessageAnnouncementHandler extends BaseMessageHandler implements HandleableMessage, Registerable {
-       /**
-        * Protected constructor
-        *
-        * @return      void
-        */
-       protected function __construct () {
-               // Call parent constructor
-               parent::__construct(__CLASS__);
-
-               // Set handler name
-               $this->setHandlerName('message_announcement');
-
-               // Init message data array
-               $this->messageDataElements = array(
-                       XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS,
-                       XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_INTERNAL_ADDRESS,
-                       XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_NODE_STATUS,
-                       XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_NODE_MODE,
-                       XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_NODE_ID,
-                       XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID,
-                       XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_PRIVATE_KEY_HASH,
-               );
-
-               // Init message-data->configuration translation array
-               $this->messageToConfig = array(
-                       XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS => 'your_external_address',
-                       XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_INTERNAL_ADDRESS => 'your_internal_address',
-                       XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_NODE_ID          => 'your_node_id',
-                       XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID       => 'your_session_id',
-                       XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_PRIVATE_KEY_HASH => 'your_private_key_hash',
-               );
-
-               // Init config-copy array
-               $this->configCopy = array(
-                       XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS => 'external_address',
-                       XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_INTERNAL_ADDRESS => 'internal_address',
-                       XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_NODE_STATUS      => 'node_status',
-                       XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID       => 'session_id',
-                       XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_PRIVATE_KEY_HASH => 'private_key_hash',
-               );
-
-               // Init array
-               $this->searchData = array(
-                       XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS
-               );
-       }
-
-       /**
-        * Creates an instance of this class
-        *
-        * @return      $handlerInstance        An instance of a HandleableMessage class
-        */
-       public final static function createNodeMessageAnnouncementHandler () {
-               // Get new instance
-               $handlerInstance = new NodeMessageAnnouncementHandler();
-
-               // Return the prepared instance
-               return $handlerInstance;
-       }
-
-       /**
-        * Handles data array of the message
-        *
-        * @param       $messageData            An array with message data to handle
-        * @param       $packageInstance        An instance of a Receivable class
-        * @return      void
-        * @throws      AnnouncementNotAcceptedException        If this node does not accept announcements
-        */
-       public function handleMessageData (array $messageData, Receivable $packageInstance) {
-               // Get node instance
-               $nodeInstance = NodeObjectFactory::createNodeInstance();
-
-               // Is this node accepting announcements?
-               if (!$nodeInstance->isAcceptingAnnouncements()) {
-                       /*
-                        * This node is not accepting announcements, then someone wants to
-                        * announce his node to a non-bootstrap and non-master node.
-                        */
-                       throw new AnnouncementNotAcceptedException(array($this, $nodeInstance, $messageData), BaseHubSystem::EXCEPTION_ANNOUNCEMENT_NOT_ACCEPTED);
-               } // END - if
-
-               // Register the announcing node with this node
-               $this->registerNodeByMessageData($messageData);
-
-               // Prepare answer message to be delivered back to the other node
-               $this->prepareAnswerMessage($messageData, $packageInstance);
-       }
-
-       /**
-        * Adds all required elements from given array into data set instance
-        *
-        * @param       $dataSetInstance        An instance of a StoreableCriteria class
-        * @param       $messageData            An array with all message data
-        * @return      void
-        */
-       public function addArrayToDataSet (StoreableCriteria $dataSetInstance, array $messageData) {
-               // Add generic first
-               parent::addArrayToDataSet($dataSetInstance, $messageData);
-
-               // Add all ements
-               foreach ($this->messageDataElements as $key) {
-                       // Is it there?
-                       assert(isset($messageData[$key]));
-
-                       // Add it
-                       /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('ANNOUNCEMENT-HANDLER: Adding messageData[' . $key . ']=' . $messageData[$key] . ' ...');
-                       $dataSetInstance->addCriteria($key, $messageData[$key]);
-               } // END - foreach
-       }
-
-       /**
-        * Initializes configuration data from given message data array
-        *
-        * @param       $messageData    An array with all message data
-        * @return      void
-        */
-       protected function initMessageConfigurationData (array $messageData) {
-               // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('ANNOUNCEMENT-HANDLER: messageData=' . print_r($messageData, TRUE));
-
-               // "Walk" throught the translation array
-               foreach ($this->messageToConfig as $messageKey => $configKey) {
-                       // Debug message
-                       //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('ANNOUNCEMENT-HANDLER: Setting messageKey=' . $messageKey . ',configKey=' . $configKey . ':' . $messageData[$messageKey]);
-
-                       // Set the element in configuration
-                       $this->getConfigInstance()->setConfigEntry($configKey, $messageData[$messageKey]);
-               } // END - foreach
-
-               // "Walk" throught the config-copy array
-               foreach ($this->configCopy as $targetKey => $sourceKey) {
-                       // Debug message
-                       //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('ANNOUNCEMENT-HANDLER: Copying from sourceKey=' . $sourceKey . ' to targetKey=' . $targetKey . '...');
-
-                       // Copy from source to targetKey
-                       $this->getConfigInstance()->setConfigEntry($targetKey, $this->getConfigInstance()->getConfigEntry($sourceKey));
-               } // END - foreach
-
-               // Translate last exception into a status code
-               $statusCode = $this->getTranslatedStatusFromLastException();
-
-               // Set it in configuration (temporarily)
-               $this->getConfigInstance()->setConfigEntry(NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_ANSWER_STATUS, $statusCode);
-       }
-
-       /**
-        * Removes configuration data with given message data array from global
-        * configuration
-        *
-        * @param       $messageData    An array with all message data
-        * @return      void
-        */
-       protected function removeMessageConfigurationData (array $messageData) {
-               // "Walk" throught the translation array again
-               foreach ($this->messageToConfig as $dummy => $configKey) {
-                       // Now unset this configuration entry (to save some memory)
-                       $this->getConfigInstance()->unsetConfigEntry($configKey);
-               } // END - foreach
-
-               // "Walk" throught the config-copy array again
-               foreach ($this->configCopy as $configKey => $dummy) {
-                       // Now unset this configuration entry (to save some memory again)
-                       $this->getConfigInstance()->unsetConfigEntry($configKey);
-               } // END - foreach
-
-               // Remove NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_ANSWER_STATUS as well
-               $this->getConfigInstance()->unsetConfigEntry(NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_ANSWER_STATUS);
-       }
-}
-
-// [EOF]
-?>
diff --git a/application/hub/classes/handler/message-types/answer/.htaccess b/application/hub/classes/handler/message-types/answer/.htaccess
deleted file mode 100644 (file)
index 3a42882..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Deny from all
diff --git a/application/hub/classes/handler/message-types/answer/class_NodeMessageAnnouncementAnswerHandler.php b/application/hub/classes/handler/message-types/answer/class_NodeMessageAnnouncementAnswerHandler.php
deleted file mode 100644 (file)
index 932b647..0000000
+++ /dev/null
@@ -1,179 +0,0 @@
-<?php
-// Own namespace
-namespace Hub\Handler\Node\Answer\Announcement;
-
-// Import application-specific stuff
-use Hub\Factory\Node\NodeObjectFactory;
-use Hub\Network\Receive\Receivable;
-use Hub\Template\Engine\Xml\Network\Answer\BaseXmlAnswerTemplateEngine;
-
-// Import framework stuff
-use CoreFramework\Criteria\Storing\StoreableCriteria;
-use CoreFramework\Generic\UnsupportedOperationException;
-use CoreFramework\Registry\Registerable;
-
-/**
- * A NodeMessageAnnouncementAnswer handler
- *
- * @author             Roland Haeder <webmaster@shipsimu.org>
- * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team
- * @license            GNU GPL 3.0 or any newer version
- * @link               http://www.shipsimu.org
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-class NodeMessageAnnouncementAnswerHandler extends BaseMessageHandler implements HandleableMessage, Registerable {
-       /**
-        * Protected constructor
-        *
-        * @return      void
-        */
-       protected function __construct () {
-               // Call parent constructor
-               parent::__construct(__CLASS__);
-
-               // Set handler name
-               $this->setHandlerName('message_announcement_answer');
-
-               // Init message data array
-               $this->messageDataElements = array(
-                       XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS,
-                       XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_INTERNAL_ADDRESS,
-                       XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_NODE_STATUS,
-                       XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_NODE_ID,
-                       XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID,
-                       XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_PRIVATE_KEY_HASH,
-                       BaseXmlAnswerTemplateEngine::ANSWER_STATUS,
-               );
-
-               // Init message-data->configuration translation array
-               $this->messageToConfig = array(
-               /*
-                       XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS => 'your_external_address',
-                       XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_INTERNAL_ADDRESS => 'your_internal_address',
-                       XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID       => 'your_session_id'
-                       XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_PRIVATE_KEY_HASH => 'your_private_key_hash'
-               */
-               );
-
-               // Init config-copy array
-               $this->configCopy = array(
-                       XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS => 'external_address',
-                       XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_INTERNAL_ADDRESS => 'internal_address',
-                       XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_NODE_STATUS      => 'node_status',
-                       XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID       => 'session_id',
-                       XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_PRIVATE_KEY_HASH => 'private_key_hash',
-               );
-
-               // Init array
-               $this->searchData = array(
-                       XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID,
-                       XmlAnnouncementAnswerTemplateEngine::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS,
-               );
-       }
-
-       /**
-        * Creates an instance of this class
-        *
-        * @return      $handlerInstance        An instance of a HandleableMessage class
-        */
-       public final static function createNodeMessageAnnouncementAnswerHandler () {
-               // Get new instance
-               $handlerInstance = new NodeMessageAnnouncementAnswerHandler();
-
-               // Return the prepared instance
-               return $handlerInstance;
-       }
-
-       /**
-        * Handles data array of the message
-        *
-        * @param       $messageData            An array with message data to handle
-        * @param       $packageInstance        An instance of a Receivable class
-        * @return      void
-        * @throws      NoAnnouncementAttemptedException        If this node has not attempted to announce itself
-        */
-       public function handleMessageData (array $messageData, Receivable $packageInstance) {
-               // Get node instance
-               $nodeInstance = NodeObjectFactory::createNodeInstance();
-
-               // Has this node attempted to announce itself?
-               if (!$nodeInstance->ifNodeIsAnnouncing()) {
-                       /*
-                        * This node has never announced itself, so it doesn't expect
-                        * announcement answer messages.
-                        */
-                       throw new NoAnnouncementAttemptedException(array($this, $nodeInstance, $messageData), self::EXCEPTION_ANNOUNCEMENT_NOT_ATTEMPTED);
-               } // END - if
-
-               // Register the announcing node with this node
-               $this->registerNodeByMessageData($messageData);
-
-               // Handle the answer status element
-               $nodeInstance->handleAnswerStatusByMessageData($messageData, $packageInstance);
-       }
-
-       /**
-        * Adds all required elements from given array into data set instance
-        *
-        * @param       $dataSetInstance        An instance of a StoreableCriteria class
-        * @param       $messageData            An array with all message data
-        * @return      void
-        */
-       public function addArrayToDataSet (StoreableCriteria $dataSetInstance, array $messageData) {
-               // Add generic first
-               parent::addArrayToDataSet($dataSetInstance, $messageData);
-
-               // Add all ements
-               foreach ($this->messageDataElements as $key) {
-                       // Is it there?
-                       assert(isset($messageData[$key]));
-
-                       /*
-                        * Add it, but remove any 'my-' prefixes as they are not used in
-                        * database layer.
-                        */
-                       $dataSetInstance->addCriteria(str_replace('my-', '', $key), $messageData[$key]);
-               } // END - foreach
-       }
-
-       /**
-        * Initializes configuration data from given message data array
-        *
-        * @param       $messageData    An array with all message data
-        * @return      void
-        * @throws      UnsupportedOperationException   If this method is called
-        */
-       protected function initMessageConfigurationData (array $messageData) {
-               // Please don't call this method
-               throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
-       }
-
-       /**
-        * Removes configuration data with given message data array from global
-        * configuration
-        *
-        * @param       $messageData    An array with all message data
-        * @return      void
-        * @throws      UnsupportedOperationException   If this method is called
-        */
-       protected function removeMessageConfigurationData (array $messageData) {
-               // Please don't call this method
-               throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
-       }
-}
-
-// [EOF]
-?>
diff --git a/application/hub/classes/handler/message-types/answer/class_NodeMessageDhtBootstrapAnswerHandler.php b/application/hub/classes/handler/message-types/answer/class_NodeMessageDhtBootstrapAnswerHandler.php
deleted file mode 100644 (file)
index e47c57a..0000000
+++ /dev/null
@@ -1,175 +0,0 @@
-<?php
-// Own namespace
-namespace Hub\Handler\Answer\Node\DhtBootstrap;
-
-// Import application-specific stuff
-use Hub\Factory\Dht\DhtObjectFactory;
-use Hub\Network\Receive\Receivable;
-use Hub\Template\Engine\Xml\Dht\Bootstrap\XmlDhtBootstrapTemplateEngine;
-use Hub\Template\Engine\Xml\Network\Answer\BaseXmlAnswerTemplateEngine;
-
-// Import framework stuff
-use CoreFramework\Criteria\Storing\StoreableCriteria;
-use CoreFramework\Generic\UnsupportedOperationException;
-use CoreFramework\Registry\Registerable;
-
-/**
- * A NodeMessageDhtBootstrapAnswer handler
- *
- * @author             Roland Haeder <webmaster@shipsimu.org>
- * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team
- * @license            GNU GPL 3.0 or any newer version
- * @link               http://www.shipsimu.org
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-class NodeMessageDhtBootstrapAnswerHandler extends BaseMessageHandler implements HandleableMessage, Registerable {
-       /**
-        * Protected constructor
-        *
-        * @return      void
-        */
-       protected function __construct () {
-               // Call parent constructor
-               parent::__construct(__CLASS__);
-
-               // Set handler name
-               $this->setHandlerName('message_announcement_answer');
-
-               // Init message data array
-               $this->messageDataElements = array(
-                       XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_EXTERNAL_ADDRESS,
-                       XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_INTERNAL_ADDRESS,
-                       XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_NODE_STATUS,
-                       XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_SESSION_ID,
-                       BaseXmlAnswerTemplateEngine::ANSWER_STATUS,
-               );
-
-               // Init message-data->configuration translation array
-               $this->messageToConfig = array(
-               /*
-                       @TODO Why commented out?
-                       XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_EXTERNAL_ADDRESS => 'your_external_address',
-                       XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_INTERNAL_ADDRESS => 'your_internal_address',
-                       XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_SESSION_ID       => 'your_session_id'
-               */
-               );
-
-               // Init config-copy array
-               $this->configCopy = array(
-                       XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_EXTERNAL_ADDRESS => 'external_address',
-                       XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_INTERNAL_ADDRESS => 'internal_address',
-                       XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_NODE_STATUS      => 'node_status',
-                       XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_SESSION_ID       => 'session_id',
-               );
-
-               // Init array
-               $this->searchData = array(
-                       XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_SESSION_ID,
-                       XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_EXTERNAL_ADDRESS,
-               );
-       }
-
-       /**
-        * Creates an instance of this class
-        *
-        * @return      $handlerInstance        An instance of a HandleableMessage class
-        */
-       public final static function createNodeMessageDhtBootstrapAnswerHandler () {
-               // Get new instance
-               $handlerInstance = new NodeMessageDhtBootstrapAnswerHandler();
-
-               // Return the prepared instance
-               return $handlerInstance;
-       }
-
-       /**
-        * Handles data array of the message
-        *
-        * @param       $messageData            An array with message data to handle
-        * @param       $packageInstance        An instance of a Receivable class
-        * @return      void
-        * @throws      NoDhtBootstrapAttemptedException        If this DHT has not attempted to bootstrap
-        * @todo        ~30% done
-        */
-       public function handleMessageData (array $messageData, Receivable $packageInstance) {
-               // Get DHT instance
-               $dhtInstance = DhtObjectFactory::createDhtInstance('node');
-
-               // Has this DHT attempted to bootstrap?
-               if (!$dhtInstance->ifDhtIsBooting()) {
-                       /*
-                        * This DHT has never bootstrapped, so it doesn't expect
-                        * announcement answer messages.
-                        */
-                       throw new NoDhtBootstrapAttemptedException(array($this, $dhtInstance, $messageData), self::EXCEPTION_DHT_BOOTSTRAP_NOT_ATTEMPTED);
-               } // END - if
-
-               // Unfinished
-               $this->partialStub('UNHANDLED: messageData=' . print_r($messageData, TRUE));
-       }
-
-       /**
-        * Adds all required elements from given array into data set instance
-        *
-        * @param       $dataSetInstance        An instance of a StoreableCriteria class
-        * @param       $messageData            An array with all message data
-        * @return      void
-        */
-       public function addArrayToDataSet (StoreableCriteria $dataSetInstance, array $messageData) {
-               // Add generic first
-               parent::addArrayToDataSet($dataSetInstance, $messageData);
-
-               // Add all ements
-               foreach ($this->messageDataElements as $key) {
-                       // Is it there?
-                       assert(isset($messageData[$key]));
-
-                       /*
-                        * Add it, but remove any 'my-' prefixes as they are not used in
-                        * database layer.
-                        */
-                       $dataSetInstance->addCriteria(str_replace('my-', '', $key), $messageData[$key]);
-               } // END - foreach
-       }
-
-       /**
-        * Initializes configuration data from given message data array
-        *
-        * @param       $messageData    An array with all message data
-        * @return      void
-        * @throws      UnsupportedOperationException   If this method is called
-        */
-       protected function initMessageConfigurationData (array $messageData) {
-               // Please don't call this method
-               throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
-       }
-
-       /**
-        * Removes configuration data with given message data array from global
-        * configuration
-        *
-        * @param       $messageData    An array with all message data
-        * @return      void
-        * @throws      UnsupportedOperationException   If this method is called
-        */
-       protected function removeMessageConfigurationData (array $messageData) {
-               // Please don't call this method
-               throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
-       }
-}
-
-// [EOF]
-?>
diff --git a/application/hub/classes/handler/message-types/answer/class_NodeMessageRequestNodeListAnswerHandler.php b/application/hub/classes/handler/message-types/answer/class_NodeMessageRequestNodeListAnswerHandler.php
deleted file mode 100644 (file)
index f2a4aa3..0000000
+++ /dev/null
@@ -1,168 +0,0 @@
-<?php
-// Own namespace
-namespace Hub\Handler\Node\Answer\Request\NodeList;
-
-// Import application-specific stuff
-use Hub\Factory\Node\NodeObjectFactory;
-use Hub\Network\Receive\Receivable;
-use Hub\Template\Engine\Xml\Network\Answer\BaseXmlAnswerTemplateEngine;
-
-// Import framework stuff
-use CoreFramework\Criteria\Storing\StoreableCriteria;
-use CoreFramework\Generic\UnsupportedOperationException;
-use CoreFramework\Registry\Registerable;
-
-/**
- * A NodeMessageRequestNodeListAnswer handler
- *
- * @author             Roland Haeder <webmaster@shipsimu.org>
- * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team
- * @license            GNU GPL 3.0 or any newer version
- * @link               http://www.shipsimu.org
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-class NodeMessageRequestNodeListAnswerHandler extends BaseMessageHandler implements HandleableMessage, Registerable {
-       /**
-        * Protected constructor
-        *
-        * @return      void
-        */
-       protected function __construct () {
-               // Call parent constructor
-               parent::__construct(__CLASS__);
-
-               // Set handler name
-               $this->setHandlerName('message_request_node_list_answer');
-
-               // Init message data array
-               $this->messageDataElements = array(
-                       XmlRequestNodeListAnswerTemplateEngine::REQUEST_DATA_SESSION_ID,
-                       XmlRequestNodeListAnswerTemplateEngine::REQUEST_DATA_NODE_LIST,
-                       BaseXmlAnswerTemplateEngine::ANSWER_STATUS,
-               );
-
-               // Init message-data->configuration translation array
-               $this->messageToConfig = array(
-               /*
-                       XmlRequestNodeListTemplateEngine::REQUEST_DATA_SESSION_ID  => 'your_session_id'
-               */
-               );
-
-               // Init search data array
-               $this->searchData = array(
-                       XmlRequestNodeListAnswerTemplateEngine::REQUEST_DATA_SESSION_ID,
-               );
-       }
-
-       /**
-        * Creates an instance of this class
-        *
-        * @return      $handlerInstance        An instance of a HandleableMessage class
-        */
-       public final static function createNodeMessageRequestNodeListAnswerHandler () {
-               // Get new instance
-               $handlerInstance = new NodeMessageRequestNodeListAnswerHandler();
-
-               // Return the prepared instance
-               return $handlerInstance;
-       }
-
-       /**
-        * Handles data array of the message
-        *
-        * @param       $messageData            An array with message data to handle
-        * @param       $packageInstance        An instance of a Receivable class
-        * @return      void
-        * @throws      NoRequestNodeListAttemptedException     If this node has not attempted to announce itself
-        */
-       public function handleMessageData (array $messageData, Receivable $packageInstance) {
-               // Get node instance
-               $nodeInstance = NodeObjectFactory::createNodeInstance();
-
-               // Has this node attempted to announce itself?
-               if (!$nodeInstance->ifNodeHasAnnouncementCompleted()) {
-                       /*
-                        * This node has never announced itself, so it doesn't expect
-                        * request-node-list answer messages.
-                        */
-                       throw new NoRequestNodeListAttemptedException(array($this, $nodeInstance, $messageData), self::EXCEPTION_ANNOUNCEMENT_NOT_ATTEMPTED);
-               } // END - if
-
-               // Register the announcing node with this node
-               $this->registerNodeByMessageData($messageData);
-
-               // Handle the answer status element
-               $nodeInstance->handleAnswerStatusByMessageData($messageData, $packageInstance);
-       }
-
-       /**
-        * Adds all required elements from given array into data set instance
-        *
-        * @param       $dataSetInstance        An instance of a StoreableCriteria class
-        * @param       $messageData            An array with all message data
-        * @return      void
-        */
-       public function addArrayToDataSet (StoreableCriteria $dataSetInstance, array $messageData) {
-               // Add generic first
-               parent::addArrayToDataSet($dataSetInstance, $messageData);
-
-               // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('ANSWER-HANDLER: messageData=' . print_r($messageData, TRUE));
-
-               // Add all ements
-               foreach ($this->messageDataElements as $key) {
-                       // Debug message
-                       //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('ANSWER-HANDLER: messageData[' . $key . ']=' . $messageData[$key]);
-
-                       // Is it there?
-                       assert(isset($messageData[$key]));
-
-                       /*
-                        * Add it, but remove any 'my-' prefixes as they are not used in
-                        * database layer.
-                        */
-                       $dataSetInstance->addCriteria(str_replace('my-', '', $key), $messageData[$key]);
-               } // END - foreach
-       }
-
-       /**
-        * Initializes configuration data from given message data array
-        *
-        * @param       $messageData    An array with all message data
-        * @return      void
-        * @throws      UnsupportedOperationException   If this method is called
-        */
-       protected function initMessageConfigurationData (array $messageData) {
-               // Please don't call this method
-               throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
-       }
-
-       /**
-        * Removes configuration data with given message data array from global
-        * configuration
-        *
-        * @param       $messageData    An array with all message data
-        * @return      void
-        * @throws      UnsupportedOperationException   If this method is called
-        */
-       protected function removeMessageConfigurationData (array $messageData) {
-               // Please don't call this method
-               throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
-       }
-}
-
-// [EOF]
-?>
diff --git a/application/hub/classes/handler/message-types/class_ b/application/hub/classes/handler/message-types/class_
deleted file mode 100644 (file)
index 0a4077e..0000000
+++ /dev/null
@@ -1,121 +0,0 @@
-<?php
-// Own namespace
-namespace Hub\Handler\Message\;
-
-// Import framework stuff
-use CoreFramework\Criteria\Storing\StoreableCriteria;
-
-/**
- * A NodeMessage??? handler
- *
- * @author             Roland Haeder <webmaster@ship-simu.org>
- * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team
- * @license            GNU GPL 3.0 or any newer version
- * @link               http://www.ship-simu.org
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-class NodeMessage???Handler extends BaseMessageHandler implements HandleableMessage, Registerable {
-       /**
-        * Protected constructor
-        *
-        * @return      void
-        */
-       protected function __construct () {
-               // Call parent constructor
-               parent::__construct(__CLASS__);
-
-               // Set handler name
-               $this->setHandlerName('message_===');
-
-               // Init message data array
-               $this->messageDataElements = array(
-                       Xml???TemplateEngine::!!!_DATA_EXTERNAL_ADDRESS,
-                       Xml???TemplateEngine::!!!_DATA_NODE_STATUS,
-                       Xml???TemplateEngine::!!!_DATA_SESSION_ID,
-                       Xml???TemplateEngine::!!!_DATA_LISTEN_PORT,
-               );
-       }
-
-       /**
-        * Creates an instance of this class
-        *
-        * @return      $handlerInstance        An instance of a HandleableMessage class
-        */
-       public final static function createNodeMessage???Handler () {
-               // Get new instance
-               $handlerInstance = new NodeMessage???Handler();
-
-               // Return the prepared instance
-               return $handlerInstance;
-       }
-
-       /**
-        * Handles data array of the message
-        *
-        * @param       $messageData            An array with message data to handle
-        * @param       $packageInstance        An instance of a Receivable class
-        * @return      void
-        */
-       public function handleMessageData (array $messageData, Receivable $packageInstance) {
-               // Register the announcing node with this node
-               $this->registerNodeByMessageData($messageData);
-
-               // Prepare answer message to be delivered back to the other node
-               $this->prepareAnswerMessage($messageData, $packageInstance);
-       }
-
-       /**
-        * Adds all required elements from given array into data set instance
-        *
-        * @param       $dataSetInstance        An instance of a StoreableCriteria class
-        * @param       $messageData            An array with all message data
-        * @return      void
-        */
-       public function addArrayToDataSet (StoreableCriteria $dataSetInstance, array $messageData) {
-               // Add all ements
-               foreach ($this->messageDataElements as $key) {
-                       // Is it there?
-                       assert(isset($messageData[$key]));
-
-                       // Add it
-                       $dataSetInstance->addCriteria($key, $messageData[$key]);
-               } // END - foreach
-       }
-
-       /**
-        * Initializes configuration data from given message data array
-        *
-        * @param       $messageData    An array with all message data
-        * @return      void
-        */
-       protected function initMessageConfigurationData (array $messageData) {
-               $this->partialStub('Please implement this method.');
-       }
-
-       /**
-        * Removes configuration data with given message data array from global
-        * configuration
-        *
-        * @param       $messageData    An array with all message data
-        * @return      void
-        */
-       protected function removeMessageConfigurationData (array $messageData) {
-               $this->partialStub('Please implement this method.');
-       }
-}
-
-// [EOF]
-?>
diff --git a/application/hub/classes/handler/message-types/class_BaseMessageHandler.php b/application/hub/classes/handler/message-types/class_BaseMessageHandler.php
deleted file mode 100644 (file)
index 4d55637..0000000
+++ /dev/null
@@ -1,101 +0,0 @@
-<?php
-// Own namespace
-namespace Hub\Handler\Message;
-
-// Import hub-specific stuff
-use Hub\Factory\Dht\DhtObjectFactory;
-use Hub\Generic\BaseHubSystem;
-use Hub\Network\Receive\Receivable;
-
-// Import framework stuff
-use CoreFramework\Generic\FrameworkException;
-
-/**
- * A general message handler, this class must be abstract to make the template
- * method pattern working.
- *
- * @author             Roland Haeder <webmaster@shipsimu.org>
- * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team
- * @license            GNU GPL 3.0 or any newer version
- * @link               http://www.shipsimu.org
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-abstract class BaseMessageHandler extends BaseDataHandler {
-       /**
-        * Protected constructor
-        *
-        * @param       $className      Name of the class
-        * @return      void
-        */
-       protected function __construct ($className) {
-               // Call parent constructor
-               parent::__construct($className);
-       }
-
-       /**
-        * "Getter" for a translated last exception as a status code
-        *
-        * @return      $statusCode             Translated status code from last exception
-        */
-       protected function getTranslatedStatusFromLastException () {
-               // Default is all fine
-               $statusCode = BaseHubSystem::MESSAGE_STATUS_CODE_OKAY;
-
-               // Is the last exception not NULL?
-               if ($this->getLastException() instanceof FrameworkException) {
-                       // "Determine" the right status code (may differ from exception to exception)
-                       $this->debugInstance(sprintf('[%s:%d]: lastException=%s,message=%s is unfinished.', __METHOD__, __LINE__, $this->getLastException()->__toString(), $this->getLastException()->getMessage()));
-               } // END - if
-
-               // Return the status code
-               return $statusCode;
-       }
-
-       /**
-        * Registers an other node with this node by given message data. The
-        * following data must always be present:
-        *
-        * - session-id  (for finding the node's record together with below data)
-        * - external-address (hostname or IP number)
-        * - listen-port (TCP/UDP listen port for inbound connections)
-        *
-        * @param       $messageArray   An array with all minimum message data
-        * @return      void
-        */
-       protected function registerNodeByMessageData (array $messageData) {
-               // Check if searchData has entries
-               assert(count($this->getSearchData()) > 0);
-
-               // Let the DHT facade do the work
-               DhtObjectFactory::createDhtInstance('node')->registerNodeByMessageData($messageData, $this);
-       }
-
-       /**
-        * Posty-handles data array of the message
-        *
-        * @param       $messageData            An array with message data to handle
-        * @param       $packageInstance        An instance of a Receivable class
-        * @return      void
-        */
-       public function postHandleMessageData (array $messageData, Receivable $packageInstance) {
-               /*
-                * Feed hash to miner by handling over the whole array as also the
-                * sender and tags are needed.
-                */
-               $packageInstance->feedHashToMiner($messageData);
-       }
-
-}
diff --git a/application/hub/classes/handler/message-types/dht/.htaccess b/application/hub/classes/handler/message-types/dht/.htaccess
deleted file mode 100644 (file)
index 3a42882..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Deny from all
diff --git a/application/hub/classes/handler/message-types/dht/class_NodeMessageDhtBootstrapHandler.php b/application/hub/classes/handler/message-types/dht/class_NodeMessageDhtBootstrapHandler.php
deleted file mode 100644 (file)
index dfaa234..0000000
+++ /dev/null
@@ -1,215 +0,0 @@
-<?php
-// Own namespace
-namespace Hub\Handler\Node\Answer\Dht\Bootstrap;
-
-// Import application-specific stuff
-use Hub\Database\Frontend\Node\Dht\NodeDistributedHashTableDatabaseWrapper;
-use Hub\Factory\Dht\DhtObjectFactory;
-use Hub\Factory\Node\NodeObjectFactory;
-use Hub\Network\Receive\Receivable;
-use Hub\Template\Engine\Xml\Dht\Bootstrap\XmlDhtBootstrapTemplateEngine;
-
-// Import framework stuff
-use CoreFramework\Criteria\Storing\StoreableCriteria;
-use CoreFramework\Registry\Registerable;
-
-/**
- * A NodeMessageDhtBootstrap handler
- *
- * @author             Roland Haeder <webmaster@shipsimu.org>
- * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team
- * @license            GNU GPL 3.0 or any newer version
- * @link               http://www.shipsimu.org
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-class NodeMessageDhtBootstrapHandler extends BaseMessageHandler implements HandleableMessage, Registerable {
-       /**
-        * Protected constructor
-        *
-        * @return      void
-        */
-       protected function __construct () {
-               // Call parent constructor
-               parent::__construct(__CLASS__);
-
-               // Set handler name
-               $this->setHandlerName('message_dht_bootstrap');
-
-               // Init message data array
-               $this->messageDataElements = array(
-                       XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_EXTERNAL_ADDRESS,
-                       XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_INTERNAL_ADDRESS,
-                       XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_NODE_STATUS,
-                       XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_NODE_MODE,
-                       XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_SESSION_ID,
-               );
-
-               // Init message-data->configuration translation array
-               $this->messageToConfig = array(
-                       XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_EXTERNAL_ADDRESS => 'your_external_address',
-                       XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_INTERNAL_ADDRESS => 'your_internal_address',
-                       XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_SESSION_ID       => 'your_session_id'
-               );
-
-               // Init config-copy array
-               $this->configCopy = array(
-                       XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_EXTERNAL_ADDRESS => 'external_address',
-                       XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_INTERNAL_ADDRESS => 'internal_address',
-                       XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_NODE_STATUS      => 'node_status',
-                       XmlDhtBootstrapAnswerTemplateEngine::DHT_BOOTSTRAP_DATA_SESSION_ID       => 'session_id',
-               );
-
-               // Init array
-               $this->searchData = array(
-                       XmlDhtBootstrapTemplateEngine::DHT_BOOTSTRAP_DATA_EXTERNAL_ADDRESS,
-               );
-       }
-
-       /**
-        * Creates an instance of this class
-        *
-        * @return      $handlerInstance        An instance of a HandleableMessage class
-        */
-       public final static function createNodeMessageDhtBootstrapHandler () {
-               // Get new instance
-               $handlerInstance = new NodeMessageDhtBootstrapHandler();
-
-               // Return the prepared instance
-               return $handlerInstance;
-       }
-
-       /**
-        * Handles data array of the message
-        *
-        * @param       $messageData            An array with message data to handle
-        * @param       $packageInstance        An instance of a Receivable class
-        * @return      void
-        * @throws      DhtBootstrapNotAcceptedException        If this node does not accept DHT bootstrap requests
-        */
-       public function handleMessageData (array $messageData, Receivable $packageInstance) {
-               // Is this node accepting DHT bootstrap requests?
-               if (!NodeObjectFactory::createNodeInstance()->isAcceptingDhtBootstrap()) {
-                       /*
-                        * This node is not accepting DHT bootstrap requests.
-                        */
-                       throw new DhtBootstrapNotAcceptedException(array($this, $messageData), self::EXCEPTION_DHT_BOOTSTRAP_NOT_ACCEPTED);
-               } // END - if
-
-               // Register the DHT bootstrap requesting node with this node
-               $this->registerNodeByMessageData($messageData);
-
-               // Prepare answer message to be delivered back to the other node
-               $this->prepareAnswerMessage($messageData, $packageInstance);
-       }
-
-       /**
-        * Adds all required elements from given array into data set instance
-        *
-        * @param       $dataSetInstance        An instance of a StoreableCriteria class
-        * @param       $messageData            An array with all message data
-        * @return      void
-        */
-       public function addArrayToDataSet (StoreableCriteria $dataSetInstance, array $messageData) {
-               // Add generic first
-               parent::addArrayToDataSet($dataSetInstance, $messageData);
-
-               // Add all ements
-               foreach ($this->messageDataElements as $key) {
-                       // Is it there?
-                       assert(isset($messageData[$key]));
-
-                       // Add it
-                       $dataSetInstance->addCriteria($key, $messageData[$key]);
-               } // END - foreach
-       }
-
-       /**
-        * Initializes configuration data from given message data array
-        *
-        * @param       $messageData    An array with all message data
-        * @return      void
-        */
-       protected function initMessageConfigurationData (array $messageData) {
-               // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-BOOTSTRAP-HANDLER: messageData=' . print_r($messageData, TRUE));
-
-               // "Walk" throught the translation array
-               foreach ($this->messageToConfig as $messageKey => $configKey) {
-                       // Debug message
-                       //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-BOOTSTRAP-HANDLER: Setting messageKey=' . $messageKey . ',configKey=' . $configKey . ':' . $messageData[$messageKey]);
-
-                       // Set the element in configuration
-                       $this->getConfigInstance()->setConfigEntry($configKey, $messageData[$messageKey]);
-               } // END - foreach
-
-               // "Walk" throught the config-copy array
-               foreach ($this->configCopy as $targetKey => $sourceKey) {
-                       // Debug message
-                       //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-BOOTSTRAP-HANDLER: Copying from sourceKey=' . $sourceKey . ' to targetKey=' . $targetKey . '...');
-
-                       // Copy from source to target key
-                       $this->getConfigInstance()->setConfigEntry($targetKey, $this->getConfigInstance()->getConfigEntry($sourceKey));
-               } // END - foreach
-
-               // Translate last exception into a status code
-               $statusCode = $this->getTranslatedStatusFromLastException();
-
-               // Set it in configuration (temporarily)
-               $this->getConfigInstance()->setConfigEntry(NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_ANSWER_STATUS, $statusCode);
-
-               /*
-                * Use the DHT instance to get a list of recipients. This means that all
-                * DHT nodes that accept bootstrap requests are read from the DHT
-                * database.
-                */
-               $nodeList = DhtObjectFactory::createDhtInstance('node')->findRecipientsByKey(NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_ACCEPT_BOOTSTRAP, 'Y');
-
-               // Make sure it is an array and has at least one entry
-               assert(is_array($nodeList));
-               assert(count($nodeList) > 0);
-
-               // Set it in configuration
-               $this->getConfigInstance()->setConfigEntry('dht_nodes', base64_encode(json_encode($nodeList)));
-       }
-
-       /**
-        * Removes configuration data with given message data array from global
-        * configuration
-        *
-        * @param       $messageData    An array with all message data
-        * @return      void
-        */
-       protected function removeMessageConfigurationData (array $messageData) {
-               // "Walk" throught the translation array again
-               foreach ($this->messageToConfig as $dummy => $configKey) {
-                       // Now unset this configuration entry (to save some memory)
-                       $this->getConfigInstance()->unsetConfigEntry($configKey);
-               } // END - foreach
-
-               // "Walk" throught the config-copy array again
-               foreach ($this->configCopy as $configKey => $dummy) {
-                       // Now unset this configuration entry (to save some memory again)
-                       $this->getConfigInstance()->unsetConfigEntry($configKey);
-               } // END - foreach
-
-               // Remove temporary "special" values as well
-               $this->getConfigInstance()->unsetConfigEntry(NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_ANSWER_STATUS);
-               $this->getConfigInstance()->unsetConfigEntry('dht_nodes');
-       }
-}
-
-// [EOF]
-?>
diff --git a/application/hub/classes/handler/message-types/requests/.htaccess b/application/hub/classes/handler/message-types/requests/.htaccess
deleted file mode 100644 (file)
index 3a42882..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Deny from all
diff --git a/application/hub/classes/handler/message-types/requests/class_NodeMessageRequestNodeListHandler.php b/application/hub/classes/handler/message-types/requests/class_NodeMessageRequestNodeListHandler.php
deleted file mode 100644 (file)
index e74527a..0000000
+++ /dev/null
@@ -1,190 +0,0 @@
-<?php
-// Own namespace
-namespace Hub\Handler\Node\Message\Request\NodeList;
-
-// Import application-specific stuff
-use Hub\Database\Frontend\Node\Dht\NodeDistributedHashTableDatabaseWrapper;
-use Hub\Factory\Dht\DhtObjectFactory;
-use Hub\Factory\Node\NodeObjectFactory;
-use Hub\Network\Receive\Receivable;
-use Hub\Node\BaseHubNode;
-
-// Import framework stuff
-use CoreFramework\Criteria\Storing\StoreableCriteria;
-use CoreFramework\Registry\Registerable;
-
-/**
- * A NodeMessageRequestNodeList handler
- *
- * @author             Roland Haeder <webmaster@shipsimu.org>
- * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team
- * @license            GNU GPL 3.0 or any newer version
- * @link               http://www.shipsimu.org
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-class NodeMessageRequestNodeListHandler extends BaseMessageHandler implements HandleableMessage, Registerable {
-       /**
-        * Protected constructor
-        *
-        * @return      void
-        */
-       protected function __construct () {
-               // Call parent constructor
-               parent::__construct(__CLASS__);
-
-               // Set handler name
-               $this->setHandlerName('message_request_node_list');
-
-               // Init message data array
-               $this->messageDataElements = array(
-                       XmlRequestNodeListTemplateEngine::REQUEST_DATA_ACCEPTED_OBJECT_TYPES,
-               );
-
-               // Init config-copy array
-               $this->configCopy = array(
-               );
-
-               // Init search data array
-               $this->searchData = array(
-                       XmlRequestNodeListTemplateEngine::REQUEST_DATA_SESSION_ID,
-               );
-       }
-
-       /**
-        * Creates an instance of this class
-        *
-        * @return      $handlerInstance        An instance of a HandleableMessage class
-        */
-       public final static function createNodeMessageRequestNodeListHandler () {
-               // Get new instance
-               $handlerInstance = new NodeMessageRequestNodeListHandler();
-
-               // Return the prepared instance
-               return $handlerInstance;
-       }
-
-       /**
-        * Handles data array of the message
-        *
-        * @param       $messageData            An array with message data to handle
-        * @param       $packageInstance        An instance of a Receivable class
-        * @return      void
-        * @throws      RequestNotAcceptedException             If this node does not accept this request
-        */
-       public function handleMessageData (array $messageData, Receivable $packageInstance) {
-               // Get node instance
-               $nodeInstance = NodeObjectFactory::createNodeInstance();
-
-               // Is this node accepting announcements?
-               if (!$nodeInstance->isAcceptingNodeListRequests()) {
-                       /*
-                        * This node is not accepting node list requests. Throw an
-                        * exception to abort any further processing.
-                        */
-                       throw new RequestNotAcceptedException(array($this, $nodeInstance, $messageData), self::EXCEPTION_REQUEST_NOT_ACCEPTED);
-               } // END - if
-
-               // Register the announcing node with this node
-               $this->registerNodeByMessageData($messageData);
-
-               // Prepare answer message to be delivered back to the other node
-               $this->prepareAnswerMessage($messageData, $packageInstance);
-       }
-
-       /**
-        * Adds all required elements from given array into data set instance
-        *
-        * @param       $dataSetInstance        An instance of a StoreableCriteria class
-        * @param       $messageData            An array with all message data
-        * @return      void
-        */
-       public function addArrayToDataSet (StoreableCriteria $dataSetInstance, array $messageData) {
-               // Add generic first
-               parent::addArrayToDataSet($dataSetInstance, $messageData);
-
-               // Add all ements
-               foreach ($this->messageDataElements as $key) {
-                       // Is it there?
-                       assert(isset($messageData[$key]));
-
-                       // Add it
-                       $dataSetInstance->addCriteria($key, $messageData[$key]);
-               } // END - foreach
-       }
-
-       /**
-        * Initializes configuration data from given message data array
-        *
-        * @param       $messageData    An array with all message data
-        * @return      void
-        */
-       protected function initMessageConfigurationData (array $messageData) {
-               // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('REQUEST-HANDLER: messageData=' . print_r($messageData, TRUE));
-
-               // "Walk" throught the config-copy array
-               foreach ($this->configCopy as $targetKey => $sourceKey) {
-                       // Debug message
-                       //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('REQUEST-HANDLER: Copying from sourceKey=' . $sourceKey . ' to targetKey=' . $targetKey . '...');
-
-                       // Copy from source to targetKey
-                       $this->getConfigInstance()->setConfigEntry($targetKey, $this->getConfigInstance()->getConfigEntry($sourceKey));
-               } // END - foreach
-
-               // Query local DHT for nodes except given session id
-               $nodeList = DhtObjectFactory::createDhtInstance('node')->queryLocalNodeListExceptByMessageData(
-                       $messageData,
-                       $this,
-                       XmlRequestNodeListTemplateEngine::REQUEST_DATA_SESSION_ID,
-                       XmlRequestNodeListTemplateEngine::REQUEST_DATA_ACCEPTED_OBJECT_TYPES,
-                       BaseHubNode::OBJECT_LIST_SEPARATOR
-               );
-
-               // Debug message
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('REQUEST-HANDLER: Got a node list of ' . count($nodeList) . ' entry/-ies back.');
-
-               // Set it serialized in configuration (temporarily)
-               $this->getConfigInstance()->setConfigEntry('node_list', base64_encode(json_encode($nodeList)));
-
-               // Translate last exception into a status code
-               $statusCode = $this->getTranslatedStatusFromLastException();
-
-               // Set it in configuration (temporarily)
-               $this->getConfigInstance()->setConfigEntry(NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_ANSWER_STATUS, $statusCode);
-       }
-
-       /**
-        * Removes configuration data with given message data array from global
-        * configuration
-        *
-        * @param       $messageData    An array with all message data
-        * @return      void
-        */
-       protected function removeMessageConfigurationData (array $messageData) {
-               // "Walk" throught the config-copy array again
-               foreach ($this->configCopy as $configKey => $dummy) {
-                       // Now unset this configuration entry (to save some memory again)
-                       $this->getConfigInstance()->unsetConfigEntry($configKey);
-               } // END - foreach
-
-               // Remove answer status/node list as well
-               $this->getConfigInstance()->unsetConfigEntry(NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_ANSWER_STATUS);
-               $this->getConfigInstance()->unsetConfigEntry('node_list');
-       }
-}
-
-// [EOF]
-?>
diff --git a/application/hub/classes/handler/message-types/self-connect/.htaccess b/application/hub/classes/handler/message-types/self-connect/.htaccess
deleted file mode 100644 (file)
index 3a42882..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Deny from all
diff --git a/application/hub/classes/handler/message-types/self-connect/class_NodeMessageSelfConnectHandler.php b/application/hub/classes/handler/message-types/self-connect/class_NodeMessageSelfConnectHandler.php
deleted file mode 100644 (file)
index b485f7b..0000000
+++ /dev/null
@@ -1,130 +0,0 @@
-<?php
-// Own namespace
-namespace Hub\Handler\Node\Message\SelfConnect;
-
-// Import application-specific stuff
-use Hub\Factory\Node\NodeObjectFactory;
-use Hub\Network\Receive\Receivable;
-
-// Import framework stuff
-use CoreFramework\Criteria\Storing\StoreableCriteria;
-use CoreFramework\Generic\UnsupportedOperationException;
-use CoreFramework\Registry\Registerable;
-
-/**
- * A NodeMessageSelfConnect handler
- *
- * @author             Roland Haeder <webmaster@shipsimu.org>
- * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team
- * @license            GNU GPL 3.0 or any newer version
- * @link               http://www.shipsimu.org
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-class NodeMessageSelfConnectHandler extends BaseMessageHandler implements HandleableMessage, Registerable {
-       /**
-        * Protected constructor
-        *
-        * @return      void
-        */
-       protected function __construct () {
-               // Call parent constructor
-               parent::__construct(__CLASS__);
-
-               // Set handler name
-               $this->setHandlerName('message_self_connect');
-       }
-
-       /**
-        * Creates an instance of this class
-        *
-        * @return      $handlerInstance        An instance of a HandleableMessage class
-        */
-       public final static function createNodeMessageSelfConnectHandler () {
-               // Get new instance
-               $handlerInstance = new NodeMessageSelfConnectHandler();
-
-               // Return the prepared instance
-               return $handlerInstance;
-       }
-
-       /**
-        * Handles data array of the message
-        *
-        * @param       $messageData            An array with message data to handle
-        * @param       $packageInstance        An instance of a Receivable class
-        * @return      void
-        */
-       public function handleMessageData (array $messageData, Receivable $packageInstance) {
-               // Get node instance
-               $nodeInstance = NodeObjectFactory::createNodeInstance();
-
-               // Are node id and session id the same?
-               if (($messageData[XmlSelfConnectTemplateEngine::SELF_CONNECT_DATA_NODE_ID] == $nodeInstance->getNodeId()) && ($messageData[XmlSelfConnectTemplateEngine::SELF_CONNECT_DATA_SESSION_ID] == $nodeInstance->getSessionId())) {
-                       // Both are equal
-                       self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SELF-CONNECT: Have connected to myself, both node and session id are equal!');
-
-                       // ... and change state
-                       $nodeInstance->getStateInstance()->nodeHasSelfConnected();
-               } else {
-                       // Something really horrible happened
-                       // @TODO Throw an exception here instead of dying
-                       $this->debugInstance(sprintf('[%s:%d]: ids mismatching! messageData=%s', __METHOD__, __LINE__, print_r($messageData, TRUE)));
-               }
-       }
-
-       /**
-        * Adds all required elements from given array into data set instance
-        *
-        * @param       $dataSetInstance        An instance of a StoreableCriteria class
-        * @param       $messageData            An array with all message data
-        * @return      void
-        * @throws      UnsupportedOperationException   If this method is called
-        */
-       public function addArrayToDataSet (StoreableCriteria $dataSetInstance, array $messageData) {
-               // Add generic first
-               parent::addArrayToDataSet($dataSetInstance, $messageData);
-
-               // Please don't call this method!
-               throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
-       }
-
-       /**
-        * Initializes configuration data from given message data array
-        *
-        * @param       $messageData    An array with all message data
-        * @return      void
-        * @throws      UnsupportedOperationException   If this method is called
-        */
-       protected function initMessageConfigurationData (array $messageData) {
-               // Please don't call this method!
-               throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
-       }
-
-       /**
-        * Removes configuration data with given message data array from global configuration
-        *
-        * @param       $messageData    An array with all message data
-        * @return      void
-        * @throws      UnsupportedOperationException   If this method is called
-        */
-       protected function removeMessageConfigurationData (array $messageData) {
-               // Please don't call this method!
-               throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION);
-       }
-}
-
-// [EOF]
-?>
diff --git a/application/hub/classes/handler/network/.htaccess b/application/hub/classes/handler/network/.htaccess
deleted file mode 100644 (file)
index 3a42882..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Deny from all
diff --git a/application/hub/classes/handler/network/socket/.htaccess b/application/hub/classes/handler/network/socket/.htaccess
deleted file mode 100644 (file)
index 3a42882..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Deny from all
diff --git a/application/hub/classes/handler/network/socket/class_SocketRawDataHandler.php b/application/hub/classes/handler/network/socket/class_SocketRawDataHandler.php
deleted file mode 100644 (file)
index e02f2f1..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-<?php
-// Own namespace
-namespace Hub\Handler\Network\Socket\RawData;
-
-// Import application-specific stuff
-use Hub\Handler\Network\RawData\BaseRawDataHandler;
-use Hub\Network\Networkable;
-
-/**
- * A file-based socket raw data handler
- *
- * @author             Roland Haeder <webmaster@shipsimu.org>
- * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team
- * @license            GNU GPL 3.0 or any newer version
- * @link               http://www.shipsimu.org
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-class SocketRawDataHandler extends BaseRawDataHandler implements Networkable {
-       /**
-        * Protected constructor
-        *
-        * @return      void
-        */
-       protected function __construct () {
-               // Call parent constructor
-               parent::__construct(__CLASS__);
-
-               // Set handler name
-               $this->setHandlerName('socket');
-       }
-
-       /**
-        * Creates an instance of this class
-        *
-        * @return      $handlerInstance        An instance of a Networkable class
-        */
-       public static final function createSocketRawDataHandler () {
-               // Get new instance
-               $handlerInstance = new SocketRawDataHandler();
-
-               // Return the prepared instance
-               return $handlerInstance;
-       }
-
-       /**
-        * Processes raw data from given resource. This is mostly useful for TCP
-        * package handling and is implemented in the ???Listener class
-        *
-        * @param       $resource       A valid socket resource array
-        * @return      void
-        */
-       public function processRawDataFromResource (array $socketArray) {
-               $this->partialStub('socketArray=' . print_r($socketArray, TRUE));
-       }
-}
-
-// [EOF]
-?>
diff --git a/application/hub/classes/handler/network/tcp/.htaccess b/application/hub/classes/handler/network/tcp/.htaccess
deleted file mode 100644 (file)
index 3a42882..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Deny from all
diff --git a/application/hub/classes/handler/network/tcp/class_ b/application/hub/classes/handler/network/tcp/class_
deleted file mode 100644 (file)
index c09a61e..0000000
+++ /dev/null
@@ -1,220 +0,0 @@
-while (count($clients) > 0) {
-       // create a copy, so $clients doesn't get modified by socket_select()
-       $read = $clients;
-
-       // get a list of all the clients that have data to be read from
-       // if there are no clients with data, go to next iteration
-       $left = @socket_select($read, $write = null, $except = null, 0, 150);
-       if ($left < 1) {
-               continue;
-       }
-
-       // check if there is a client trying to connect
-       if (in_array($mainSocket, $read)) {
-               // accept the client, and add him to the $clients array
-               $new_sock = socket_accept($mainSocket);
-               $clients[] = $new_sock;
-
-               // send the client a welcome message
-               socket_write($new_sock, "No noobs, but I'll make an exception. :)\n".
-               "There are ".(count($clients) - 1)." client(s) connected to the server.\n");
-
-               socket_getpeername($new_sock, $ip);
-               out(__FILE__, __LINE__, '['.date('m/d/Y:H:i:s', time())."]:New client connected: {$ip}");
-
-               // Notify all chatter
-               if (count($clients) > 2) {
-                       foreach ($clients as $send_sock) {
-                               if ($send_sock != $mainSocket && $send_sock != $new_sock) {
-                                       socket_write($send_sock, "Server: Chatter has joined from {$ip}. There are now ".(count($clients) - 1)." clients.\n");
-                               }
-                       }
-               }
-
-               // remove the listening socket from the clients-with-data array
-               $key = array_search($mainSocket, $read);
-               unset($read[$key]);
-       }
-
-       // loop through all the clients that have data to read from
-       foreach ($read as $read_sock) {
-               // Get client data
-               socket_getpeername($read_sock, $ip);
-
-               // read until newline or 1024 bytes
-               // socket_read while show errors when the client is disconnected, so silence the error messages
-               $data = @socket_read($read_sock, 1024, PHP_NORMAL_READ);
-
-               // check if the client is disconnected
-               if (($data === FALSE) || (in_array(strtolower(trim($data)), $leaving))) {
-
-                       // remove client for $clients array
-                       $key = array_search($read_sock, $clients);
-                       unset($clients[$key]);
-                       out(__FILE__, __LINE__, '['.date('m/d/Y:H:i:s', time())."]:Client from {$ip} disconnected. Left: ".(count($clients) - 1)."");
-
-                       // Notify all chatter
-                       if (count($clients) > 1) {
-                               foreach ($clients as $send_sock) {
-                                       if ($send_sock != $mainSocket) {
-                                               socket_write($send_sock, "Server: Chatter from {$ip} has logged out. ".(count($clients) - 1)." client(s) left.\n");
-                                       }
-                               }
-                       }
-
-                       // continue to the next client to read from, if any
-                       socket_write($read_sock, "Server: Good bye.\n");
-                       socket_shutdown($read_sock, 2);
-                       socket_close($read_sock);
-                       continue;
-               } elseif (in_array(trim($data), $shutdown)) {
-                       // Is he allowed to shutdown?
-                       if (!in_array($ip, $masters)) {
-                               out(__FILE__, __LINE__, '['.date('m/d/Y:H:i:s', time())."]:Client {$ip} has tried to shutdown the server!");
-                               socket_write($read_sock, "Server: You are not allowed to shutdown the server!\n");
-                               $data = "";
-                               continue;
-                       }
-
-                       // Close all connections a leave here
-                       foreach ($clients as $client) {
-                               // Send message to client
-                               if ($client !== $mainSocket && $client != $read_sock) {
-                                       socket_write($client, "Server: Shutting down! Thank you for joining us.\n");
-                               }
-
-                               // Quit him
-                               socket_shutdown($client, 2);
-                               socket_close($client);
-                       } // end foreach
-
-                       // Leave the loop
-                       $data = "";
-                       $clients = array();
-                       continue;
-               }
-
-               // trim off the trailing/beginning white spaces
-               $data = trim($data);
-
-               // Test for HTML codes
-               $tags = strip_tags($data);
-
-               // check if there is any data after trimming off the spaces
-               if (!empty($data) && $tags == $data && count($clients) > 2) {
-                       // Send confirmation to "chatter"
-                       socket_write($read_sock, "\nServer: Message accepted.\n");
-
-                       // send this to all the clients in the $clients array (except the first one, which is a listening socket)
-                       foreach ($clients as $send_sock) {
-
-                               // if its the listening sock or the client that we got the message from, go to the next one in the list
-                               if ($send_sock == $mainSocket || $send_sock == $read_sock) {
-                                       continue;
-                               } // END - if
-
-                               // write the message to the client -- add a newline character to the end of the message
-                               socket_write($send_sock, "{$ip}:{$data}\n");
-
-                       } // end of broadcast foreach
-               } elseif ($tags != $data) {
-                       // HTML codes are not allowed
-                       out(__FILE__, __LINE__, '['.date('m/d/Y:H:i:s', time())."]:Client {$ip} has entered HTML code!");
-                       socket_write($read_sock, "Server: HTML is forbidden!\n");
-               } elseif ((count($clients) == 2) && ($read_sock != $mainSocket)) {
-                       // No one else will hear the "chatter"
-                       out(__FILE__, __LINE__, '['.date('m/d/Y:H:i:s', time())."]:Client {$ip} speaks with himself.");
-                       socket_write($read_sock, "Server: No one will hear you!\n");
-               }
-       } // end of reading foreach
-}
-
-// close the listening socket
-socket_close($mainSocket);
-
-?>
-// Own namespace
-namespace Hub\Listener\;
-
-// Import application-specific stuff
-use Hub\Helper\Node\NodeHelper;
-use Hub\Listener\BaseListener;
-use Hub\Listener\Listenable;
-
-// Import framework stuff
-use CoreFramework\Visitor\Visitable;
-
-<?php
-/**
- * A TCP ??? listener
- *
- * @author             Roland Haeder <webmaster@ship-simu.org>
- * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team
- * @license            GNU GPL 3.0 or any newer version
- * @link               http://www.ship-simu.org
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-class ???Listener extends BaseListener implements Listenable, Visitable {
-       /**
-        * Protected constructor
-        *
-        * @return      void
-        */
-       protected function __construct () {
-               // Call parent constructor
-               parent::__construct(__CLASS__);
-       }
-
-       /**
-        * Creates an instance of this class
-        *
-        * @param       $nodeInstance           A NodeHelper instance
-        * @return      $listenerInstance       An instance a prepared listener class
-        */
-       public final static function create???Listener (NodeHelper $nodeInstance) {
-               // Get new instance
-               $listenerInstance = new ???Listener();
-
-               // Set the application instance
-               $listenerInstance->setNodeInstance($nodeInstance);
-
-               // Return the prepared instance
-               return $listenerInstance;
-       }
-
-       /**
-        * Initializes the listener by setting up the required socket server
-        *
-        * @return      void
-        * @todo        0% done
-        */
-       public function initListener() {
-               $this->partialStub('Need to implement this method.');
-       }
-
-       /**
-        * "Listens" for incoming network packages
-        *
-        * @return      void
-        * @todo        0% done
-        */
-       public function doListen() {
-               $this->partialStub('Need to implement this method.');
-       }
-}
-
-// [EOF]
-?>
diff --git a/application/hub/classes/handler/network/tcp/class_TcpRawDataHandler.php b/application/hub/classes/handler/network/tcp/class_TcpRawDataHandler.php
deleted file mode 100644 (file)
index 3832dc3..0000000
+++ /dev/null
@@ -1,125 +0,0 @@
-<?php
-// Own namespace
-namespace Hub\Handler\Network\RawData\Tcp;
-
-// Import application-specific stuff
-use Hub\Handler\Network\RawData\BaseRawDataHandler;
-use Hub\Network\Networkable;
-use Hub\Pool\Poolable;
-
-/**
- * A TCP raw data handler
- *
- * @author             Roland Haeder <webmaster@shipsimu.org>
- * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team
- * @license            GNU GPL 3.0 or any newer version
- * @link               http://www.shipsimu.org
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-class TcpRawDataHandler extends BaseRawDataHandler implements Networkable {
-       /**
-        * Protected constructor
-        *
-        * @return      void
-        */
-       protected function __construct () {
-               // Call parent constructor
-               parent::__construct(__CLASS__);
-
-               // Set handler name
-               $this->setHandlerName('tcp');
-       }
-
-       /**
-        * Creates an instance of this class
-        *
-        * @return      $handlerInstance        An instance of a Networkable class
-        */
-       public static final function createTcpRawDataHandler () {
-               // Get new instance
-               $handlerInstance = new TcpRawDataHandler();
-
-               // Return the prepared instance
-               return $handlerInstance;
-       }
-
-       /**
-        * Processes raw data from given resource. This is mostly useful for TCP
-        * package handling and is implemented in the TcpListener class
-        *
-        * @param       $resource       A valid socket resource array
-        * @return      void
-        */
-       public function processRawDataFromResource (array $socketArray) {
-               // Check the resource
-               if ((!isset($socketArray[Poolable::SOCKET_ARRAY_INSTANCE])) || (!is_resource($socketArray[Poolable::SOCKET_ARRAY_INSTANCE]))) {
-                       // Throw an exception
-                       throw new InvalidResourceException($this, self::EXCEPTION_INVALID_RESOURCE);
-               } // END - if
-
-               // Reset error code to unhandled
-               $this->setErrorCode(self::SOCKET_ERROR_UNHANDLED);
-
-               // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('TCP-HANDLER: Handling TCP package from resource=' . $socketArray[Poolable::SOCKET_ARRAY_INSTANCE] . ',type=' . $socketArray[Poolable::SOCKET_ARRAY_CONN_TYPE] . ',last error=' . socket_strerror($this->lastSocketError));
-
-               /*
-                * Read the raw data from socket. If you change PHP_BINARY_READ to
-                * PHP_NORMAL_READ, this line will endless block. This script does only
-                * provide simultanous threads, not real.
-                */
-               $rawData = socket_read($socketArray[Poolable::SOCKET_ARRAY_INSTANCE], $this->getConfigInstance()->getConfigEntry('tcp_buffer_length'), PHP_BINARY_READ);
-
-               // Get socket error code back
-               $this->lastSocketError = socket_last_error($socketArray[Poolable::SOCKET_ARRAY_INSTANCE]);
-
-               // Debug output of read data length
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('TCP-HANDLER: rawData[' . gettype($rawData) . ']=' . strlen($rawData) . ',MD5=' . md5($rawData) . ',resource=' . $socketArray[Poolable::SOCKET_ARRAY_INSTANCE] . ',error=' . socket_strerror($this->lastSocketError));
-               //* NOISY-DEBUG: */ if ($rawData !== FALSE) self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('TCP-HANDLER: rawData=' . $rawData);
-
-               // Is it valid?
-               if ($this->lastSocketError == 11) {
-                       // Debug message
-                       //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('TCP-HANDLER: Ignoring error 11 (Resource temporary unavailable) from socket resource=' . $socketArray[Poolable::SOCKET_ARRAY_INSTANCE]);
-
-                       /*
-                        * Error code 11 (Resource temporary unavailable) can be safely
-                        * ignored on non-blocking sockets. The socket is currently not
-                        * sending any data.
-                        */
-                        socket_clear_error($socketArray[Poolable::SOCKET_ARRAY_INSTANCE]);
-
-                        // Skip any further processing
-                        return;
-               } elseif (($rawData === FALSE) || ($this->lastSocketError > 0)) {
-                       // Network error or connection lost
-                       $this->setErrorCode($this->lastSocketError);
-               } elseif (empty($rawData)) {
-                       // The peer did send nothing to us which is now being ignored
-                       return;
-               } else {
-                       /*
-                        * All is fine at this point. So it is okay to add the raw data to
-                        * the stacker. Here it doesn't matter if the raw data is a
-                        * well-formed BASE64-encoded message with start and markers. This
-                        * will be checked later on.
-                        */
-                       //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('TCP-HANDLER: Adding ' . strlen($rawData) . ' bytes to stacker ...');
-                       $this->addRawDataToStacker($rawData);
-               }
-       }
-
-}
diff --git a/application/hub/classes/handler/network/udp/.htaccess b/application/hub/classes/handler/network/udp/.htaccess
deleted file mode 100644 (file)
index 3a42882..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Deny from all
diff --git a/application/hub/classes/handler/network/udp/class_UdpRawDataHandler.php b/application/hub/classes/handler/network/udp/class_UdpRawDataHandler.php
deleted file mode 100644 (file)
index f1aaa66..0000000
+++ /dev/null
@@ -1,81 +0,0 @@
-<?php
-// Own namespace
-namespace Hub\Handler\Network\RawData\Udp;
-
-// Import application-specific stuff
-use Hub\Handler\Network\RawData\BaseRawDataHandler;
-use Hub\Network\Networkable;
-use Hub\Pool\Poolable;
-
-/**
- * A UDP raw data handler
- *
- * @author             Roland Haeder <webmaster@shipsimu.org>
- * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team
- * @license            GNU GPL 3.0 or any newer version
- * @link               http://www.shipsimu.org
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-class UdpRawDataHandler extends BaseRawDataHandler implements Networkable {
-       /**
-        * Protected constructor
-        *
-        * @return      void
-        */
-       protected function __construct () {
-               // Call parent constructor
-               parent::__construct(__CLASS__);
-
-               // Set handler name
-               $this->setHandlerName('udp');
-       }
-
-       /**
-        * Creates an instance of this class
-        *
-        * @return      $handlerInstance                An instance of a Networkable class
-        */
-       public static final function createUdpRawDataHandler () {
-               // Get new instance
-               $handlerInstance = new UdpRawDataHandler();
-
-               // Return the prepared instance
-               return $handlerInstance;
-       }
-
-       /**
-        * Processes raw data from given resource. This is mostly useful for UDP
-        * package handling and is implemented in the UdpListener class
-        *
-        * @param       $socketArray    A valid socket resource array
-        * @return      void
-        * @throws      InvalidResourceException        If the given resource is invalid
-        * @todo        0%
-        */
-       public function processRawDataFromResource (array $socketArray) {
-               // Check the resource
-               if ((!isset($socketArray[Poolable::SOCKET_ARRAY_INSTANCE])) || (!is_resource($socketArray[Poolable::SOCKET_ARRAY_INSTANCE]))) {
-                       // Throw an exception
-                       throw new InvalidResourceException($this, self::EXCEPTION_INVALID_RESOURCE);
-               } // END - if
-
-               // Implement processing here
-               $this->partialStub('Please implement this method. resource=' . $socketArray[Poolable::SOCKET_ARRAY_INSTANCE] . ',type=' . $socketArray[Poolable::SOCKET_ARRRAY_CONN_TYPE]);
-       }
-}
-
-// [EOF]
-?>
index 8353fa0c996b5be2d3f9b128508057f76d328f0f..a66f951c43f99a87a849ca90066950cf2df56fb6 100644 (file)
@@ -3,13 +3,10 @@
 namespace Hub\Handler\Protocol;
 
 // Import application-specific sutff
+use Hub\Handler\BaseHubHandler;
 use Hub\Handler\Protocol\HandleableProtocol;
-use Hub\Locator\Node\LocateableNode;
 use Hub\Tools\HubTools;
 
-// Import framework stuff
-use CoreFramework\Handler\BaseHandler;
-
 /**
  * A general handler for protocols such as TCP, UDP and others.
  *
@@ -32,12 +29,7 @@ use CoreFramework\Handler\BaseHandler;
  * You should have received a copy of the GNU General Public License
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
-abstract class BaseProtocolHandler extends BaseHandler implements HandleableProtocol {
-       /**
-        * Whole UNL instance
-        */
-       private $universalNodeLocatorInstance = NULL;
-
+abstract class BaseProtocolHandler extends BaseHubHandler implements HandleableProtocol {
        /**
         * Name of used protocol
         */
@@ -54,17 +46,6 @@ abstract class BaseProtocolHandler extends BaseHandler implements HandleableProt
                parent::__construct($className);
        }
 
-       /**
-        * Setter for UNL instance
-        *
-        * @para        $unlInstance    An instance of a LocateableNode class
-        * @return      void
-        */
-       protected final function setUniversalNodeLocatorInstance (LocateableNode $unlInstance) {
-               // Set new UNL data array
-               $this->universalNodeLocatorInstance = $unlInstance;
-       }
-
        /**
         * Validates given UNL very basicly by given regular expression. You
         * normally don't need/want to overwrite this method as this is a very basic
@@ -104,16 +85,6 @@ abstract class BaseProtocolHandler extends BaseHandler implements HandleableProt
                $this->protocolName = $protocolName;
        }
 
-       /**
-        * Getter for UNL instance
-        *
-        * @return      $unlData        An instance of a LocateableNode class
-        */
-       public final function getUniversalNodeLocatorInstance () {
-               // Return UNL data array
-               return $this->universalNodeLocatorInstance;
-       }
-
        /**
         * Default implementation for returning address part, may not be suitable
         * for IPv4/IPv6 protocol handlers. So you have to overwrite (NOT CHANGE!) this method.
index 9a2846c670e453048282dcf50acdae2648827497..0b5036feb452d14c2990da7e77172969b28a6613 100644 (file)
@@ -1,18 +1,19 @@
 <?php
 // Own namespace
-namespace Hub\Handler\Network\;
+namespace Hub\Handler\Network\RawData;
 
 // Import application-specific stuff
+use Hub\Handler\Network\RawData\BaseRawDataHandler;
 use Hub\Network\Networkable;
 
 /**
- * A ??? network package handler
+ * A !!! raw data handler
  *
- * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @author             Roland Haeder <webmaster@shipsimu.org>
  * @version            0.0.0
  * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 Hub Developer Team
  * @license            GNU GPL 3.0 or any newer version
- * @link               http://www.ship-simu.org
+ * @link               http://www.shipsimu.org
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -27,7 +28,7 @@ use Hub\Network\Networkable;
  * You should have received a copy of the GNU General Public License
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
-class ???NetworkPackageHandler extends BaseNetworkPackageHandler implements Networkable {
+class ???RawDataHandler extends BaseRawDataHandler implements Networkable {
        /**
         * Protected constructor
         *
@@ -38,40 +39,30 @@ class ???NetworkPackageHandler extends BaseNetworkPackageHandler implements Netw
                parent::__construct(__CLASS__);
 
                // Set handler name
-               $this->setHandlerName('!!!');
+               $this->setHandlerName('|||');
        }
 
        /**
         * Creates an instance of this class
         *
-        * @return      $handlerInstance                An instance of a Networkable class
+        * @return      $handlerInstance        An instance of a Networkable class
         */
-       public final static function create???NetworkPackageHandler () {
+       public static final function create???RawDataHandler () {
                // Get new instance
-               $handlerInstance = new ???NetworkPackageHandler();
+               $handlerInstance = new ???RawDataHandler();
 
                // Return the prepared instance
                return $handlerInstance;
        }
 
        /**
-        * Processes a package from given resource. This is mostly useful for TCP
-        * package handling and is implemented in the TcpListener class
+        * Processes raw data from given resource. This is mostly useful for TCP
+        * package handling and is implemented in the ???Listener class
         *
-        * @param       $resource       A valid resource identifier
+        * @param       $resource       A valid socket resource array
         * @return      void
-        * @throws      InvalidResourceException        If the given resource is invalid
-        * @todo        0%
         */
-       public function processResourcePackage ($resource) {
-               // Check the resource
-               if (!is_resource($resource)) {
-                       // Throw an exception
-                       throw new InvalidResourceException($this, self::EXCEPTION_INVALID_RESOURCE);
-               } // END - if
-
-               // Implement processing here
-               $this->partialStub('Please implement this method.');
+       public function processRawDataFromResource (array $socketArray) {
        }
 
 }
diff --git a/application/hub/classes/handler/raw_data/class_BaseDataHandler.php b/application/hub/classes/handler/raw_data/class_BaseDataHandler.php
deleted file mode 100644 (file)
index 6b06d89..0000000
+++ /dev/null
@@ -1,201 +0,0 @@
-<?php
-// Own namespace
-namespace Hub\Handler\Data;
-
-// Import application-specific stuff
-use Hub\Factory\Node\NodeObjectFactory;
-use Hub\Network\Deliver\Deliverable;
-
-// Import framework stuff
-use CoreFramework\Factory\ObjectFactory;
-use CoreFramework\Generic\FrameworkException;
-use CoreFramework\Handler\BaseHandler;
-
-/**
- * A general data Handler
- *
- * @author             Roland Haeder <webmaster@shipsimu.org>
- * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 Hub Developer Team
- * @license            GNU GPL 3.0 or any newer version
- * @link               http://www.shipsimu.org
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-abstract class BaseDataHandler extends BaseHandler {
-       /**
-        * Last exception instance from database layer or NULL (default)
-        */
-       private $lastException = NULL;
-
-       /**
-        * Array with search criteria elements
-        */
-       protected $searchData = array();
-
-       /**
-        * Array with all data XML nodes (which hold the actual data) and their values
-        */
-       protected $messageDataElements = array();
-
-       /**
-        * Array for translating message data elements (other node's data mostly)
-        * into configuration elements.
-        */
-       protected $messageToConfig = array();
-
-       /**
-        * Array for copying configuration entries
-        */
-       protected $configCopy = array();
-
-       /**
-        * Protected constructor
-        *
-        * @param       $className      Name of the class
-        * @return      void
-        */
-       protected function __construct ($className) {
-               // Call parent constructor
-               parent::__construct($className);
-       }
-
-       /**
-        * Getter for search data array
-        *
-        * @return      $searchData             Search data array
-        */
-       public final function getSearchData () {
-               return $this->searchData;
-       }
-
-       /**
-        * Getter for last exception
-        *
-        * @return      $lastException  Last thrown exception
-        */
-       public final function getLastException () {
-               return $this->lastException;
-       }
-
-       /**
-        * Setter for last exception
-        *
-        * @param       $lastException  Last thrown exception
-        * @return      void
-        */
-       public final function setLastException (FrameworkException $exceptionInstance = NULL) {
-               $this->lastException = $exceptionInstance;
-       }
-
-       /**
-        * Prepares a message as answer for given message data for delivery.
-        *
-        * @param       $messageData            An array with all message data
-        * @param       $packageInstance        An instance of a Deliverable instance
-        * @return      void
-        */
-       protected function prepareAnswerMessage (array $messageData, Deliverable $packageInstance) {
-               // Debug message
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('MESSAGE-HANDLER: Going to send an answer message for ' . $this->getHandlerName() . ' ...');
-
-               // Get a helper instance based on this handler's name
-               $helperInstance = ObjectFactory::createObjectByConfiguredName('node_answer_' . $this->getHandlerName() . '_helper_class', array($messageData));
-
-               // Get node instance
-               $nodeInstance = NodeObjectFactory::createNodeInstance();
-
-               // Load descriptor XML
-               $helperInstance->loadDescriptorXml($nodeInstance);
-
-               /*
-                * Set missing (temporary) configuration data, mostly it needs to be
-                * copied from message data array.
-                */
-               $this->initMessageConfigurationData($messageData);
-
-               // Compile any configuration variables
-               $helperInstance->getTemplateInstance()->compileConfigInVariables();
-
-               // Deliver the package
-               $helperInstance->sendPackage($nodeInstance);
-
-               /*
-                * Remove temporary configuration
-                */
-               $this->removeMessageConfigurationData($messageData);
-
-               // Debug message
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('MESSAGE-HANDLER: Answer message has been prepared.');
-       }
-
-       /**
-        * Prepares the next message
-        *
-        * @param       $messageData            An array with all message data
-        * @param       $packageInstance        An instance of a Deliverable instance
-        * @return      void
-        */
-       protected function prepareNextMessage (array $messageData, Deliverable $packageInstance) {
-               // Debug message
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('MESSAGE-HANDLER: Going to send next message ...');
-
-               // Get a helper instance based on this handler's name
-               $helperInstance = ObjectFactory::createObjectByConfiguredName('node_next_' . $this->getHandlerName() . '_helper_class', array($messageData));
-
-               // Get node instance
-               $nodeInstance = NodeObjectFactory::createNodeInstance();
-
-               // Load descriptor XML
-               $helperInstance->loadDescriptorXml($nodeInstance);
-
-               /*
-                * Set missing (temporary) configuration data, mostly it needs to be
-                * copied from message data array.
-                */
-               $this->initMessageConfigurationData($messageData);
-
-               // Compile any configuration variables
-               $helperInstance->getTemplateInstance()->compileConfigInVariables();
-
-               // Deliver the package
-               $helperInstance->sendPackage($nodeInstance);
-
-               /*
-                * Remove temporary configuration
-                */
-               $this->removeMessageConfigurationData($messageData);
-
-               // Debug message
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('MESSAGE-HANDLER: Next message has been prepared.');
-       }
-
-       /**
-        * Initializes configuration data from given message data array
-        *
-        * @param       $messageData    An array with all message data
-        * @return      void
-        */
-       abstract protected function initMessageConfigurationData (array $messageData);
-
-       /**
-        * Removes configuration data with given message data array from global
-        * configuration
-        *
-        * @param       $messageData    An array with all message data
-        * @return      void
-        */
-       abstract protected function removeMessageConfigurationData (array $messageData);
-
-}
diff --git a/application/hub/classes/handler/raw_data/class_BaseRawDataHandler.php b/application/hub/classes/handler/raw_data/class_BaseRawDataHandler.php
new file mode 100644 (file)
index 0000000..b05eb66
--- /dev/null
@@ -0,0 +1,177 @@
+<?php
+// Own namespace
+namespace Hub\Handler\Network\RawData;
+
+// Import application-specific stuff
+use Hub\Container\Socket\StorableSocket;
+use Hub\Factory\Node\NodeObjectFactory;
+use Hub\Generic\HubInterface;
+use Hub\Handler\BaseHubHandler;
+use Hub\Network\Package\NetworkPackage;
+
+// Import framework stuff
+use CoreFramework\Factory\ObjectFactory;
+use CoreFramework\Generic\UnsupportedOperationException;
+
+/**
+ * A general Handler for raw data from sockets
+ *
+ * @author             Roland Haeder <webmaster@shipsimu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 Hub Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.shipsimu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+class BaseRawDataHandler extends BaseHubHandler implements HubInterface {
+       // - Package errors
+       const PACKAGE_ERROR_INVALID_DATA       = 'invalid_data';    // Invalid data in package found
+       const PACKAGE_ERROR_INCOMPLETE_DATA    = 'incomplete_data'; // Incomplete data sent (e.g. field is missing)
+       const PACKAGE_ERROR_INVALID_CONTENT    = 'invalid_content'; // Content is invalid (e.g. not well-formed)
+       const PACKAGE_ERROR_RECIPIENT_MISMATCH = 'recipient_error'; // Recipient is not us
+       const PACKAGE_LEVEL_CHECK_OKAY         = 'checked_package'; // Package is fine
+
+       // Package data
+       const PACKAGE_RAW_DATA   = 'raw_data';
+       const PACKAGE_ERROR_CODE = 'error_code';
+
+       // Start/end marker
+       const STREAM_START_MARKER = '[[S]]';
+       const STREAM_END_MARKER   = '[[E]]';
+
+       /**
+        * Stacker for raw data
+        */
+       const STACKER_NAME_RAW_DATA = 'raw_data';
+
+       /**
+        * Error code from socket
+        */
+       private $errorCode = -1;
+
+       /**
+        * Protected constructor
+        *
+        * @param       $className      Name of the class
+        * @return      void
+        */
+       protected function __construct ($className) {
+               // Call parent constructor
+               parent::__construct($className);
+
+               // Set error code to 'unknown'
+               $this->setErrorCode(StorableSocket::SOCKET_ERROR_UNKNOWN);
+
+               // Init stacker instance for processed raw data
+               $stackInstance = ObjectFactory::createObjectByConfiguredName('node_raw_data_stacker_class');
+
+               // Remember this in this package handler
+               $this->setStackInstance($stackInstance);
+
+               // Init stacker
+               $this->initStack();
+       }
+
+       /**
+        * Initializes the stacker for raw data
+        *
+        * @return      void
+        */
+       protected function initStack () {
+               $this->getStackInstance()->initStack(self::STACKER_NAME_RAW_DATA);
+       }
+
+       /**
+        * Adds given raw data to the raw data stacker
+        *
+        * @param       $rawData        raw data from the socket resource
+        * @return      void
+        */
+       protected function addRawDataToStacker ($rawData) {
+               /*
+                * Add the deocoded data and error code to the stacker so other classes
+                * (e.g. NetworkPackage) can "pop" it from the stacker.
+                */
+               $this->getStackInstance()->pushNamed(self::STACKER_NAME_RAW_DATA, array(
+                       self::PACKAGE_RAW_DATA   => $rawData,
+                       self::PACKAGE_ERROR_CODE => $this->getErrorCode()
+               ));
+       }
+
+       /**
+        * Checks whether raw data is pending for further processing.
+        *
+        * @return      $isPending      Whether raw data is pending
+        */
+       public function isRawDataPending () {
+               // Does the stacker have some entries (not empty)?
+               $isPending = (!$this->getStackInstance()->isStackEmpty(self::STACKER_NAME_RAW_DATA));
+
+               // Return it
+               return $isPending;
+       }
+
+       /**
+        * "Getter" for next raw data from the stacker
+        *
+        * @return      $rawData        Raw data from the stacker
+        */
+       public function getNextRawData () {
+               // "Pop" the raw data from the stacker
+               $rawData = $this->getStackInstance()->popNamed(self::STACKER_NAME_RAW_DATA);
+
+               // And return it
+               return $rawData;
+       }
+
+       /**
+        * Checks whether the 'recipient' field matches our own an universal node
+        * locator.
+        *
+        * @param       $packageData    Raw package data
+        * @return      $matches                Whether it matches
+        * @todo        This method will be moved to a better place
+        */
+       protected function ifRecipientMatchesOwnUniversalNodeLocator (array $packageData) {
+               // Construct own address first
+               $ownAddress = NodeObjectFactory::createNodeInstance()->determineUniversalNodeLocator();
+
+               // Does it match?
+               $matches = ($ownAddress === $packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT]);
+
+               // Return result
+               return $matches;
+       }
+
+       /**
+        * Setter for error code
+        *
+        * @param       $errorCode      The error code we shall set
+        * @return      void
+        */
+       public final function setErrorCode ($errorCode) {
+               $this->errorCode = $errorCode;
+       }
+
+       /**
+        * Getter for error code
+        *
+        * @return      $errorCode      The error code
+        */
+       public final function getErrorCode () {
+               return $this->errorCode;
+       }
+
+}
diff --git a/application/hub/classes/handler/raw_data/network/.htaccess b/application/hub/classes/handler/raw_data/network/.htaccess
deleted file mode 100644 (file)
index 3a42882..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Deny from all
diff --git a/application/hub/classes/handler/raw_data/network/class_ b/application/hub/classes/handler/raw_data/network/class_
deleted file mode 100644 (file)
index 0b5036f..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-<?php
-// Own namespace
-namespace Hub\Handler\Network\RawData;
-
-// Import application-specific stuff
-use Hub\Handler\Network\RawData\BaseRawDataHandler;
-use Hub\Network\Networkable;
-
-/**
- * A !!! raw data handler
- *
- * @author             Roland Haeder <webmaster@shipsimu.org>
- * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 Hub Developer Team
- * @license            GNU GPL 3.0 or any newer version
- * @link               http://www.shipsimu.org
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-class ???RawDataHandler extends BaseRawDataHandler implements Networkable {
-       /**
-        * Protected constructor
-        *
-        * @return      void
-        */
-       protected function __construct () {
-               // Call parent constructor
-               parent::__construct(__CLASS__);
-
-               // Set handler name
-               $this->setHandlerName('|||');
-       }
-
-       /**
-        * Creates an instance of this class
-        *
-        * @return      $handlerInstance        An instance of a Networkable class
-        */
-       public static final function create???RawDataHandler () {
-               // Get new instance
-               $handlerInstance = new ???RawDataHandler();
-
-               // Return the prepared instance
-               return $handlerInstance;
-       }
-
-       /**
-        * Processes raw data from given resource. This is mostly useful for TCP
-        * package handling and is implemented in the ???Listener class
-        *
-        * @param       $resource       A valid socket resource array
-        * @return      void
-        */
-       public function processRawDataFromResource (array $socketArray) {
-       }
-
-}
diff --git a/application/hub/classes/handler/raw_data/network/class_BaseRawDataHandler.php b/application/hub/classes/handler/raw_data/network/class_BaseRawDataHandler.php
deleted file mode 100644 (file)
index 914badd..0000000
+++ /dev/null
@@ -1,175 +0,0 @@
-<?php
-// Own namespace
-namespace Hub\Handler\Network\RawData;
-
-// Import application-specific stuff
-use Hub\Container\Socket\StorableSocket;
-use Hub\Factory\Node\NodeObjectFactory;
-use Hub\Network\Package\NetworkPackage;
-
-// Import framework stuff
-use CoreFramework\Factory\ObjectFactory;
-use CoreFramework\Handler\BaseHandler;
-
-/**
- * A general Handler for raw data from sockets
- *
- * @author             Roland Haeder <webmaster@shipsimu.org>
- * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 Hub Developer Team
- * @license            GNU GPL 3.0 or any newer version
- * @link               http://www.shipsimu.org
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-class BaseRawDataHandler extends BaseHandler {
-       // - Package errors
-       const PACKAGE_ERROR_INVALID_DATA       = 'invalid_data';    // Invalid data in package found
-       const PACKAGE_ERROR_INCOMPLETE_DATA    = 'incomplete_data'; // Incomplete data sent (e.g. field is missing)
-       const PACKAGE_ERROR_INVALID_CONTENT    = 'invalid_content'; // Content is invalid (e.g. not well-formed)
-       const PACKAGE_ERROR_RECIPIENT_MISMATCH = 'recipient_error'; // Recipient is not us
-       const PACKAGE_LEVEL_CHECK_OKAY         = 'checked_package'; // Package is fine
-
-       // Package data
-       const PACKAGE_RAW_DATA   = 'raw_data';
-       const PACKAGE_ERROR_CODE = 'error_code';
-
-       // Start/end marker
-       const STREAM_START_MARKER = '[[S]]';
-       const STREAM_END_MARKER   = '[[E]]';
-
-       /**
-        * Stacker for raw data
-        */
-       const STACKER_NAME_RAW_DATA = 'raw_data';
-
-       /**
-        * Error code from socket
-        */
-       private $errorCode = -1;
-
-       /**
-        * Protected constructor
-        *
-        * @param       $className      Name of the class
-        * @return      void
-        */
-       protected function __construct ($className) {
-               // Call parent constructor
-               parent::__construct($className);
-
-               // Set error code to 'unknown'
-               $this->setErrorCode(StorableSocket::SOCKET_ERROR_UNKNOWN);
-
-               // Init stacker instance for processed raw data
-               $stackInstance = ObjectFactory::createObjectByConfiguredName('node_raw_data_stacker_class');
-
-               // Remember this in this package handler
-               $this->setStackInstance($stackInstance);
-
-               // Init stacker
-               $this->initStack();
-       }
-
-       /**
-        * Initializes the stacker for raw data
-        *
-        * @return      void
-        */
-       protected function initStack () {
-               $this->getStackInstance()->initStack(self::STACKER_NAME_RAW_DATA);
-       }
-
-       /**
-        * Adds given raw data to the raw data stacker
-        *
-        * @param       $rawData        raw data from the socket resource
-        * @return      void
-        */
-       protected function addRawDataToStacker ($rawData) {
-               /*
-                * Add the deocoded data and error code to the stacker so other classes
-                * (e.g. NetworkPackage) can "pop" it from the stacker.
-                */
-               $this->getStackInstance()->pushNamed(self::STACKER_NAME_RAW_DATA, array(
-                       self::PACKAGE_RAW_DATA   => $rawData,
-                       self::PACKAGE_ERROR_CODE => $this->getErrorCode()
-               ));
-       }
-
-       /**
-        * Checks whether raw data is pending for further processing.
-        *
-        * @return      $isPending      Whether raw data is pending
-        */
-       public function isRawDataPending () {
-               // Does the stacker have some entries (not empty)?
-               $isPending = (!$this->getStackInstance()->isStackEmpty(self::STACKER_NAME_RAW_DATA));
-
-               // Return it
-               return $isPending;
-       }
-
-       /**
-        * "Getter" for next raw data from the stacker
-        *
-        * @return      $rawData        Raw data from the stacker
-        */
-       public function getNextRawData () {
-               // "Pop" the raw data from the stacker
-               $rawData = $this->getStackInstance()->popNamed(self::STACKER_NAME_RAW_DATA);
-
-               // And return it
-               return $rawData;
-       }
-
-       /**
-        * Checks whether the 'recipient' field matches our own an universal node
-        * locator.
-        *
-        * @param       $packageData    Raw package data
-        * @return      $matches                Whether it matches
-        * @todo        This method will be moved to a better place
-        */
-       protected function ifRecipientMatchesOwnUniversalNodeLocator (array $packageData) {
-               // Construct own address first
-               $ownAddress = NodeObjectFactory::createNodeInstance()->determineUniversalNodeLocator();
-
-               // Does it match?
-               $matches = ($ownAddress === $packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT]);
-
-               // Return result
-               return $matches;
-       }
-
-       /**
-        * Setter for error code
-        *
-        * @param       $errorCode      The error code we shall set
-        * @return      void
-        */
-       public final function setErrorCode ($errorCode) {
-               $this->errorCode = $errorCode;
-       }
-
-       /**
-        * Getter for error code
-        *
-        * @return      $errorCode      The error code
-        */
-       public final function getErrorCode () {
-               return $this->errorCode;
-       }
-
-}
diff --git a/application/hub/classes/handler/raw_data/socket/.htaccess b/application/hub/classes/handler/raw_data/socket/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/classes/handler/raw_data/socket/class_SocketRawDataHandler.php b/application/hub/classes/handler/raw_data/socket/class_SocketRawDataHandler.php
new file mode 100644 (file)
index 0000000..e02f2f1
--- /dev/null
@@ -0,0 +1,71 @@
+<?php
+// Own namespace
+namespace Hub\Handler\Network\Socket\RawData;
+
+// Import application-specific stuff
+use Hub\Handler\Network\RawData\BaseRawDataHandler;
+use Hub\Network\Networkable;
+
+/**
+ * A file-based socket raw data handler
+ *
+ * @author             Roland Haeder <webmaster@shipsimu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.shipsimu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+class SocketRawDataHandler extends BaseRawDataHandler implements Networkable {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+
+               // Set handler name
+               $this->setHandlerName('socket');
+       }
+
+       /**
+        * Creates an instance of this class
+        *
+        * @return      $handlerInstance        An instance of a Networkable class
+        */
+       public static final function createSocketRawDataHandler () {
+               // Get new instance
+               $handlerInstance = new SocketRawDataHandler();
+
+               // Return the prepared instance
+               return $handlerInstance;
+       }
+
+       /**
+        * Processes raw data from given resource. This is mostly useful for TCP
+        * package handling and is implemented in the ???Listener class
+        *
+        * @param       $resource       A valid socket resource array
+        * @return      void
+        */
+       public function processRawDataFromResource (array $socketArray) {
+               $this->partialStub('socketArray=' . print_r($socketArray, TRUE));
+       }
+}
+
+// [EOF]
+?>
diff --git a/application/hub/classes/handler/raw_data/tcp/.htaccess b/application/hub/classes/handler/raw_data/tcp/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/classes/handler/raw_data/tcp/class_ b/application/hub/classes/handler/raw_data/tcp/class_
new file mode 100644 (file)
index 0000000..c09a61e
--- /dev/null
@@ -0,0 +1,220 @@
+while (count($clients) > 0) {
+       // create a copy, so $clients doesn't get modified by socket_select()
+       $read = $clients;
+
+       // get a list of all the clients that have data to be read from
+       // if there are no clients with data, go to next iteration
+       $left = @socket_select($read, $write = null, $except = null, 0, 150);
+       if ($left < 1) {
+               continue;
+       }
+
+       // check if there is a client trying to connect
+       if (in_array($mainSocket, $read)) {
+               // accept the client, and add him to the $clients array
+               $new_sock = socket_accept($mainSocket);
+               $clients[] = $new_sock;
+
+               // send the client a welcome message
+               socket_write($new_sock, "No noobs, but I'll make an exception. :)\n".
+               "There are ".(count($clients) - 1)." client(s) connected to the server.\n");
+
+               socket_getpeername($new_sock, $ip);
+               out(__FILE__, __LINE__, '['.date('m/d/Y:H:i:s', time())."]:New client connected: {$ip}");
+
+               // Notify all chatter
+               if (count($clients) > 2) {
+                       foreach ($clients as $send_sock) {
+                               if ($send_sock != $mainSocket && $send_sock != $new_sock) {
+                                       socket_write($send_sock, "Server: Chatter has joined from {$ip}. There are now ".(count($clients) - 1)." clients.\n");
+                               }
+                       }
+               }
+
+               // remove the listening socket from the clients-with-data array
+               $key = array_search($mainSocket, $read);
+               unset($read[$key]);
+       }
+
+       // loop through all the clients that have data to read from
+       foreach ($read as $read_sock) {
+               // Get client data
+               socket_getpeername($read_sock, $ip);
+
+               // read until newline or 1024 bytes
+               // socket_read while show errors when the client is disconnected, so silence the error messages
+               $data = @socket_read($read_sock, 1024, PHP_NORMAL_READ);
+
+               // check if the client is disconnected
+               if (($data === FALSE) || (in_array(strtolower(trim($data)), $leaving))) {
+
+                       // remove client for $clients array
+                       $key = array_search($read_sock, $clients);
+                       unset($clients[$key]);
+                       out(__FILE__, __LINE__, '['.date('m/d/Y:H:i:s', time())."]:Client from {$ip} disconnected. Left: ".(count($clients) - 1)."");
+
+                       // Notify all chatter
+                       if (count($clients) > 1) {
+                               foreach ($clients as $send_sock) {
+                                       if ($send_sock != $mainSocket) {
+                                               socket_write($send_sock, "Server: Chatter from {$ip} has logged out. ".(count($clients) - 1)." client(s) left.\n");
+                                       }
+                               }
+                       }
+
+                       // continue to the next client to read from, if any
+                       socket_write($read_sock, "Server: Good bye.\n");
+                       socket_shutdown($read_sock, 2);
+                       socket_close($read_sock);
+                       continue;
+               } elseif (in_array(trim($data), $shutdown)) {
+                       // Is he allowed to shutdown?
+                       if (!in_array($ip, $masters)) {
+                               out(__FILE__, __LINE__, '['.date('m/d/Y:H:i:s', time())."]:Client {$ip} has tried to shutdown the server!");
+                               socket_write($read_sock, "Server: You are not allowed to shutdown the server!\n");
+                               $data = "";
+                               continue;
+                       }
+
+                       // Close all connections a leave here
+                       foreach ($clients as $client) {
+                               // Send message to client
+                               if ($client !== $mainSocket && $client != $read_sock) {
+                                       socket_write($client, "Server: Shutting down! Thank you for joining us.\n");
+                               }
+
+                               // Quit him
+                               socket_shutdown($client, 2);
+                               socket_close($client);
+                       } // end foreach
+
+                       // Leave the loop
+                       $data = "";
+                       $clients = array();
+                       continue;
+               }
+
+               // trim off the trailing/beginning white spaces
+               $data = trim($data);
+
+               // Test for HTML codes
+               $tags = strip_tags($data);
+
+               // check if there is any data after trimming off the spaces
+               if (!empty($data) && $tags == $data && count($clients) > 2) {
+                       // Send confirmation to "chatter"
+                       socket_write($read_sock, "\nServer: Message accepted.\n");
+
+                       // send this to all the clients in the $clients array (except the first one, which is a listening socket)
+                       foreach ($clients as $send_sock) {
+
+                               // if its the listening sock or the client that we got the message from, go to the next one in the list
+                               if ($send_sock == $mainSocket || $send_sock == $read_sock) {
+                                       continue;
+                               } // END - if
+
+                               // write the message to the client -- add a newline character to the end of the message
+                               socket_write($send_sock, "{$ip}:{$data}\n");
+
+                       } // end of broadcast foreach
+               } elseif ($tags != $data) {
+                       // HTML codes are not allowed
+                       out(__FILE__, __LINE__, '['.date('m/d/Y:H:i:s', time())."]:Client {$ip} has entered HTML code!");
+                       socket_write($read_sock, "Server: HTML is forbidden!\n");
+               } elseif ((count($clients) == 2) && ($read_sock != $mainSocket)) {
+                       // No one else will hear the "chatter"
+                       out(__FILE__, __LINE__, '['.date('m/d/Y:H:i:s', time())."]:Client {$ip} speaks with himself.");
+                       socket_write($read_sock, "Server: No one will hear you!\n");
+               }
+       } // end of reading foreach
+}
+
+// close the listening socket
+socket_close($mainSocket);
+
+?>
+// Own namespace
+namespace Hub\Listener\;
+
+// Import application-specific stuff
+use Hub\Helper\Node\NodeHelper;
+use Hub\Listener\BaseListener;
+use Hub\Listener\Listenable;
+
+// Import framework stuff
+use CoreFramework\Visitor\Visitable;
+
+<?php
+/**
+ * A TCP ??? listener
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class ???Listener extends BaseListener implements Listenable, Visitable {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+       }
+
+       /**
+        * Creates an instance of this class
+        *
+        * @param       $nodeInstance           A NodeHelper instance
+        * @return      $listenerInstance       An instance a prepared listener class
+        */
+       public final static function create???Listener (NodeHelper $nodeInstance) {
+               // Get new instance
+               $listenerInstance = new ???Listener();
+
+               // Set the application instance
+               $listenerInstance->setNodeInstance($nodeInstance);
+
+               // Return the prepared instance
+               return $listenerInstance;
+       }
+
+       /**
+        * Initializes the listener by setting up the required socket server
+        *
+        * @return      void
+        * @todo        0% done
+        */
+       public function initListener() {
+               $this->partialStub('Need to implement this method.');
+       }
+
+       /**
+        * "Listens" for incoming network packages
+        *
+        * @return      void
+        * @todo        0% done
+        */
+       public function doListen() {
+               $this->partialStub('Need to implement this method.');
+       }
+}
+
+// [EOF]
+?>
diff --git a/application/hub/classes/handler/raw_data/tcp/class_TcpRawDataHandler.php b/application/hub/classes/handler/raw_data/tcp/class_TcpRawDataHandler.php
new file mode 100644 (file)
index 0000000..3832dc3
--- /dev/null
@@ -0,0 +1,125 @@
+<?php
+// Own namespace
+namespace Hub\Handler\Network\RawData\Tcp;
+
+// Import application-specific stuff
+use Hub\Handler\Network\RawData\BaseRawDataHandler;
+use Hub\Network\Networkable;
+use Hub\Pool\Poolable;
+
+/**
+ * A TCP raw data handler
+ *
+ * @author             Roland Haeder <webmaster@shipsimu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.shipsimu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+class TcpRawDataHandler extends BaseRawDataHandler implements Networkable {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+
+               // Set handler name
+               $this->setHandlerName('tcp');
+       }
+
+       /**
+        * Creates an instance of this class
+        *
+        * @return      $handlerInstance        An instance of a Networkable class
+        */
+       public static final function createTcpRawDataHandler () {
+               // Get new instance
+               $handlerInstance = new TcpRawDataHandler();
+
+               // Return the prepared instance
+               return $handlerInstance;
+       }
+
+       /**
+        * Processes raw data from given resource. This is mostly useful for TCP
+        * package handling and is implemented in the TcpListener class
+        *
+        * @param       $resource       A valid socket resource array
+        * @return      void
+        */
+       public function processRawDataFromResource (array $socketArray) {
+               // Check the resource
+               if ((!isset($socketArray[Poolable::SOCKET_ARRAY_INSTANCE])) || (!is_resource($socketArray[Poolable::SOCKET_ARRAY_INSTANCE]))) {
+                       // Throw an exception
+                       throw new InvalidResourceException($this, self::EXCEPTION_INVALID_RESOURCE);
+               } // END - if
+
+               // Reset error code to unhandled
+               $this->setErrorCode(self::SOCKET_ERROR_UNHANDLED);
+
+               // Debug message
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('TCP-HANDLER: Handling TCP package from resource=' . $socketArray[Poolable::SOCKET_ARRAY_INSTANCE] . ',type=' . $socketArray[Poolable::SOCKET_ARRAY_CONN_TYPE] . ',last error=' . socket_strerror($this->lastSocketError));
+
+               /*
+                * Read the raw data from socket. If you change PHP_BINARY_READ to
+                * PHP_NORMAL_READ, this line will endless block. This script does only
+                * provide simultanous threads, not real.
+                */
+               $rawData = socket_read($socketArray[Poolable::SOCKET_ARRAY_INSTANCE], $this->getConfigInstance()->getConfigEntry('tcp_buffer_length'), PHP_BINARY_READ);
+
+               // Get socket error code back
+               $this->lastSocketError = socket_last_error($socketArray[Poolable::SOCKET_ARRAY_INSTANCE]);
+
+               // Debug output of read data length
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('TCP-HANDLER: rawData[' . gettype($rawData) . ']=' . strlen($rawData) . ',MD5=' . md5($rawData) . ',resource=' . $socketArray[Poolable::SOCKET_ARRAY_INSTANCE] . ',error=' . socket_strerror($this->lastSocketError));
+               //* NOISY-DEBUG: */ if ($rawData !== FALSE) self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('TCP-HANDLER: rawData=' . $rawData);
+
+               // Is it valid?
+               if ($this->lastSocketError == 11) {
+                       // Debug message
+                       //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('TCP-HANDLER: Ignoring error 11 (Resource temporary unavailable) from socket resource=' . $socketArray[Poolable::SOCKET_ARRAY_INSTANCE]);
+
+                       /*
+                        * Error code 11 (Resource temporary unavailable) can be safely
+                        * ignored on non-blocking sockets. The socket is currently not
+                        * sending any data.
+                        */
+                        socket_clear_error($socketArray[Poolable::SOCKET_ARRAY_INSTANCE]);
+
+                        // Skip any further processing
+                        return;
+               } elseif (($rawData === FALSE) || ($this->lastSocketError > 0)) {
+                       // Network error or connection lost
+                       $this->setErrorCode($this->lastSocketError);
+               } elseif (empty($rawData)) {
+                       // The peer did send nothing to us which is now being ignored
+                       return;
+               } else {
+                       /*
+                        * All is fine at this point. So it is okay to add the raw data to
+                        * the stacker. Here it doesn't matter if the raw data is a
+                        * well-formed BASE64-encoded message with start and markers. This
+                        * will be checked later on.
+                        */
+                       //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('TCP-HANDLER: Adding ' . strlen($rawData) . ' bytes to stacker ...');
+                       $this->addRawDataToStacker($rawData);
+               }
+       }
+
+}
diff --git a/application/hub/classes/handler/raw_data/udp/.htaccess b/application/hub/classes/handler/raw_data/udp/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/classes/handler/raw_data/udp/class_UdpRawDataHandler.php b/application/hub/classes/handler/raw_data/udp/class_UdpRawDataHandler.php
new file mode 100644 (file)
index 0000000..f1aaa66
--- /dev/null
@@ -0,0 +1,81 @@
+<?php
+// Own namespace
+namespace Hub\Handler\Network\RawData\Udp;
+
+// Import application-specific stuff
+use Hub\Handler\Network\RawData\BaseRawDataHandler;
+use Hub\Network\Networkable;
+use Hub\Pool\Poolable;
+
+/**
+ * A UDP raw data handler
+ *
+ * @author             Roland Haeder <webmaster@shipsimu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.shipsimu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+class UdpRawDataHandler extends BaseRawDataHandler implements Networkable {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+
+               // Set handler name
+               $this->setHandlerName('udp');
+       }
+
+       /**
+        * Creates an instance of this class
+        *
+        * @return      $handlerInstance                An instance of a Networkable class
+        */
+       public static final function createUdpRawDataHandler () {
+               // Get new instance
+               $handlerInstance = new UdpRawDataHandler();
+
+               // Return the prepared instance
+               return $handlerInstance;
+       }
+
+       /**
+        * Processes raw data from given resource. This is mostly useful for UDP
+        * package handling and is implemented in the UdpListener class
+        *
+        * @param       $socketArray    A valid socket resource array
+        * @return      void
+        * @throws      InvalidResourceException        If the given resource is invalid
+        * @todo        0%
+        */
+       public function processRawDataFromResource (array $socketArray) {
+               // Check the resource
+               if ((!isset($socketArray[Poolable::SOCKET_ARRAY_INSTANCE])) || (!is_resource($socketArray[Poolable::SOCKET_ARRAY_INSTANCE]))) {
+                       // Throw an exception
+                       throw new InvalidResourceException($this, self::EXCEPTION_INVALID_RESOURCE);
+               } // END - if
+
+               // Implement processing here
+               $this->partialStub('Please implement this method. resource=' . $socketArray[Poolable::SOCKET_ARRAY_INSTANCE] . ',type=' . $socketArray[Poolable::SOCKET_ARRRAY_CONN_TYPE]);
+       }
+}
+
+// [EOF]
+?>
index 355c7668502bd2e115961d0923e3c961c1c216a5..5fe5b83411069a620b75d8e7bba1cee848b90b3c 100644 (file)
@@ -3,6 +3,7 @@
 namespace Hub\Helper\Connection;
 
 // Import application-specific stuff
+use Hub\Container\Socket\StorableSocket;
 use Hub\Factory\Fragmenter\FragmenterFactory;
 use Hub\Factory\Network\NetworkPackageFactory;
 use Hub\Factory\State\Peer\PeerStateFactory;
@@ -109,7 +110,7 @@ class BaseConnectionHelper extends BaseHubSystemHelper implements Visitable, Reg
         */
        public final function __toString () {
                // Class name representation
-               $class = self::getConnectionClassName($this->getSocketInstance(), parent::__toString());
+               $class = self::getConnectionClassNameFromSocket($this->getSocketInstance(), parent::__toString());
 
                // Return it
                return $class;
@@ -137,12 +138,11 @@ class BaseConnectionHelper extends BaseHubSystemHelper implements Visitable, Reg
        /**
         * Static "getter" for this connection class' name
         *
-        * @param       $address        IP address
-        * @param       $port           Port number
-        * @param       $className      Original class name
+        * @param       $socketInstance         An instance of a StorableSocket class
         * @return      $class          Expanded class name
         */
-       public static function getConnectionClassName ($address, $port, $className) {
+       public static function getConnectionClassNameFromSocket (StorableSocket $socketInstance) {
+               die(__METHOD__.':socketInstance='.print_r($socketInstance, TRUE));
                // Construct it
                $class = $address . ':' . $port . ':' . $className;
 
index 0d85641132186022f260f6d15babcb11156ea9de..46fecd8ce6497fecf8d4d0d50f6ec5b7faff3209 100644 (file)
@@ -6,10 +6,12 @@ namespace Hub\Listener;
 use Hub\Container\Socket\StorableSocket;
 use Hub\Factory\Network\NetworkPackageFactory;
 use Hub\Listener\Listenable;
+use Hub\Locator\Node\LocateableNode;
 use Hub\Network\Networkable;
 
 // Import framework stuff
 use CoreFramework\Generic\BaseDecorator;
+use CoreFramework\Generic\UnsupportedOperationException;
 use CoreFramework\Visitor\Visitable;
 use CoreFramework\Visitor\Visitor;
 
@@ -284,4 +286,25 @@ class BaseListenerDecorator extends BaseDecorator implements Visitable {
                $this->protocolName = $protocolName;
        }
 
+       /**
+        * Setter for UNL instance
+        *
+        * @para        $unlInstance    An instance of a LocateableNode class
+        * @return      void
+        * @throws      UnsupportedOperationException   If this method is called
+        */
+       protected final function setUniversalNodeLocatorInstance (LocateableNode $unlInstance) {
+               throw new UnsupportedOperationException('This method should not be called.');
+       }
+
+       /**
+        * Getter for UNL instance
+        *
+        * @return      $unlData        An instance of a LocateableNode class
+        * @throws      UnsupportedOperationException   If this method is called
+        */
+       public final function getUniversalNodeLocatorInstance () {
+               throw new UnsupportedOperationException('This method should not be called.');
+       }
+
 }
index f526eebf208cb3e79f0443b79fddf3635b5ccc02..8fec88c5c202d4c595aeb20c22e5d724176b8c96 100644 (file)
@@ -6,6 +6,8 @@ namespace Hub\Resolver\State\Peer;
 use Hub\Container\Socket\StorableSocket;
 use Hub\Factory\State\Peer\PeerStateFactory;
 use Hub\Helper\Connection\ConnectionHelper;
+use Hub\Resolver\State\BaseStateResolver;
+use Hub\Resolver\State\StateResolver;
 
 // Import framework stuff
 use CoreFramework\Socket\InvalidSocketException;
index e9e2ac927aeeee8bf9faee4ffbad83dc70be2ae2..13cbe515c505cff1c923d177dbbb66ccb35f7e70 100644 (file)
@@ -4,6 +4,7 @@ namespace Hub\State\Peer;
 
 // Import application-specific stuff
 use Hub\Container\Socket\StorableSocket;
+use Hub\State\Peer\PeerStateable;
 
 // Import framework stuff
 use CoreFramework\State\Stateable;
index 9b71fe1e32312aaf4639d9f9263c1e9e1fc25353..45e82c18affa0f5b746efa4fd04be6dc3e56ad98 100644 (file)
@@ -4,6 +4,7 @@ namespace Hub\State\Peer;
 
 // Import application-specific stuff
 use Hub\Container\Socket\StorableSocket;
+use Hub\State\Peer\PeerStateable;
 
 // Import framework stuff
 use CoreFramework\State\Stateable;
index f12869ae6bb2cb725c3dcf324a23bf87c981083d..cf42313a955b2715a58424624b2ccf84700c4bf5 100644 (file)
@@ -4,6 +4,7 @@ namespace Hub\State\Peer;
 
 // Import application-specific stuff
 use Hub\Container\Socket\StorableSocket;
+use Hub\State\Peer\PeerStateable;
 
 // Import framework stuff
 use CoreFramework\State\Stateable;
@@ -56,7 +57,5 @@ class ConnectionRefusedPeerState extends BasePeerState implements PeerStateable
                // Return the prepared instance
                return $stateInstance;
        }
-}
 
-// [EOF]
-?>
+}
index 7313e93907502b9314cbd9ca0dacaded54475a0d..2de0616eb6c908d3dfec150759fc3425d2d43b29 100644 (file)
@@ -4,6 +4,7 @@ namespace Hub\State\Peer;
 
 // Import application-specific stuff
 use Hub\Container\Socket\StorableSocket;
+use Hub\State\Peer\PeerStateable;
 
 // Import framework stuff
 use CoreFramework\State\Stateable;
@@ -56,7 +57,5 @@ class ConnectionTimedOutPeerState extends BasePeerState implements PeerStateable
                // Return the prepared instance
                return $stateInstance;
        }
-}
 
-// [EOF]
-?>
+}
index edaa29f837f7420acaea278ebe058ae31a3c1c3b..b90fb9ebe1eb654fa4f509a95d364b1a420f2841 100644 (file)
@@ -4,6 +4,7 @@ namespace Hub\State\Peer;
 
 // Import application-specific stuff
 use Hub\Container\Socket\StorableSocket;
+use Hub\State\Peer\PeerStateable;
 
 // Import framework stuff
 use CoreFramework\State\Stateable;
@@ -56,7 +57,5 @@ class NoRouteToHostPeerState extends BasePeerState implements PeerStateable {
                // Return the prepared instance
                return $stateInstance;
        }
-}
 
-// [EOF]
-?>
+}
index 99d39acc9843ae55b1386f12dd67bcd87d060369..f33ed89944d958b376110b6be71d7cfde0cc5de4 100644 (file)
@@ -4,6 +4,7 @@ namespace Hub\State\Peer;
 
 // Import application-specific stuff
 use Hub\Container\Socket\StorableSocket;
+use Hub\State\Peer\PeerStateable;
 
 // Import framework stuff
 use CoreFramework\State\Stateable;
@@ -56,7 +57,5 @@ class OperationAlreadyProgressPeerState extends BasePeerState implements PeerSta
                // Return the prepared instance
                return $stateInstance;
        }
-}
 
-// [EOF]
-?>
+}
index ca6d00f2d5ed6d3b59e1179be1fac1fc2a8bb5b5..51fce8833219e9511db098f2bc484bf75f43014c 100644 (file)
@@ -4,6 +4,7 @@ namespace Hub\State\Peer;
 
 // Import application-specific stuff
 use Hub\Container\Socket\StorableSocket;
+use Hub\State\Peer\PeerStateable;
 
 // Import framework stuff
 use CoreFramework\State\Stateable;
@@ -56,7 +57,5 @@ class ProblemPeerState extends BasePeerState implements PeerStateable {
                // Return the prepared instance
                return $stateInstance;
        }
-}
 
-// [EOF]
-?>
+}
index 30aa74d6cdfa40e14de1d214becc73528ca07e38..3a6430742ef7eeebc9c02ef258069f598d5c4c22 100644 (file)
@@ -4,6 +4,7 @@ namespace Hub\State\Peer;
 
 // Import application-specific stuff
 use Hub\Container\Socket\StorableSocket;
+use Hub\State\Peer\PeerStateable;
 
 // Import framework stuff
 use CoreFramework\State\Stateable;
@@ -56,7 +57,5 @@ class TransportEndpointGonePeerState extends BasePeerState implements PeerStatea
                // Return the prepared instance
                return $stateInstance;
        }
-}
 
-// [EOF]
-?>
+}
index da101a97652468b7f2cd8dd43eff0368d7c8d71b..a3aab472300f41bc4831d5b9848ff231e11d3d5c 100644 (file)
@@ -53,7 +53,5 @@ class InitPeerState extends BasePeerState implements PeerStateable {
                // Return the prepared instance
                return $stateInstance;
        }
-}
 
-// [EOF]
-?>
+}
index e0a9a17048dd415224842a45839b9cd843c59a21..391824b0e23bbcf2192f4e52a25bb2cc84d91338 100644 (file)
@@ -61,7 +61,7 @@ $cfg->setConfigEntry('node_dht_db_wrapper_class', 'Hub\Database\Frontend\Node\Dh
 $cfg->setConfigEntry('node_dht_list_limit', 20);
 
 // CFG: PEER-LOOKUP-DB-WRAPPER-CLASS
-$cfg->setConfigEntry('peer_state_lookup_db_wrapper_class', 'PeerStateLookupDatabaseWrapper');
+$cfg->setConfigEntry('peer_state_lookup_db_wrapper_class', 'Hub\Database\Frontend\Node\PeerState\PeerStateLookupDatabaseWrapper');
 
 // CFG: WEB-CONTENT-TYPE
 $cfg->setConfigEntry('web_content_type', '');
index 68b7d2147dc79c6c8ac39ef7f2adef740201a317..2abd9c85cf18fd923e8ba8a780b8085e05170b44 100644 (file)
@@ -98,4 +98,11 @@ interface HubInterface extends FrameworkInterface {
         */
        function getSocketInstance ();
 
+       /**
+        * Getter for UNL instance
+        *
+        * @return      $unlInstance    An instance of a LocateableNode class
+        */
+       function getUniversalNodeLocatorInstance ();
+
 }
index b8e7c78f49e1d5be1e3ce6ba9bf1d301d47f97b4..74f64de7ef13376f70dadee430223b9c85794f85 100644 (file)
@@ -3,6 +3,7 @@
 namespace Hub\AnswerStatus\Node;
 
 // Import application-specific stuff
+use Hub\Generic\HubInterface;
 use Hub\Network\Receive\Receivable;
 
 // Import framework stuff
@@ -31,7 +32,7 @@ use CoreFramework\Handler\DataSet\HandleableDataSet;
  * You should have received a copy of the GNU General Public License
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
-interface HandleableAnswerStatus extends HandleableDataSet {
+interface HandleableAnswerStatus extends HandleableDataSet, HubInterface {
        /**
         * Handles given message data array
         *
@@ -49,7 +50,5 @@ interface HandleableAnswerStatus extends HandleableDataSet {
         * @return      void
         */
        function addArrayToDataSet (StoreableCriteria $dataSetInstance, array $messageData);
-}
 
-// [EOF]
-?>
+}
index 1d0a90a09475881353808c14be2d3ecad44ae12a..f8f920d37bf571c2d6039d4d81cd6137c8bfad8b 100644 (file)
@@ -2,6 +2,9 @@
 // Own namespace
 namespace Hub\Handler\Network\RawData\Chunks;
 
+// Import application-specific stuff
+use Hub\Generic\HubInterface;
+
 // Import framework stuff
 use CoreFramework\Handler\Handleable;
 
@@ -27,7 +30,7 @@ use CoreFramework\Handler\Handleable;
  * You should have received a copy of the GNU General Public License
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
-interface HandleableChunks extends Handleable {
+interface HandleableChunks extends Handleable, HubInterface {
        /**
         * Adds all chunks if the last one verifies as a 'final chunk'.
         *
@@ -101,7 +104,5 @@ interface HandleableChunks extends Handleable {
         * @return      void
         */
        function handledAssembledRawPackageData ();
-}
 
-// [EOF]
-?>
+}
index 5ad7ee260f3a5d78b912abc3b738b73c382db507..ba965357623c0d3ccab1511df53fc8e9035e264d 100644 (file)
@@ -3,6 +3,7 @@
 namespace Hub\Handler\Message;
 
 // Import application-specific stuff
+use Hub\Generic\HubInterface;
 use Hub\Network\Receive\Receivable;
 
 // Import framework stuff
@@ -30,7 +31,7 @@ use CoreFramework\Handler\DataSet\HandleableDataSet;
  * You should have received a copy of the GNU General Public License
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
-interface HandleableMessage extends HandleableDataSet {
+interface HandleableMessage extends HandleableDataSet, HubInterface {
        /**
         * Handles data array of the message
         *
@@ -48,7 +49,5 @@ interface HandleableMessage extends HandleableDataSet {
         * @return      void
         */
        function postHandleMessageData (array $messageData, Receivable $packageInstance);
-}
 
-// [EOF]
-?>
+}
index caf56cf9e141929813a933618bce35fd9dbafc47..4cd6ed37c872ad744fe45e1fd91766ae075cb3a2 100644 (file)
@@ -2,6 +2,9 @@
 // Own namespace
 namespace Hub\Network;
 
+// Import application-specific stuff
+use Hub\Generic\HubInterface;
+
 // Import framework stuff
 use CoreFramework\Handler\DataSet\HandleableDataSet;
 
@@ -27,7 +30,7 @@ use CoreFramework\Handler\DataSet\HandleableDataSet;
  * You should have received a copy of the GNU General Public License
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
-interface Networkable extends HandleableDataSet {
+interface Networkable extends HandleableDataSet, HubInterface {
        /**
         * Processes raw data from given resource. This is mostly useful for TCP
         * package handling and is implemented in the TcpListener class
@@ -51,7 +54,5 @@ interface Networkable extends HandleableDataSet {
         * @return      $decodedData    Raw data from the stacker
         */
        function getNextRawData ();
-}
 
-// [EOF]
-?>
+}
index 79575b8b871aadbd5f2affb903ad3f144d511b86..33528ffe5a33952f80b4e248f9f73d7b7f787372 100644 (file)
@@ -2,6 +2,9 @@
 // Own namespace
 namespace Hub\Handler\Protocol;
 
+// Import application-specific stuff
+use Hub\Generic\HubInterface;
+
 // Import framework stuff
 use CoreFramework\Handler\Handleable;
 
@@ -27,14 +30,7 @@ use CoreFramework\Handler\Handleable;
  * You should have received a copy of the GNU General Public License
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
-interface HandleableProtocol extends Handleable {
-       /**
-        * Getter for UNL instance
-        *
-        * @return      $unlInstance    An instance of a LocateableNode class
-        */
-       function getUniversalNodeLocatorInstance ();
-
+interface HandleableProtocol extends Handleable, HubInterface {
        /**
         * Getter for port number to satify HandleableProtocol
         *
index be49b0561c8acbac86a350fd6d700e6243d6c450..511bd8f6aeb26a973f52dbcb1286228e89a72dbe 100644 (file)
@@ -3,6 +3,7 @@
 namespace Hub\Helper\Connection;
 
 // Import application-specific stuff
+use Hub\Container\Socket\StorableSocket;
 use Hub\Helper\HubHelper;
 
 /**
@@ -50,12 +51,10 @@ interface ConnectionHelper extends HubHelper {
        /**
         * Static "getter" for this connection class' name
         *
-        * @param       $address        IP address
-        * @param       $port           Port number
-        * @param       $className      Original class name
+        * @param       $socketInstance         An instance of a StorableSocket class
         * @return      $class          Expanded class name
         */
-       static function getConnectionClassName ($address, $port, $className);
+       static function getConnectionClassNameFromSocket (StorableSocket $socketInstance);
 
        /**
         * Getter for shuttedDown
index d3f24b44f436be272c3c019e19733c5d51f08caf..c651cf691f1e3745e6ba35683126180e6aa59ef0 100644 (file)
@@ -1,4 +1,10 @@
 <?php
+// Own namespace
+namespace Hub\State\Node\Lookup;
+
+// Import application-specific stuff
+use Hub\LookupTable\Lookupable;
+
 /**
  * An interface for node-state lookup tables
  *
@@ -23,6 +29,3 @@
  */
 interface LookupableNodeState extends Lookupable {
 }
-
-// [EOF]
-?>
index 7385a22e5b3f19939096eeb827806c5541507128..01b8a3bcc7d9bc04d64f84e21c61feea262def0c 100644 (file)
@@ -5,6 +5,8 @@ namespace Hub\State\Peer\Lookup;
 // Import application-specific stuff
 use Hub\Container\Socket\StorableSocket;
 use Hub\Helper\Connection\ConnectionHelper;
+use Hub\LookupTable\Lookupable;
+use Hub\State\Peer\PeerStateable;
 
 // Import framework stuff
 use CoreFramework\State\Stateable;
@@ -61,10 +63,10 @@ interface LookupablePeerState extends Lookupable {
        /**
         * Purges old entries of given socket resource. We use the IP address from that resource.
         *
-        * @param       $socketResource         A valid socket resource
+        * @param       $socketInstance         An instance of a StorableSocket class
         * @return      void
         */
-       function purgeOldEntriesBySocketResource ($socketResource);
+       function purgeOldEntriesBysocketInstance (StorableSocket $socketInstance);
 
        /**
         * Checks whether a given peer state (in helper instance) is same as stored
@@ -75,7 +77,5 @@ interface LookupablePeerState extends Lookupable {
         * @return      $isSamePeerState                Whether the peer's state is the same
         */
        function isSamePeerState (ConnectionHelper $helperInstance, array $packageData);
-}
 
-// [EOF]
-?>
+}
index dabe7930d59a17f3db4c2f014327fcce0c15843b..85554f55fa11adfcb7345295fe7067194cfd5e56 100644 (file)
@@ -3,6 +3,7 @@
 namespace Hub\Resolver\State;
 
 // Import application-specific stuff
+use Hub\Container\Socket\StorableSocket;
 use Hub\Helper\Connection\ConnectionHelper;
 
 // Import framework stuff
@@ -36,10 +37,10 @@ interface StateResolver extends Resolver {
         *
         * @param       $helperInstance         An instance of a ConnectionHelper class
         * @param       $packageData            Raw package data
-        * @param       $socketResource         A valid socket resource
+        * @param       $socketInstance         An instance of a StorableSocket class
         * @return      $stateInstance          An instance of the resolved state
         */
-       static function resolveStateByPackage (ConnectionHelper $helperInstance, array $packageData, $socketResource);
+       static function resolveStateByPackage (ConnectionHelper $helperInstance, array $packageData, StorableSocket $socketInstance);
 
        /**
         * Checks whether the given state is valid
index e1de0cb0fcd51cde034c571f204180a824561b70..57ab4fdc9fef6641481bc94d289f19c24a32ac62 100644 (file)
@@ -29,6 +29,3 @@ use CoreFramework\State\Stateable;
  */
 interface PeerStateable extends Stateable {
 }
-
-// [EOF]
-?>