]> git.mxchange.org Git - hub.git/commitdiff
Renamed a lot 'Peer' classes to 'Node' or 'Client' depending on what they are written for
authorRoland Häder <roland@mxchange.org>
Sun, 24 Apr 2011 08:35:49 +0000 (08:35 +0000)
committerRoland Häder <roland@mxchange.org>
Sun, 24 Apr 2011 08:35:49 +0000 (08:35 +0000)
15 files changed:
.gitattributes
application/hub/config.php
application/hub/main/database/wrapper/states/class_NodeStateLookupDatabaseWrapper.php [new file with mode: 0644]
application/hub/main/database/wrapper/states/class_PeerStateLookupDatabaseWrapper.php
application/hub/main/factories/states/peer/class_PeerStateFactory.php
application/hub/main/listener/tcp/class_TcpListener.php
application/hub/main/listener/tcp/decorators/class_ClientTcpListenerDecorator.php [new file with mode: 0644]
application/hub/main/listener/tcp/decorators/class_PeerTcpListenerDecorator.php
application/hub/main/listener/udp/decorators/class_ClientUdpListenerDecorator.php [new file with mode: 0644]
application/hub/main/listener/udp/decorators/class_PeerUdpListenerDecorator.php
application/hub/main/lookup/peer/class_NodeStateLookupTable.php [new file with mode: 0644]
application/hub/main/lookup/peer/class_PeerStateLookupTable.php
application/hub/main/nodes/class_BaseHubNode.php
application/hub/main/states/peer/new/class_NewConnectionNodeState.php [new file with mode: 0644]
application/hub/main/states/peer/new/class_NewConnectionPeerState.php

index 28f043c99e52f0831668a83b22baea35cb59c666..1178a29f4e0ed8c07cdb654e962a2a69f6fb4cd2 100644 (file)
@@ -165,6 +165,7 @@ application/hub/main/database/wrapper/node/.htaccess svneol=native#text/plain
 application/hub/main/database/wrapper/node/class_NodeInformationDatabaseWrapper.php svneol=native#text/plain
 application/hub/main/database/wrapper/node/class_NodeListDatabaseWrapper.php svneol=native#text/plain
 application/hub/main/database/wrapper/states/.htaccess svneol=native#text/plain
+application/hub/main/database/wrapper/states/class_NodeStateLookupDatabaseWrapper.php svneol=native#text/plain
 application/hub/main/database/wrapper/states/class_PeerStateLookupDatabaseWrapper.php svneol=native#text/plain
 application/hub/main/decorators/.htaccess -text svneol=unset#text/plain
 application/hub/main/discovery/.htaccess -text svneol=unset#text/plain
@@ -324,12 +325,14 @@ application/hub/main/listener/tcp/.htaccess -text svneol=unset#text/plain
 application/hub/main/listener/tcp/class_ svneol=native#text/plain
 application/hub/main/listener/tcp/class_TcpListener.php svneol=native#text/plain
 application/hub/main/listener/tcp/decorators/.htaccess -text svneol=unset#text/plain
+application/hub/main/listener/tcp/decorators/class_ClientTcpListenerDecorator.php svneol=native#text/plain
 application/hub/main/listener/tcp/decorators/class_HubTcpListenerDecorator.php svneol=native#text/plain
 application/hub/main/listener/tcp/decorators/class_PeerTcpListenerDecorator.php svneol=native#text/plain
 application/hub/main/listener/udp/.htaccess -text svneol=unset#text/plain
 application/hub/main/listener/udp/class_ svneol=native#text/plain
 application/hub/main/listener/udp/class_UdpListener.php svneol=native#text/plain
 application/hub/main/listener/udp/decorators/.htaccess -text svneol=unset#text/plain
+application/hub/main/listener/udp/decorators/class_ClientUdpListenerDecorator.php svneol=native#text/plain
 application/hub/main/listener/udp/decorators/class_HubUdpListenerDecorator.php svneol=native#text/plain
 application/hub/main/listener/udp/decorators/class_PeerUdpListenerDecorator.php svneol=native#text/plain
 application/hub/main/lists/.htaccess -text svneol=unset#text/plain
@@ -352,6 +355,7 @@ application/hub/main/lookup/.htaccess -text svneol=unset#text/plain
 application/hub/main/lookup/class_ svneol=native#text/plain
 application/hub/main/lookup/class_BaseLookupTable.php svneol=native#text/plain
 application/hub/main/lookup/peer/.htaccess -text svneol=unset#text/plain
+application/hub/main/lookup/peer/class_NodeStateLookupTable.php svneol=native#text/plain
 application/hub/main/lookup/peer/class_PeerStateLookupTable.php svneol=native#text/plain
 application/hub/main/nodes/.htaccess -text svneol=unset#text/plain
 application/hub/main/nodes/boot/.htaccess -text svneol=unset#text/plain
@@ -440,6 +444,7 @@ application/hub/main/states/peer/.htaccess -text svneol=unset#text/plain
 application/hub/main/states/peer/class_ svneol=native#text/plain
 application/hub/main/states/peer/class_BasePeerState.php svneol=native#text/plain
 application/hub/main/states/peer/new/.htaccess -text svneol=unset#text/plain
+application/hub/main/states/peer/new/class_NewConnectionNodeState.php svneol=native#text/plain
 application/hub/main/states/peer/new/class_NewConnectionPeerState.php svneol=native#text/plain
 application/hub/main/streams/.htaccess svneol=native#text/plain
 application/hub/main/streams/package/.htaccess svneol=native#text/plain
index 3264f81f663aac9cda84c6811dd7a27d774b694f..92f467fd164df9b6827aad03dd149beae2e02eeb 100644 (file)
@@ -51,8 +51,8 @@ $cfg->setConfigEntry('node_info_db_wrapper_class', 'NodeInformationDatabaseWrapp
 // CFG: NODE-LIST-DB-WRAPPER-CLASS
 $cfg->setConfigEntry('node_list_db_wrapper_class', 'NodeListDatabaseWrapper');
 
-// CFG: PEER-LOOKUP-DB-WRAPPER-CLASS
-$cfg->setConfigEntry('peer_state_lookup_db_wrapper_class', 'PeerStateLookupDatabaseWrapper');
+// CFG: NODE-LOOKUP-DB-WRAPPER-CLASS
+$cfg->setConfigEntry('node_state_lookup_db_wrapper_class', 'NodeStateLookupDatabaseWrapper');
 
 // CFG: WEB-CONTENT-TYPE
 $cfg->setConfigEntry('web_content_type', '');
@@ -79,13 +79,13 @@ $cfg->setConfigEntry('hub_tcp_listener_class', 'HubTcpListenerDecorator');
 $cfg->setConfigEntry('hub_udp_listener_class', 'HubUdpListenerDecorator');
 
 // CFG: CLIENT-TCP-LISTENER-CLASS
-$cfg->setConfigEntry('peer_tcp_listener_class', 'PeerTcpListenerDecorator');
+$cfg->setConfigEntry('client_tcp_listener_class', 'ClientTcpListenerDecorator');
 
 // CFG: CLIENT-UDP-LISTENER-CLASS
-$cfg->setConfigEntry('peer_udp_listener_class', 'PeerUdpListenerDecorator');
+$cfg->setConfigEntry('client_udp_listener_class', 'ClientUdpListenerDecorator');
 
-// CFG: CLIENT-POOL-CLASS
-$cfg->setConfigEntry('peer_pool_class', 'DefaultPeerPool');
+// CFG: NODE-POOL-CLASS
+$cfg->setConfigEntry('node_pool_class', 'DefaultPeerPool');
 
 // CFG: POOL-ENTRIES-LIST-CLASS
 $cfg->setConfigEntry('pool_entries_list_class', 'PoolEntriesList');
@@ -492,11 +492,11 @@ $cfg->setConfigEntry('tcp_connect_retry_max', 10);
 // CFG: UDP-CONNECT-RETRY-MAX
 $cfg->setConfigEntry('udp_connect_retry_max', 10);
 
-// CFG: PEER-STATE-LOOKUP-TABLE-CLASS
-$cfg->setConfigEntry('peer_state_lookup_table_class', 'PeerStateLookupTable');
+// CFG: NODE-STATE-LOOKUP-TABLE-CLASS
+$cfg->setConfigEntry('node_state_lookup_table_class', 'NodeStateLookupTable');
 
-// CFG: PEER-STATE-CHECKED-PACKAGE-CLASS
-$cfg->setConfigEntry('peer_state_checked_package_class', 'NewConnectionPeerState');
+// CFG: NODE-STATE-CHECKED-PACKAGE-CLASS
+$cfg->setConfigEntry('node_state_checked_package_class', 'NewConnectionNodeState');
 
 // CFG: SESSION-ID
 $cfg->setConfigEntry('session_id', '');
diff --git a/application/hub/main/database/wrapper/states/class_NodeStateLookupDatabaseWrapper.php b/application/hub/main/database/wrapper/states/class_NodeStateLookupDatabaseWrapper.php
new file mode 100644 (file)
index 0000000..1e4b174
--- /dev/null
@@ -0,0 +1,172 @@
+<?php
+/**
+ * A database wrapper for node state lookups
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2011 Hub Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class NodeStateLookupDatabaseWrapper extends BaseDatabaseWrapper {
+       // Exception constants
+       const EXCEPTION_NODE_ALREADY_REGISTERED = 0x300;
+
+       // Constants for database table names
+       const DB_TABLE_NODE_LOOKUP = 'node_states';
+
+       // Constants for database column names
+       const DB_COLUMN_NODE_IP         = 'node_ip';
+       const DB_COLUMN_NODE_PORT       = 'node_port';
+       const DB_COLUMN_NODE_SESSION_ID = 'node_session_id';
+
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+       }
+
+       /**
+        * Creates an instance of this database wrapper by a provided user class
+        *
+        * @return      $wrapperInstance        An instance of the created wrapper class
+        */
+       public static final function createNodeStateLookupDatabaseWrapper () {
+               // Get a new instance
+               $wrapperInstance = new NodeStateLookupDatabaseWrapper();
+
+               // Set (primary!) table name
+               $wrapperInstance->setTableName(self::DB_TABLE_NODE_LOOKUP);
+
+               // Return the instance
+               return $wrapperInstance;
+       }
+
+       /**
+        * Getter for index key
+        *
+        * @return      $indexKey       Index key
+        */
+       public final function getIndexKey () {
+               return $this->getDatabaseInstance()->getIndexKey();
+       }
+
+       /**
+        * Checks wether given 'sender' is a new node
+        *
+        * @param       $packageData    Raw package data
+        * @return      $isNewPeer              Wether 'sender' is a new node to this node
+        */
+       public function isSenderNewPeer (array $packageData) {
+               // Is always new node by default
+               $isNewPeer = true;
+
+               // Is the package valid?
+               if (!isset($packageData[NetworkPackage::INDEX_PACKAGE_SENDER])) {
+                       // Invalid package found, please report this
+                       die(__METHOD__ . ': packageData=' . print_r($packageData, true));
+               } // END - if
+
+               // Remove session id > IP:port
+               $ipPort = HubTools::resolveSessionId($packageData[NetworkPackage::INDEX_PACKAGE_SENDER]);
+
+               // Is it not invalid:invalid?
+               if ($ipPort != 'invalid:invalid') {
+                       // Get a search criteria instance
+                       $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
+
+                       // Add 'sender' as the node's IP address
+                       $searchInstance->addCriteria(self::DB_COLUMN_NODE_IP, $ipPort);
+                       $searchInstance->setLimit(1);
+
+                       // Count the query
+                       $entries = $this->doSelectCountByCriteria($searchInstance);
+
+                       // Is it there?
+                       $isNewPeer = ($entries === 0);
+               } // END - if
+
+               // Return the result
+               return $isNewPeer;
+       }
+
+       /**
+        * Registers a new node with given package data. We use the session id from it.
+        *
+        * @param       $packageData            Raw package data
+        * @param       $socketResource         A valid socket resource
+        * @return      void
+        * @throws      PeerAlreadyRegisteredException  If a node is already registered
+        * @throws      InvalidSocketException  If the socket resource was invalid
+        */
+       public function registerPeerByPackageData (array $packageData, $socketResource) {
+               // Make sure only new nodes can be registered with package data
+               if (!$this->isSenderNewPeer($packageData)) {
+                       // Throw an exception because this should normally not happen
+                       throw new PeerAlreadyRegisteredException(array($this, $packageData), self::EXCEPTION_NODE_ALREADY_REGISTERED);
+               } // END - if
+
+               // Generate a dataset instance
+               $dataSetInstance = ObjectFactory::createObjectByConfiguredName('dataset_criteria_class', array(self::DB_TABLE_NODE_LOOKUP));
+
+               // Session ids must be unique
+               $dataSetInstance->setUniqueKey(self::DB_COLUMN_NODE_SESSION_ID);
+
+               // Add session id
+               $dataSetInstance->addCriteria(self::DB_COLUMN_NODE_SESSION_ID, $packageData[NetworkPackage::INDEX_PACKAGE_SENDER]);
+
+               // Get node name
+               if (!socket_getnodename($socketResource, $nodeName, $nodePort)) {
+                       // Get last error
+                       $lastError = socket_last_error($socketResource);
+
+                       // Doesn't work!
+                       throw new InvalidSocketException(array($this, gettype($socketResource), $lastError, socket_strerror($lastError)), BaseListener::EXCEPTION_INVALID_SOCKET);
+               } // END - if
+
+               // Add ip address and port
+               $dataSetInstance->addCriteria(self::DB_COLUMN_NODE_IP  , $nodeName);
+               $dataSetInstance->addCriteria(self::DB_COLUMN_NODE_PORT, $nodePort);
+
+               // "Insert" the data set
+               $this->getDatabaseInstance()->queryInsertDataSet($dataSetInstance);
+       }
+
+       /**
+        * Purges old entries of given socket resource. We use the IP address from that resource.
+        *
+        * @param       $socketResource         A valid socket resource
+        * @return      void
+        * @throws      InvalidSocketException  If the socket resource was invalid
+        */
+       public function purgeOldEntriesBySocketResource ($socketResource) {
+               // Get node name
+               if (!socket_getnodename($socketResource, $nodeName, $nodePort)) {
+                       // Get last error
+                       $lastError = socket_last_error($socketResource);
+
+                       // Doesn't work!
+                       throw new InvalidSocketException(array($this, gettype($socketResource), $lastError, socket_strerror($lastError)), BaseListener::EXCEPTION_INVALID_SOCKET);
+               } // END - if
+       }
+}
+
+// [EOF]
+?>
index 7450d228f5f2b3d45a7af414f84fe945d91bf60f..f551ef47b7591c74e7b59193e56a1fa6505a87ab 100644 (file)
@@ -1,172 +1,3 @@
 <?php
-/**
- * A database wrapper for peer state lookups
- *
- * @author             Roland Haeder <webmaster@ship-simu.org>
- * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2011 Hub Developer Team
- * @license            GNU GPL 3.0 or any newer version
- * @link               http://www.ship-simu.org
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-class PeerStateLookupDatabaseWrapper extends BaseDatabaseWrapper {
-       // Exception constants
-       const EXCEPTION_PEER_ALREADY_REGISTERED = 0x300;
-
-       // Constants for database table names
-       const DB_TABLE_PEER_LOOKUP = 'peer_states';
-
-       // Constants for database column names
-       const DB_COLUMN_PEER_IP         = 'peer_ip';
-       const DB_COLUMN_PEER_PORT       = 'peer_port';
-       const DB_COLUMN_PEER_SESSION_ID = 'peer_session_id';
-
-       /**
-        * Protected constructor
-        *
-        * @return      void
-        */
-       protected function __construct () {
-               // Call parent constructor
-               parent::__construct(__CLASS__);
-       }
-
-       /**
-        * Creates an instance of this database wrapper by a provided user class
-        *
-        * @return      $wrapperInstance        An instance of the created wrapper class
-        */
-       public static final function createPeerStateLookupDatabaseWrapper () {
-               // Get a new instance
-               $wrapperInstance = new PeerStateLookupDatabaseWrapper();
-
-               // Set (primary!) table name
-               $wrapperInstance->setTableName(self::DB_TABLE_PEER_LOOKUP);
-
-               // Return the instance
-               return $wrapperInstance;
-       }
-
-       /**
-        * Getter for index key
-        *
-        * @return      $indexKey       Index key
-        */
-       public final function getIndexKey () {
-               return $this->getDatabaseInstance()->getIndexKey();
-       }
-
-       /**
-        * Checks wether given 'sender' is a new peer
-        *
-        * @param       $packageData    Raw package data
-        * @return      $isNewPeer              Wether 'sender' is a new peer to this node
-        */
-       public function isSenderNewPeer (array $packageData) {
-               // Is always new peer by default
-               $isNewPeer = true;
-
-               // Is the package valid?
-               if (!isset($packageData[NetworkPackage::INDEX_PACKAGE_SENDER])) {
-                       // Invalid package found, please report this
-                       die(__METHOD__ . ': packageData=' . print_r($packageData, true));
-               } // END - if
-
-               // Remove session id > IP:port
-               $ipPort = HubTools::resolveSessionId($packageData[NetworkPackage::INDEX_PACKAGE_SENDER]);
-
-               // Is it not invalid:invalid?
-               if ($ipPort != 'invalid:invalid') {
-                       // Get a search criteria instance
-                       $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
-
-                       // Add 'sender' as the peer's IP address
-                       $searchInstance->addCriteria(self::DB_COLUMN_PEER_IP, $ipPort);
-                       $searchInstance->setLimit(1);
-
-                       // Count the query
-                       $entries = $this->doSelectCountByCriteria($searchInstance);
-
-                       // Is it there?
-                       $isNewPeer = ($entries === 0);
-               } // END - if
-
-               // Return the result
-               return $isNewPeer;
-       }
-
-       /**
-        * 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
-        * @return      void
-        * @throws      PeerAlreadyRegisteredException  If a peer is already registered
-        * @throws      InvalidSocketException  If the socket resource was invalid
-        */
-       public function registerPeerByPackageData (array $packageData, $socketResource) {
-               // Make sure only new peers can be registered with package data
-               if (!$this->isSenderNewPeer($packageData)) {
-                       // Throw an exception because this should normally not happen
-                       throw new PeerAlreadyRegisteredException(array($this, $packageData), self::EXCEPTION_PEER_ALREADY_REGISTERED);
-               } // END - if
-
-               // Generate a dataset instance
-               $dataSetInstance = ObjectFactory::createObjectByConfiguredName('dataset_criteria_class', array(self::DB_TABLE_PEER_LOOKUP));
-
-               // Session ids must be unique
-               $dataSetInstance->setUniqueKey(self::DB_COLUMN_PEER_SESSION_ID);
-
-               // Add session id
-               $dataSetInstance->addCriteria(self::DB_COLUMN_PEER_SESSION_ID, $packageData[NetworkPackage::INDEX_PACKAGE_SENDER]);
-
-               // Get peer name
-               if (!socket_getpeername($socketResource, $peerName, $peerPort)) {
-                       // Get last error
-                       $lastError = socket_last_error($socketResource);
-
-                       // Doesn't work!
-                       throw new InvalidSocketException(array($this, gettype($socketResource), $lastError, socket_strerror($lastError)), BaseListener::EXCEPTION_INVALID_SOCKET);
-               } // END - if
-
-               // Add ip address and port
-               $dataSetInstance->addCriteria(self::DB_COLUMN_PEER_IP  , $peerName);
-               $dataSetInstance->addCriteria(self::DB_COLUMN_PEER_PORT, $peerPort);
-
-               // "Insert" the data set
-               $this->getDatabaseInstance()->queryInsertDataSet($dataSetInstance);
-       }
-
-       /**
-        * Purges old entries of given socket resource. We use the IP address from that resource.
-        *
-        * @param       $socketResource         A valid socket resource
-        * @return      void
-        * @throws      InvalidSocketException  If the socket resource was invalid
-        */
-       public function purgeOldEntriesBySocketResource ($socketResource) {
-               // Get peer name
-               if (!socket_getpeername($socketResource, $peerName, $peerPort)) {
-                       // Get last error
-                       $lastError = socket_last_error($socketResource);
-
-                       // Doesn't work!
-                       throw new InvalidSocketException(array($this, gettype($socketResource), $lastError, socket_strerror($lastError)), BaseListener::EXCEPTION_INVALID_SOCKET);
-               } // END - if
-       }
-}
-
-// [EOF]
+// @DEPRECATED
 ?>
index a8db17ac63bddc3dc817e4fa110e40a977976f39..eff9b89223772c167ff77f3b3ac5454c68620337 100644 (file)
@@ -86,7 +86,7 @@ class PeerStateFactory extends ObjectFactory {
                // Is the instance null?
                if (is_null(self::$tableInstance)) {
                        // Get a new one
-                       self::$tableInstance = ObjectFactory::createObjectByConfiguredName('peer_state_lookup_table_class');
+                       self::$tableInstance = ObjectFactory::createObjectByConfiguredName('node_state_lookup_table_class');
                } // END - if
 
                // Return it
index bdc20b462f98411783f950199ebb81097119a66e..a1f87a766685826b4cf4c13c9b1fcd685008e65d 100644 (file)
@@ -146,7 +146,7 @@ class TcpListener extends BaseListener implements Listenable {
                $this->registerServerSocketResource($mainSocket);
 
                // Initialize the peer pool instance
-               $poolInstance = ObjectFactory::createObjectByConfiguredName('peer_pool_class', array($this));
+               $poolInstance = ObjectFactory::createObjectByConfiguredName('node_pool_class', array($this));
 
                // Add main socket
                $poolInstance->addPeer($mainSocket);
diff --git a/application/hub/main/listener/tcp/decorators/class_ClientTcpListenerDecorator.php b/application/hub/main/listener/tcp/decorators/class_ClientTcpListenerDecorator.php
new file mode 100644 (file)
index 0000000..f456e00
--- /dev/null
@@ -0,0 +1,96 @@
+<?php
+/**
+ * A decorator for the TcpListener to communicate to peers
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2011 Hub Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class ClientTcpListenerDecorator extends BaseListenerDecorator implements Listenable {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+
+               // Set listener type
+               $this->setListenerType('peer');
+       }
+
+       /**
+        * Creates an instance of this class
+        *
+        * @param       $listenerInstance       A Listener instance
+        * @return      $decoratorInstance      An instance a prepared listener decorator class
+        */
+       public static final function createClientTcpListenerDecorator (Listenable $listenerInstance) {
+               // Get new instance
+               $decoratorInstance = new ClientTcpListenerDecorator();
+
+               // Set the application instance
+               $decoratorInstance->setListenerInstance($listenerInstance);
+
+               // Return the prepared instance
+               return $decoratorInstance;
+       }
+
+       /**
+        * Initializes the listener by setting up the required socket server
+        *
+        * @return      void
+        */
+       public function initListener () {
+               $this->partialStub('WARNING: This method should not be called.');
+       }
+
+       /**
+        * "Listens" for incoming network packages
+        *
+        * @return      void
+        */
+       public function doListen () {
+               // Handle generic TCP package
+               $this->getListenerInstance()->doListen();
+
+               // Handle peer TCP package
+               $this->partialStub('Need to handle peer TCP package.');
+       }
+
+       /**
+        * Checks wether the listener would accept the given package data array
+        *
+        * @param       $packageData    Raw package data
+        * @return      $accepts                Wether this listener does accept
+        */
+       public function ifListenerAcceptsPackageData (array $packageData) {
+               // Get a tags instance
+               $tagsInstance = PackageTagsFactory::createPackageTagsInstance();
+
+               // So is the package accepted with this listener?
+               $accepts = $tagsInstance->ifPackageDataIsAcceptedByListener($packageData, $this);
+
+               // Return the result
+               return $accepts;
+       }
+}
+
+// [EOF]
+?>
index fbcbaaa6619823a59a91ffad1c52dec5d16e5dcb..f551ef47b7591c74e7b59193e56a1fa6505a87ab 100644 (file)
@@ -1,96 +1,3 @@
 <?php
-/**
- * A decorator for the TcpListener to communicate to peers
- *
- * @author             Roland Haeder <webmaster@ship-simu.org>
- * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2011 Hub Developer Team
- * @license            GNU GPL 3.0 or any newer version
- * @link               http://www.ship-simu.org
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-class PeerTcpListenerDecorator extends BaseListenerDecorator implements Listenable {
-       /**
-        * Protected constructor
-        *
-        * @return      void
-        */
-       protected function __construct () {
-               // Call parent constructor
-               parent::__construct(__CLASS__);
-
-               // Set listener type
-               $this->setListenerType('peer');
-       }
-
-       /**
-        * Creates an instance of this class
-        *
-        * @param       $listenerInstance       A Listener instance
-        * @return      $decoratorInstance      An instance a prepared listener decorator class
-        */
-       public static final function createPeerTcpListenerDecorator (Listenable $listenerInstance) {
-               // Get new instance
-               $decoratorInstance = new PeerTcpListenerDecorator();
-
-               // Set the application instance
-               $decoratorInstance->setListenerInstance($listenerInstance);
-
-               // Return the prepared instance
-               return $decoratorInstance;
-       }
-
-       /**
-        * Initializes the listener by setting up the required socket server
-        *
-        * @return      void
-        */
-       public function initListener () {
-               $this->partialStub('WARNING: This method should not be called.');
-       }
-
-       /**
-        * "Listens" for incoming network packages
-        *
-        * @return      void
-        */
-       public function doListen () {
-               // Handle generic TCP package
-               $this->getListenerInstance()->doListen();
-
-               // Handle peer TCP package
-               $this->partialStub('Need to handle peer TCP package.');
-       }
-
-       /**
-        * Checks wether the listener would accept the given package data array
-        *
-        * @param       $packageData    Raw package data
-        * @return      $accepts                Wether this listener does accept
-        */
-       public function ifListenerAcceptsPackageData (array $packageData) {
-               // Get a tags instance
-               $tagsInstance = PackageTagsFactory::createPackageTagsInstance();
-
-               // So is the package accepted with this listener?
-               $accepts = $tagsInstance->ifPackageDataIsAcceptedByListener($packageData, $this);
-
-               // Return the result
-               return $accepts;
-       }
-}
-
-// [EOF]
+// @DEPRECATED
 ?>
diff --git a/application/hub/main/listener/udp/decorators/class_ClientUdpListenerDecorator.php b/application/hub/main/listener/udp/decorators/class_ClientUdpListenerDecorator.php
new file mode 100644 (file)
index 0000000..6e6da32
--- /dev/null
@@ -0,0 +1,96 @@
+<?php
+/**
+ * A decorator for the UdpListener to communicate to peers
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2011 Hub Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class ClientUdpListenerDecorator extends BaseListenerDecorator implements Listenable {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+
+               // Set listener type
+               $this->setListenerType('peer');
+       }
+
+       /**
+        * Creates an instance of this class
+        *
+        * @param       $listenerInstance       A Listener instance
+        * @return      $decoratorInstance      An instance a prepared listener decorator class
+        */
+       public static final function createClientUdpListenerDecorator (Listenable $listenerInstance) {
+               // Get new instance
+               $decoratorInstance = new ClientUdpListenerDecorator();
+
+               // Set the application instance
+               $decoratorInstance->setListenerInstance($listenerInstance);
+
+               // Return the prepared instance
+               return $decoratorInstance;
+       }
+
+       /**
+        * Initializes the listener by setting up the required socket server
+        *
+        * @return      void
+        */
+       public function initListener () {
+               $this->partialStub('WARNING: This method should not be called.');
+       }
+
+       /**
+        * "Listens" for incoming network packages
+        *
+        * @return      void
+        */
+       public function doListen () {
+               // Handle generic UDP packages first
+               $this->getListenerInstance()->doListen();
+
+               // Handle this peer UDP package
+               $this->partialStub('Need to handle peer UDP package.');
+       }
+
+       /**
+        * Checks wether the listener would accept the given package data array
+        *
+        * @param       $packageData    Raw package data
+        * @return      $accepts                Wether this listener does accept
+        */
+       function ifListenerAcceptsPackageData (array $packageData) {
+               // Get a tags instance
+               $tagsInstance = PackageTagsFactory::createPackageTagsInstance();
+
+               // So is the package accepted with this listener?
+               $accepts = $tagsInstance->ifPackageDataIsAcceptedByListener($packageData, $this);
+
+               // Return the result
+               return $accepts;
+       }
+}
+
+// [EOF]
+?>
index 6459dd2e5304c902b78f25794d6d2bbe2afc8947..f551ef47b7591c74e7b59193e56a1fa6505a87ab 100644 (file)
@@ -1,96 +1,3 @@
 <?php
-/**
- * A decorator for the UdpListener to communicate to peers
- *
- * @author             Roland Haeder <webmaster@ship-simu.org>
- * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2011 Hub Developer Team
- * @license            GNU GPL 3.0 or any newer version
- * @link               http://www.ship-simu.org
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-class PeerUdpListenerDecorator extends BaseListenerDecorator implements Listenable {
-       /**
-        * Protected constructor
-        *
-        * @return      void
-        */
-       protected function __construct () {
-               // Call parent constructor
-               parent::__construct(__CLASS__);
-
-               // Set listener type
-               $this->setListenerType('peer');
-       }
-
-       /**
-        * Creates an instance of this class
-        *
-        * @param       $listenerInstance       A Listener instance
-        * @return      $decoratorInstance      An instance a prepared listener decorator class
-        */
-       public static final function createPeerUdpListenerDecorator (Listenable $listenerInstance) {
-               // Get new instance
-               $decoratorInstance = new PeerUdpListenerDecorator();
-
-               // Set the application instance
-               $decoratorInstance->setListenerInstance($listenerInstance);
-
-               // Return the prepared instance
-               return $decoratorInstance;
-       }
-
-       /**
-        * Initializes the listener by setting up the required socket server
-        *
-        * @return      void
-        */
-       public function initListener () {
-               $this->partialStub('WARNING: This method should not be called.');
-       }
-
-       /**
-        * "Listens" for incoming network packages
-        *
-        * @return      void
-        */
-       public function doListen () {
-               // Handle generic UDP packages first
-               $this->getListenerInstance()->doListen();
-
-               // Handle this peer UDP package
-               $this->partialStub('Need to handle peer UDP package.');
-       }
-
-       /**
-        * Checks wether the listener would accept the given package data array
-        *
-        * @param       $packageData    Raw package data
-        * @return      $accepts                Wether this listener does accept
-        */
-       function ifListenerAcceptsPackageData (array $packageData) {
-               // Get a tags instance
-               $tagsInstance = PackageTagsFactory::createPackageTagsInstance();
-
-               // So is the package accepted with this listener?
-               $accepts = $tagsInstance->ifPackageDataIsAcceptedByListener($packageData, $this);
-
-               // Return the result
-               return $accepts;
-       }
-}
-
-// [EOF]
+// @DEPRECATED
 ?>
diff --git a/application/hub/main/lookup/peer/class_NodeStateLookupTable.php b/application/hub/main/lookup/peer/class_NodeStateLookupTable.php
new file mode 100644 (file)
index 0000000..89ff712
--- /dev/null
@@ -0,0 +1,104 @@
+<?php
+/**
+ * A Peer lookup table class
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2011 Hub Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+class NodeStateLookupTable extends BaseLookupTable implements LookupablePeerState {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+       }
+
+       /**
+        * Creates an instance of this class
+        *
+        * @return      $tableInstance  An instance of a Lookupable class
+        */
+       public static final function createNodeStateLookupTable () {
+               // Get new instance
+               $tableInstance = new NodeStateLookupTable();
+
+               // Get a database wrapper instance
+               $wrapperInstance = ObjectFactory::createObjectByConfiguredName('node_state_lookup_db_wrapper_class');
+
+               // Set it for later re-use
+               $tableInstance->setWrapperInstance($wrapperInstance);
+
+               // Return the prepared instance
+               return $tableInstance;
+       }
+
+       /**
+        * Checks wether given 'sender' is a new peer
+        *
+        * @param       $packageData    Raw package data
+        * @return      $isNewPeer              Wether 'sender' is a new peer to this node
+        */
+       public function isSenderNewPeer (array $packageData) {
+               // Get our wrapper instance and ask for it
+               $isNewPeer = $this->getWrapperInstance()->isSenderNewPeer($packageData);
+
+               // Return it
+               return $isNewPeer;
+       }
+
+       /**
+        * Registers a peer with given package data. We use the session id from it
+        *
+        * @param       $packageData            Valid raw package data
+        * @param       $socketResource         A valid socket resource
+        * @return      void
+        */
+       public function registerPeerByPackageData (array $packageData, $socketResource) {
+               // Just handle it over
+               $this->getWrapperInstance()->registerPeerByPackageData($packageData, $socketResource);
+       }
+
+       /**
+        * Registers the given peer state and raw package data
+        *
+        * @param       $stateInstance  A PeerStateable class instance
+        * @param       $packageData    Valid package data array
+        * @return      void
+        */
+       public function registerPeerState (PeerStateable $stateInstance, array $packageData) {
+               die(__METHOD__."\n");
+       }
+
+       /**
+        * Purges old entries of given socket resource. We use the IP address from that resource.
+        *
+        * @param       $socketResource         A valid socket resource
+        * @return      void
+        */
+       public function purgeOldEntriesBySocketResource ($socketResource) {
+               // Just handle it over
+               $this->getWrapperInstance()->purgeOldEntriesBySocketResource($socketResource);
+       }
+}
+
+// [EOF]
+?>
index 068d588a5358bc4c6db6167657cfb1d9040274eb..f551ef47b7591c74e7b59193e56a1fa6505a87ab 100644 (file)
@@ -1,104 +1,3 @@
 <?php
-/**
- * A Peer lookup table class
- *
- * @author             Roland Haeder <webmaster@ship-simu.org>
- * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2011 Hub Developer Team
- * @license            GNU GPL 3.0 or any newer version
- * @link               http://www.ship-simu.org
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-class PeerStateLookupTable extends BaseLookupTable implements LookupablePeerState {
-       /**
-        * Protected constructor
-        *
-        * @return      void
-        */
-       protected function __construct () {
-               // Call parent constructor
-               parent::__construct(__CLASS__);
-       }
-
-       /**
-        * Creates an instance of this class
-        *
-        * @return      $tableInstance  An instance of a Lookupable class
-        */
-       public static final function createPeerStateLookupTable () {
-               // Get new instance
-               $tableInstance = new PeerStateLookupTable();
-
-               // Get a database wrapper instance
-               $wrapperInstance = ObjectFactory::createObjectByConfiguredName('peer_state_lookup_db_wrapper_class');
-
-               // Set it for later re-use
-               $tableInstance->setWrapperInstance($wrapperInstance);
-
-               // Return the prepared instance
-               return $tableInstance;
-       }
-
-       /**
-        * Checks wether given 'sender' is a new peer
-        *
-        * @param       $packageData    Raw package data
-        * @return      $isNewPeer              Wether 'sender' is a new peer to this node
-        */
-       public function isSenderNewPeer (array $packageData) {
-               // Get our wrapper instance and ask for it
-               $isNewPeer = $this->getWrapperInstance()->isSenderNewPeer($packageData);
-
-               // Return it
-               return $isNewPeer;
-       }
-
-       /**
-        * Registers a peer with given package data. We use the session id from it
-        *
-        * @param       $packageData            Valid raw package data
-        * @param       $socketResource         A valid socket resource
-        * @return      void
-        */
-       public function registerPeerByPackageData (array $packageData, $socketResource) {
-               // Just handle it over
-               $this->getWrapperInstance()->registerPeerByPackageData($packageData, $socketResource);
-       }
-
-       /**
-        * Registers the given peer state and raw package data
-        *
-        * @param       $stateInstance  A PeerStateable class instance
-        * @param       $packageData    Valid package data array
-        * @return      void
-        */
-       public function registerPeerState (PeerStateable $stateInstance, array $packageData) {
-               die(__METHOD__."\n");
-       }
-
-       /**
-        * Purges old entries of given socket resource. We use the IP address from that resource.
-        *
-        * @param       $socketResource         A valid socket resource
-        * @return      void
-        */
-       public function purgeOldEntriesBySocketResource ($socketResource) {
-               // Just handle it over
-               $this->getWrapperInstance()->purgeOldEntriesBySocketResource($socketResource);
-       }
-}
-
-// [EOF]
+// @DEPRECATED
 ?>
index eace6673efe5db30033b1f624f8e223d0fec5ca1..fbe8f50dfc2e250c39f2c9731e1bf1b56788c65a 100644 (file)
@@ -540,7 +540,7 @@ class BaseHubNode extends BaseHubSystem implements Updateable {
                $this->getListenerPoolInstance()->addListener($decoratorInstance);
 
                // Get a decorator class
-               $decoratorInstance = ObjectFactory::createObjectByConfiguredName('peer_tcp_listener_class', array($listenerInstance));
+               $decoratorInstance = ObjectFactory::createObjectByConfiguredName('client_tcp_listener_class', array($listenerInstance));
 
                // Add this listener to the pool
                $this->getListenerPoolInstance()->addListener($decoratorInstance);
@@ -567,7 +567,7 @@ class BaseHubNode extends BaseHubSystem implements Updateable {
                $this->getListenerPoolInstance()->addListener($decoratorInstance);
 
                // Get a decorator class
-               $decoratorInstance = ObjectFactory::createObjectByConfiguredName('peer_udp_listener_class', array($listenerInstance));
+               $decoratorInstance = ObjectFactory::createObjectByConfiguredName('client_udp_listener_class', array($listenerInstance));
 
                // Add this listener to the pool
                $this->getListenerPoolInstance()->addListener($decoratorInstance);
diff --git a/application/hub/main/states/peer/new/class_NewConnectionNodeState.php b/application/hub/main/states/peer/new/class_NewConnectionNodeState.php
new file mode 100644 (file)
index 0000000..b6270bf
--- /dev/null
@@ -0,0 +1,50 @@
+<?php
+/**
+ * A NewConnection peer state class
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2011 Hub Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+class NewConnectionNodeState extends BasePeerState implements PeerStateable {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+       }
+
+       /**
+        * Creates an instance of this class
+        *
+        * @return      $stateInstance  An instance of a PeerStateable class
+        */
+       public static final function createNewConnectionNodeState () {
+               // Get new instance
+               $stateInstance = new NewConnectionNodeState();
+
+               // Return the prepared instance
+               return $stateInstance;
+       }
+}
+
+// [EOF]
+?>
index d72b8a359ade15fbb4f99f57af1e1a04df1b6758..f551ef47b7591c74e7b59193e56a1fa6505a87ab 100644 (file)
@@ -1,50 +1,3 @@
 <?php
-/**
- * A NewConnection peer state class
- *
- * @author             Roland Haeder <webmaster@ship-simu.org>
- * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2011 Hub Developer Team
- * @license            GNU GPL 3.0 or any newer version
- * @link               http://www.ship-simu.org
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-class NewConnectionPeerState extends BasePeerState implements PeerStateable {
-       /**
-        * Protected constructor
-        *
-        * @return      void
-        */
-       protected function __construct () {
-               // Call parent constructor
-               parent::__construct(__CLASS__);
-       }
-
-       /**
-        * Creates an instance of this class
-        *
-        * @return      $stateInstance  An instance of a PeerStateable class
-        */
-       public static final function createNewConnectionPeerState () {
-               // Get new instance
-               $stateInstance = new NewConnectionPeerState();
-
-               // Return the prepared instance
-               return $stateInstance;
-       }
-}
-
-// [EOF]
+// @DEPRECATED
 ?>