application/hub/interfaces/lists/class_Listable.php svneol=native#text/plain
application/hub/interfaces/lookup/.htaccess -text svneol=unset#text/plain
application/hub/interfaces/lookup/class_Lookupable.php svneol=native#text/plain
+application/hub/interfaces/lookup/node_states/.htaccess -text svneol=unset#text/plain
+application/hub/interfaces/lookup/node_states/class_LookupableNodeState.php svneol=native#text/plain
application/hub/interfaces/lookup/peer_states/.htaccess -text svneol=unset#text/plain
application/hub/interfaces/lookup/peer_states/class_LookupablePeerState.php svneol=native#text/plain
application/hub/interfaces/messages/.htaccess svneol=native#text/plain
application/hub/main/controller/console/class_HubConsoleChatController.php svneol=native#text/plain
application/hub/main/controller/console/class_HubConsoleCruncherController.php svneol=native#text/plain
application/hub/main/controller/console/class_HubConsoleDefaultNewsController.php svneol=native#text/plain
+application/hub/main/controller/http/.htaccess -text svneol=unset#text/plain
application/hub/main/cruncher/.htaccess svneol=native#text/plain
application/hub/main/cruncher/class_BaseHubCruncher.php svneol=native#text/plain
application/hub/main/cruncher/mcrypt/.htaccess svneol=native#text/plain
application/hub/main/resolver/controller/.htaccess -text svneol=unset#text/plain
application/hub/main/resolver/controller/console/.htaccess -text svneol=unset#text/plain
application/hub/main/resolver/controller/console/class_HubConsoleControllerResolver.php svneol=native#text/plain
+application/hub/main/resolver/controller/http/.htaccess -text svneol=unset#text/plain
application/hub/main/resolver/state/.htaccess -text svneol=unset#text/plain
application/hub/main/resolver/state/class_BaseStateResolver.php svneol=native#text/plain
application/hub/main/resolver/state/network/.htaccess -text svneol=unset#text/plain
application/hub/main/resolver/state/network/class_NetworkStateResolver.php svneol=native#text/plain
+application/hub/main/resolver/state/peer/.htaccess -text svneol=unset#text/plain
+application/hub/main/resolver/state/peer/class_PeerStateResolver.php svneol=native#text/plain
application/hub/main/source/.htaccess svneol=native#text/plain
application/hub/main/source/class_BaseSource.php svneol=native#text/plain
application/hub/main/source/units/.htaccess svneol=native#text/plain
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/connected/.htaccess -text svneol=unset#text/plain
+application/hub/main/states/peer/connected/class_ConnectedPeerState.php svneol=native#text/plain
+application/hub/main/states/peer/errors/.htaccess -text svneol=unset#text/plain
+application/hub/main/states/peer/errors/class_ConnectionRefusedPeerState.php svneol=native#text/plain
+application/hub/main/states/peer/init/.htaccess -text svneol=unset#text/plain
+application/hub/main/states/peer/init/class_InitPeerState.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/states/peer/transport_endpoint/.htaccess -text svneol=unset#text/plain
+application/hub/main/states/peer/transport_endpoint/class_TransportEndpointGonePeerState.php svneol=native#text/plain
+application/hub/main/statistics/.htaccess -text svneol=unset#text/plain
+application/hub/main/statistics/connection/.htaccess -text svneol=unset#text/plain
application/hub/main/streams/.htaccess svneol=native#text/plain
application/hub/main/streams/package/.htaccess svneol=native#text/plain
application/hub/main/streams/package/input/.htaccess svneol=native#text/plain
db/news/.htaccess -text svneol=unset#text/plain
db/node_data/.htaccess -text svneol=unset#text/plain
db/node_list/.htaccess -text svneol=unset#text/plain
+db/node_states/.htaccess -text svneol=unset#text/plain
db/peer_states/.htaccess -text svneol=unset#text/plain
docs/COPYING -text
docs/COPYING.documents -text
/.settings
application/hub/config-local.php
db/node_data/*.serialized
+db/node_states/*.serialized
+db/peer_states/*.serialized
docs/warn.log
/nbproject
/**
* An instance of this class
*/
- private static $thisInstance = null;
+ private static $thisInstance = NULL;
/**
* Private constructor
// Set this application in registry
Registry::getRegistry()->addInstance('app', $this);
+ // Default response is console
+ $response = $this->getResponseTypeFromSystem();
+ $responseType = $this->getResponseTypeFromSystem();
+
// Create a new request object
- $requestInstance = ObjectFactory::createObjectByName('ConsoleRequest');
+ $requestInstance = ObjectFactory::createObjectByName($this->convertToClassName($response) . 'Request');
// Remember request instance here
$this->setRequestInstance($requestInstance);
- // Default response is console
- $response = 'console';
- $responseType = 'console';
-
- // Do we have a 'client' parameter set?
- if ($requestInstance->isRequestElementSet('client')) {
- // Extend the response type
- $responseType = 'client_' . $responseType;
- } // END - if
-
// Do we have another response?
if ($requestInstance->isRequestElementSet('request')) {
- // Then use it, this does override above 'client'!
+ // Then use it
$response = strtolower($requestInstance->getRequestElement('request'));
$responseType = $response;
} // END - if
// CFG: NODE-LIST-DB-WRAPPER-CLASS
$cfg->setConfigEntry('node_list_db_wrapper_class', 'NodeListDatabaseWrapper');
-// CFG: NODE-LOOKUP-DB-WRAPPER-CLASS
-$cfg->setConfigEntry('node_state_lookup_db_wrapper_class', 'NodeStateLookupDatabaseWrapper');
+// CFG: PEER-LOOKUP-DB-WRAPPER-CLASS
+$cfg->setConfigEntry('peer_state_lookup_db_wrapper_class', 'PeerStateLookupDatabaseWrapper');
// CFG: WEB-CONTENT-TYPE
$cfg->setConfigEntry('web_content_type', '');
// CFG: UDP-CONNECT-RETRY-MAX
$cfg->setConfigEntry('udp_connect_retry_max', 10);
-// CFG: NODE-STATE-LOOKUP-TABLE-CLASS
-$cfg->setConfigEntry('node_state_lookup_table_class', 'NodeStateLookupTable');
-
// CFG: NODE-STATE-CHECKED-PACKAGE-CLASS
$cfg->setConfigEntry('node_state_checked_package_class', 'NewConnectionNodeState');
$cfg->setConfigEntry('node_raw_data_input_stream_class', 'RawDataInputStream');
///////////////////////////////////////////////////////////////////////////////
-// Cruncher Configuration
+// Peer states
+///////////////////////////////////////////////////////////////////////////////
+
+// CFG: PEER-INIT-STATE-CLASS
+$cfg->setConfigEntry('peer_init_state_class', 'InitPeerState');
+
+// CFG: PEER-CONNECTED-STATE-CLASS
+$cfg->setConfigEntry('peer_connected_state_class', 'ConnectedPeerState');
+
+// CFG: PEER-CONNECTION-REFUSED-STATE-CLASS
+$cfg->setConfigEntry('peer_connection_refused_state_class', 'ConnectionRefusedPeerState');
+
+// CFG: PEER-TRANSPORT-ENDPOINT-STATE-CLASS
+$cfg->setConfigEntry('peer_transport_endpoint_state_class', 'TransportEndpointGonePeerState');
+
+///////////////////////////////////////////////////////////////////////////////
+// Cruncher configuration
///////////////////////////////////////////////////////////////////////////////
// CFG: CRUNCHER-DEFAULT-MODE (can be only 'mcrypt' at the moment)
// CFG: CHAT-SHUTDOWN-FILTER
$cfg->setConfigEntry('chat_shutdown_filter', 'ChatShutdownFilter');
+///////////////////////////////////////////////////////////////////////////////
+// HTTP Configuration
+///////////////////////////////////////////////////////////////////////////////
+
+// CFG: DEFAULT-WEB-COMMAND
+$cfg->setConfigEntry('default_web_command', 'home');
+
+// CFG: WEB-CMD-HOME-RESOLVER-CLASS
+$cfg->setConfigEntry('web_cmd_home_resolver_class', 'WebCommandResolver');
+
+// CFG: NEWS-HOME-LIMIT
+$cfg->setConfigEntry('news_home_limit', 10);
+
// [EOF]
?>
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-// The hub's own exception handler
+// The node's own exception handler
function hub_exception_handler ($exceptionInstance) {
// Is it an object and a valid instance?
if ((is_object($exceptionInstance)) && ($exceptionInstance instanceof FrameworkException)) {
$message = sprintf("[%s:%d] Sender %s is already registered.",
$messageArray[0]->__toString(),
$this->getLine(),
- $messageArray[NetworkPackage::INDEX_PACKAGE_SENDER]
+ $messageArray[NetworkPackage::PACKAGE_DATA_SENDER]
);
// Call parent exception constructor
public function __construct (Stateable $stateInstance, $code) {
// Construct the message
$message = sprintf("[%s:%d] Unexpected state detected.",
- $nodeSateInstance->__toString(),
+ $stateInstance->__toString(),
$this->getLine()
);
* @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
+ * @todo Please find another name for this interface
*
* 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
*/
function sendRawPackageData (array $packageData);
- /**
- * Checks wether the connect retry is exhausted
- *
- * @return $isExhaused Wether connect retry is exchausted
- */
- function isConnectRetryExhausted ();
-
/**
* Do the shutdown sequence for this connection helper
*
* @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
+ * @todo Please find another name for this interface
*
* 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
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * An interface for node-state lookup tables
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2011 Hub Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+interface LookupableNodeState extends Lookupable {
+}
+
+// [EOF]
+?>
<?php
/**
- * An interface for peer-state lookup tables
+ * An interface for peer-state lookup table wrappers
*
* @author Roland Haeder <webmaster@ship-simu.org>
* @version 0.0.0
* "Enqueues" raw content into this delivery class by reading the raw content
* from given template instance and pushing it on the 'undeclared' stack.
*
- * @param $helperInstance An instance of a BaseHubHelper class
+ * @param $helperInstance An instance of a HelpableHub class
* @param $nodeInstance An instance of a NodeHelper class
* @return void
*/
- function enqueueRawDataFromTemplate (BaseHubHelper $helperInstance, NodeHelper $nodeInstance);
+ function enqueueRawDataFromTemplate (HelpableHub $helperInstance, NodeHelper $nodeInstance);
/**
* Checks wether a package has been enqueued for delivery.
* to all chunks and prepends a final hashsum chunk. It will return the
* final hash for faster processing of packages.
*
- * @param $packageData Raw package data array
- * @param $connectionInstance A helper instance for connections
- * @return $finalHash Final hash for faster processing
+ * @param $packageData Raw package data array
+ * @param $helperInstance An instance of a ConnectionHelper class
+ * @return $finalHash Final hash for faster processing
*/
- function fragmentPackageArray (array $packageData, BaseConnectionHelper $connectionInstance);
+ function fragmentPackageArray (array $packageData, ConnectionHelper $helperInstance);
/**
* This method gets the next chunk from the internal FIFO which should be
/**
* An instance of a node
*/
- private $nodeInstance = null;
+ private $nodeInstance = NULL;
/**
* An instance of a cruncher
*/
- private $cruncherInstance = null;
+ private $cruncherInstance = NULL;
/**
* Listener instance
*/
- private $listenerInstance = null;
+ private $listenerInstance = NULL;
/**
* A network package handler instance
*/
- private $packageInstance = null;
+ private $packageInstance = NULL;
/**
* A Receivable instance
*/
- private $receiverInstance = null;
+ private $receiverInstance = NULL;
/**
* State instance
*/
- private $stateInstance = null;
+ private $stateInstance = NULL;
/**
* Listener pool instance
*/
- private $listenerPoolInstance = null;
+ private $listenerPoolInstance = NULL;
/**
* Protected constructor
*/
public function shutdownSocket ($socketResource) {
// Debug message
- $this->debugOutput('Shutting down socket ' . $socketResource . ' ...');
+ $this->debugOutput('HUB-SYSTEM: Shutting down socket resource ' . $socketResource . ' with state ' . $this->getPrintableState() . ' ...');
// Set socket resource
$this->setSocketResource($socketResource);
/**
* The query class instance
*/
- private $queryInstance = null;
+ private $queryInstance = NULL;
/**
* Protected constructor
--- /dev/null
+Deny from all
/**
* All buffer queue instances (a FIFO)
*/
- private $bufferInstance = null;
+ private $bufferInstance = NULL;
/**
* Protected constructor
const DB_COLUMN_NODE_SESSION_ID = 'node_session_id';
const DB_COLUMN_NODE_IP_PORT = 'node_ipport';
+ // Other constants
+ const INVALID_IP_PORT = 'invalid:invalid';
+
/**
* Protected constructor
*
*/
public function resolveIpPortBySessionId ($sessionId) {
// Set invalid ip:port combination
- $recipient = 'invalid:invalid';
+ $recipient = self::INVALID_IP_PORT;
// Now get a search criteria instance
$searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
<?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]
+// @DEPRECATED
?>
<?php
-// @DEPRECATED
+/**
+ * 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 implements LookupablePeerState {
+ // 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';
+ const DB_COLUMN_SOCKET_ERROR_CODE = 'socket_error_code';
+ const DB_COLUMN_SOCKET_ERROR_MSG = 'socket_error_msg';
+
+ /**
+ * 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 peer
+ */
+ public function isSenderNewPeer (array $packageData) {
+ //* DEBUG: */ $this->debugOutput('DATABASE-WRAPPER: ' . __FUNCTION__ . ' called with packageData()=' . count($packageData) . ' - ENTERED!');
+ // Is always new peer by default
+ $isNewPeer = true;
+
+ // Is the package valid?
+ if (!isset($packageData[NetworkPackage::PACKAGE_DATA_SENDER])) {
+ // Invalid package found, please report this
+ die(__METHOD__ . ': packageData=' . print_r($packageData, true));
+ } // END - if
+
+ // Resolve session id > IP:port
+ //* DEBUG: */ $this->debugOutput('DATABASE-WRAPPER: sender=' . $packageData[NetworkPackage::PACKAGE_DATA_SENDER] . ' - resolving ...');
+ $ipPort = HubTools::resolveSessionId($packageData[NetworkPackage::PACKAGE_DATA_SENDER]);
+ //* DEBUG: */ $this->debugOutput('DATABASE-WRAPPER: ipPort=' . $ipPort);
+
+ // Is it not invalid:invalid?
+ if ($ipPort != NodeListDatabaseWrapper::INVALID_IP_PORT) {
+ // 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?
+ //* DEBUG: */ $this->debugOutput('DATABASE-WRAPPER: entries=' . $entries);
+ $isNewPeer = ($entries === 0);
+ } // END - if
+
+ // Return the result
+ //* DEBUG: */ $this->debugOutput('DATABASE-WRAPPER: isNewPeer=' . intval($isNewPeer) . ' - EXIT!');
+ 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
+ */
+ 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::PACKAGE_DATA_SENDER]);
+
+ // Get peer name
+ if (!@socket_getpeername($socketResource, $peerName, $peerPort)) {
+ // Get last error
+ $lastError = socket_last_error($socketResource);
+
+ // ... and cleartext message from it and put both into criteria
+ $dataSetInstance->addCriteria(self::DB_COLUMN_SOCKET_ERROR_CODE, $lastError);
+ $dataSetInstance->addCriteria(self::DB_COLUMN_SOCKET_ERROR_MSG , socket_strerror($lastError));
+ } // 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);
+ }
+
+ /**
+ * Registers the given peer state and raw package data
+ *
+ * @param $stateInstance A PeerStateable class instance
+ * @param $packageData Valid package data array
+ * @return void
+ * @todo Unfinished area
+ */
+ public function registerPeerState (PeerStateable $stateInstance, array $packageData) {
+ $this->debugBackTrace('stateInstance=' . $stateInstance->__toString() . ' - UNFINISHED AREA!');
+ }
+
+ /**
+ * 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]
?>
$listInstance->addEntry('ip_port', $ipPort);
break;
- // This may be a direct recipient (hub's session id)
+ // This may be a direct recipient (node's session id)
default:
$this->partialStub('Please add code handling recipients ' . $packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT]);
break;
$poolInstance = Registry::getRegistry()->getInstance('node')->getListenerPoolInstance();
// Init listener instance
- $listenerInstance = null;
+ $listenerInstance = NULL;
/*
* Now we need to choose again. It is wether we are speaking with a hub
* matching socket resource for that protocol.
*
* @param $packageData Raw package data array
- * @return $socketResource A valid socket resource
+ * @return $socketResource A valid socket resource or FALSE if an error occured
* @throws NoListGroupException If the procol group is not found in peer list
*/
public function discoverSocket (array $packageData) {
// If there is no listener who wants to have that package, we simply drop it here
if (is_null($listenerInstance)) {
- // @TODO We may need some locking here
+ // @TODO We may need some logging here
// Abort with no resource
return false;
} // END - if
$socketResource = $listenerInstance->getPoolInstance()->getSocketFromPackageData($packageData);
// Is it false, the recipient isn't known to us and we have no connection to it
- if (!is_resource($socketResource)) {
- // Create a new socket resource
- $socketResource = SocketFactory::createSocketFromPackageData($packageData, $protocolName);
+ if ((!is_resource($socketResource)) || (socket_last_error($socketResource) > 0)) {
+ // Try to create a new socket resource
+ try {
+ // Possibly noisy debug message
+ /* NOISY-DEBUG: */ $this->debugOutput('SOCKET-DISCOVERY: Trying to establish a ' . strtoupper($protocolName) . ' connection to ' . $packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT] . ' ...');
+
+ // Get a socket resource from our factory (if succeeded)
+ $socketResource = SocketFactory::createSocketFromPackageData($packageData, $protocolName);
+
+ // This succeeded, so change the state to 'CONNECTED'
+ } catch (SocketConnectionException $e) {
+ // The connection fails of being established, so log it away
+ $this->debugOutput('SOCKET-DISCOVERY: ' . $e->__toString() . ',message=' . $e->getMessage());
+ }
} // END - if
+ // Get the helper instance from registry
+ $helperInstance = Registry::getRegistry()->getInstance('connection');
+
+ // Resolve the peer's state (but ignore return value)
+ PeerStateResolver::resolveStateByPackage($helperInstance, $packageData, $socketResource);
+
// And return it
return $socketResource;
}
* @return $socketResource Socket resource
*/
public static function createSocketFromPackageData (array $packageData, $protocolName) {
- // Construct configuration entry for object factory
- $configEntry = $protocolName . '_connection_helper_class';
+ // Construct registry key
+ $registryKey = 'socket_' . $protocolName . '_' . $packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT];
- // And call the static method
- $socketResource = call_user_func(FrameworkConfiguration::getInstance()->getConfigEntry($configEntry) . '::createConnectionFromPackageData', $packageData);
+ // Is the key there?
+ if (Registry::getRegistry()->instanceExists($registryKey)) {
+ // Get container instance
+ $containerInstance = Registry::getRegistry()->getInstance($registryKey);
+
+ // Get socket back
+ $socketResource = $containerInstance->getSocketResource();
+ } else {
+ // Construct configuration entry for object factory and get it
+ $className = FrameworkConfiguration::getInstance()->getConfigEntry($protocolName . '_connection_helper_class');
+
+ // And call the static method
+ $socketResource = call_user_func($className . '::createConnectionFromPackageData', $packageData);
+
+ // Construct container class, this won't be reached if an exception is thrown
+ $containerInstance = ObjectFactory::CreateObjectByConfiguredName('socket_container_class', array($socketResource, NULL, $packageData));
+
+ // Register it with the registry
+ Registry::getRegistry()->addInstance($registryKey, $containerInstance);
+ }
// Return the resource
return $socketResource;
// Get a class from that configuration entry
$stateInstance = self::createObjectByConfiguredName($className, array($nodeInstance));
+ // Debug message
+ $stateInstance->debugOutput('NODE-STATE: Has changed from ' . $nodeInstance->getPrintableState() . ' to ' . $stateInstance->getStateName() . '.');
+
// Once we have that state, set it in the node instance
$nodeInstance->setStateInstance($stateInstance);
/**
* Static lookup table instance
*/
- private static $tableInstance = null;
+ private static $tableInstance = NULL;
/**
* Protected constructor
parent::__construct(__CLASS__);
}
+ /**
+ * Singleton getter for lookup table instances, kept public if we need this
+ * table somewhere else.
+ *
+ * @return $tableInstance An instance of a lookup table
+ */
+ public static final function getTableInstance () {
+ // Is the instance null?
+ if (is_null(self::$tableInstance)) {
+ // Get a new one
+ self::$tableInstance = self::createObjectByConfiguredName('peer_state_lookup_db_wrapper_class');
+ } // END - if
+
+ // Return it
+ return self::$tableInstance;
+ }
+
/**
* Creates a peer state instance based on errorCode if no entry is found in the lookup table
* for the peer given in $packageData 'sender' element or it changes the state if it differs
* from current state.
*
- * @param $errorCode The last error code
+ * @param $helperInstance An instance of a ConnectionHelper class
* @param $packageData Raw package data
* @param $socketResource A valid socket resource
+ * @param $errorCode The last error code
* @return $stateInstance A Stateable class instance
*/
- public static final function createPeerStateInstanceByErrorCode ($errorCode, array $packageData, $socketResource) {
+ public static final function createPeerStateInstanceBySocketStatusCode (ConnectionHelper $helperInstance, array $packageData, $socketResource, $errorCode) {
// So first we need our lookup table
$tableInstance = self::getTableInstance();
// Purge old entries
- $tableInstance->purgeOldEntriesBySocketResource($socketResource);
+ try {
+ $tableInstance->purgeOldEntriesBySocketResource($socketResource);
+ } catch (InvalidSocketException $e) {
+ // Just log all errors
+ $tableInstance->debugOutput('PEER-STATE-FACTORY: Purging of old entries failed. Message from exception: ' . $e->getMessage());
+ }
// Do we have an entry?
if ($tableInstance->isSenderNewPeer($packageData)) {
+ // Debug output
+ $tableInstance->debugOutput('PEER-STATE-FACTORY: errorCode=' . $errorCode);
+
// Is a new peer so create the state instance based on error code, first we need a config entry
- $configEntry = 'peer_state_' . $errorCode . '_class';
+ $configEntry = 'peer_' . $errorCode . '_state_class';
// Register the new peer with its session id
$tableInstance->registerPeerByPackageData($packageData, $socketResource);
$tableInstance->registerPeerState($stateInstance, $packageData);
} else {
// It is a known peer, so we need to check if the state has changed
- die(__METHOD__ . ': Lookup!' . "\n");
+ $this->debugBackTrace(__METHOD__ . ': Lookup!' . "\n");
}
+ // Debug message
+ $stateInstance->debugOutput('PEER-STATE[' . __LINE__ . ']: Has changed from ' . $helperInstance->getPrintableState() . ' to ' . $stateInstance->getStateName() . '.');
+
+ // Set the state in the helper
+ $helperInstance->setStateInstance($stateInstance);
+
// For any purposes, return the state instance
return $stateInstance;
}
/**
- * Singleton getter for lookup table instances, kept public if we need this
- * table somewhere else.
+ * Creates an instance of a configurable peer state and sets it in the
+ * given peer instance.
*
- * @return $tableInstance An instance of a lookup table
+ * @param $stateName Name of the state
+ * @param $helperInstance A ConnectionHelper class instance
+ * @return $stateInstance A Stateable class instance
*/
- public static final function getTableInstance () {
- // Is the instance null?
- if (is_null(self::$tableInstance)) {
- // Get a new one
- self::$tableInstance = self::createObjectByConfiguredName('node_state_lookup_table_class');
- } // END - if
+ public static final function createPeerStateInstanceByName ($stateName, ConnectionHelper $helperInstance) {
+ // Then construct the class' configuraton entry
+ $className = 'peer_' . $stateName . '_state_class';
- // Return it
- return self::$tableInstance;
+ // Get a class from that configuration entry
+ $stateInstance = self::createObjectByConfiguredName($className, array($helperInstance));
+
+ // Debug message
+ $stateInstance->debugOutput('PEER-STATE[' . __LINE__ . ']: Has changed from ' . $helperInstance->getPrintableState() . ' to ' . $stateInstance->getStateName() . '.');
+
+ // Once we have that state, set it in the peer instance
+ $helperInstance->setStateInstance($stateInstance);
+
+ // For any purposes, return the state instance
+ return $stateInstance;
}
}
const SOCKET_ERROR_INVALID_BASE64_MODULO = 'base64_modulo'; // Length is not modulo 4
const SOCKET_ERROR_INVALID_BASE64_MESSAGE = 'base64_message'; // Raw data is not Base64-encoded
const SOCKET_ERROR_UNHANDLED = 'unhandled_package'; // Unhandled raw data (not bad)
+ const SOCKET_ERROR_CONNECTION_REFUSED = 'connection_refused'; // The name says it: connection refused
+ const SOCKET_CONNECTED = 'connected'; // Nothing errorous happens, socket is connected
// - Package errors
const PACKAGE_ERROR_INVALID_DATA = 'invalid_data'; // Invalid data in package found
// Does it match?
// @TODO Numeric or alpha-numeric index?
- $matches = ($ownAddress === $packageData[NetworkPackage::INDEX_PACKAGE_RECIPIENT]);
+ $matches = ($ownAddress === $packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT]);
// Return result
return $matches;
/**
* Visitor instance for all tasks while they are active
*/
- private $visitorInstance = null;
+ private $visitorInstance = NULL;
/**
* Protected constructor
$this->getIteratorInstance()->next();
} // END - while
-
// Debug message
$this->debugOutput('TASK-HANDLER: Shutdown of all tasks completed.');
*/
private $diff = 0;
- /**
- * Connect retries for this connection
- */
- private $retryCount = 0;
-
/**
* Wether this connection is shutted down
*/
// And add it to this connection helper
$this->setOutputStreamInstance($streamInstance);
- }
- /**
- * Getter for port number to satify ProtocolHandler
- *
- * @return $port The port number
- */
- public final function getPort () {
- return $this->port;
+ // Init state which sets the state to 'init'
+ $this->initState();
}
/**
- * Setter for port number to satify ProtocolHandler
+ * Getter for real class name
*
- * @param $port The port number
- * @return void
+ * @return $class Name of this class
*/
- protected final function setPort ($port) {
- $this->port = $port;
- }
+ public function __toString () {
+ // Class name representation
+ $class = self::getConnectionClassName($this->getAddress(), $this->getPort(), parent::__toString());
- /**
- * Getter for protocol
- *
- * @return $protocol Used protocol
- */
- public final function getProtocol () {
- return $this->protocol;
+ // Return it
+ return $class;
}
/**
- * Setter for protocol
+ * Static "getter" for this connection class' name
*
- * @param $protocol Used protocol
- * @return void
+ * @param $address IP address
+ * @param $port Port number
+ * @param $className Original class name
+ * @return $class Expanded class name
*/
- protected final function setProtocol ($protocol) {
- $this->protocol = $protocol;
- }
+ public static function getConnectionClassName ($address, $port, $className) {
+ // Construct it
+ $class = $address . ':' . $port . ':' . $className;
- /**
- * Getter for IP address
- *
- * @return $address The IP address
- */
- public final function getAddress () {
- return $this->address;
+ // ... and return it
+ return $class;
}
/**
- * Setter for IP address
+ * Initializes the peer's state which sets it to 'init'
*
- * @param $address The IP address
* @return void
*/
- protected final function setAddress ($address) {
- $this->address = $address;
+ private function initState() {
+ /*
+ * Get the state factory and create the initial state, we don't need
+ * the state instance here
+ */
+ PeerStateFactory::createPeerStateInstanceByName('init', $this);
}
/**
}
}
+ /**
+ * Getter for port number to satify ProtocolHandler
+ *
+ * @return $port The port number
+ */
+ public final function getPort () {
+ return $this->port;
+ }
+
+ /**
+ * Setter for port number to satify ProtocolHandler
+ *
+ * @param $port The port number
+ * @return void
+ */
+ protected final function setPort ($port) {
+ $this->port = $port;
+ }
+
+ /**
+ * Getter for protocol
+ *
+ * @return $protocol Used protocol
+ */
+ public final function getProtocol () {
+ return $this->protocol;
+ }
+
+ /**
+ * Setter for protocol
+ *
+ * @param $protocol Used protocol
+ * @return void
+ */
+ protected final function setProtocol ($protocol) {
+ $this->protocol = $protocol;
+ }
+
+ /**
+ * Getter for IP address
+ *
+ * @return $address The IP address
+ */
+ public final function getAddress () {
+ return $this->address;
+ }
+
+ /**
+ * Setter for IP address
+ *
+ * @param $address The IP address
+ * @return void
+ */
+ protected final function setAddress ($address) {
+ $this->address = $address;
+ }
+
/**
* "Accept" a visitor by simply calling it back
*
* @throws InvalidSocketException If we got a problem with this socket
*/
public function sendRawPackageData (array $packageData) {
+ // The helper's state must be 'connected'
+ $this->getStateInstance()->validatePeerStateConnected();
+
// Cache buffer length
$bufferSize = $this->getConfigInstance()->getConfigEntry($this->getProtocol() . '_buffer_length');
return $totalSentBytes;
}
- /**
- * Getter for real class name
- *
- * @return $class Name of this class
- */
- public function __toString () {
- // Class name representation
- $class = $this->getAddress() . ':' . $this->getPort() . ':' . parent::__toString();
-
- // Return it
- return $class;
- }
-
- /**
- * Checks wether the connect retry is exhausted
- *
- * @return $isExhaused Wether connect retry is exchausted
- */
- public final function isConnectRetryExhausted () {
- // Construct config entry
- $configEntry = $this->getProtocol() . '_connect_retry_max';
-
- // Check it out
- $isExhausted = ($this->retryCount >= $this->getConfigInstance()->getConfigEntry($configEntry));
-
- // Return it
- return $isExhausted;
- }
-
- /**
- * Increases the connect retry count
- *
- * @return void
- */
- public final function increaseConnectRetry () {
- $this->retryCount++;
- }
-
/**
* Marks this connection as shutted down
*
* @return void
*/
- protected final function markConnectionShutdown () {
+ protected final function markConnectionShuttedDown () {
+ /* NOISY-DEBUG: */ $this->debugOutput('CONNECTION: ' . $this->__toString() . ' has been marked as shutted down');
$this->shuttedDown = true;
}
* @return $shuttedDown Wether this connection is shutted down
*/
public final function isShuttedDown () {
+ /* NOISY-DEBUG: */ $this->debugOutput('CONNECTION: ' . $this->__toString() . ',shuttedDown=' . intval($this->shuttedDown));
return $this->shuttedDown;
}
}
*
* @param $packageData Raw package data
* @return $socketResource Socket resource
- * @throws InvalidSocketException If the socket is invalid
+ * @throws SocketCreationException If the socket could not be created
+ * @throws SocketOptionException If a socket option could not be set
+ * @throws SocketConnectionException If a connection could not be opened
*/
public static function createConnectionFromPackageData (array $packageData) {
// Create an instance
// Is the socket resource valid?
if (!is_resource($socketResource)) {
// Something bad happened
- throw new InvalidSocketException(array($helperInstance, gettype($socketResource), 0, 'invalid'), BaseListener::EXCEPTION_INVALID_SOCKET);
+ throw new SocketCreationException(array($helperInstance, gettype($socketResource), 0, 'invalid'), BaseListener::EXCEPTION_SOCKET_CREATION_FAILED);
} // END - if
// Get socket error code for verification
// Check if there was an error else
if ($socketError > 0) {
+ // Shutdown this socket
+ $helperInstance->shutdownSocket($socketResource);
+
// Then throw again
- throw new InvalidSocketException(array($helperInstance, gettype($socketResource), $socketError, socket_strerror($socketError)), BaseListener::EXCEPTION_INVALID_SOCKET);
+ throw new SocketCreationException(array($helperInstance, gettype($socketResource), $socketError, socket_strerror($socketError)), BaseListener::EXCEPTION_SOCKET_CREATION_FAILED);
} // END - if
// Set the option to reuse the port
$helperInstance->shutdownSocket($socketResource);
// And throw again
- throw new InvalidSocketException(array($helperInstance, gettype($socketResource), $socketError, $errorMessage), BaseListener::EXCEPTION_INVALID_SOCKET);
+ throw new SocketOptionException(array($helperInstance, gettype($socketResource), $socketError, $errorMessage), BaseListener::EXCEPTION_INVALID_SOCKET);
} // END - if
// Set the resource
$helperInstance->shutdownSocket($socketResource);
// Throw it again
- throw new InvalidSocketException(array($helperInstance, gettype($socketResource), $socketError, $errorMessage), BaseListener::EXCEPTION_INVALID_SOCKET);
+ throw new SocketConnectionException(array($helperInstance, gettype($socketResource), $socketError, $errorMessage), BaseListener::EXCEPTION_INVALID_SOCKET);
} else {
// Debug output
$helperInstance->debugOutput('CONNECTION: Operation is in progress, this usual for non-blocking connections.');
$helperInstance->shutdownSocket($socketResource);
// And throw again
- throw new InvalidSocketException(array($helperInstance, gettype($socketResource), $socketError, $errorMessage), BaseListener::EXCEPTION_INVALID_SOCKET);
+ throw new SocketOptionException(array($helperInstance, gettype($socketResource), $socketError, $errorMessage), BaseListener::EXCEPTION_INVALID_SOCKET);
} // END - if
+ // We have a connection, so change the state
+ PeerStateFactory::createPeerStateInstanceByName('connected', $this);
+
// Okay, that should be it. So return it...
return $socketResource;
}
* @todo We may want to implement a filter for ease notification of other objects like our pool
*/
public function doShutdown () {
+ // Debug message
+ $this->debugOutput('HELPER: Shutting down socket resource ' . $this->getSocketResource());
+
// Clear any previous errors
socket_clear_error($this->getSocketResource());
} // END - if
// Mark this connection as shutted down
- $this->markConnectionShutdown();
+ $this->markConnectionShuttedDown();
}
}
*/
public function current () {
// Default is null
- $current = null;
+ $current = NULL;
$this->partialStub('Please implement this method.');
*/
public function key () {
// Default is null
- $key = null;
+ $key = NULL;
$this->partialStub('Please implement this method.');
*/
public function current () {
// Default is null
- $current = null;
+ $current = NULL;
// Is the entry valid?
if (!$this->valid()) {
*/
public function current () {
// Default is null
- $current = null;
+ $current = NULL;
// Is the entry valid?
if (!$this->valid()) {
*/
public function current () {
// Default is null
- $current = null;
+ $current = NULL;
// Is the entry valid?
if (!$this->valid()) {
*/
public function current () {
// Default is null
- $current = null;
+ $current = NULL;
// Is the entry valid?
if (!$this->valid()) {
*/
public function current () {
// Default is null
- $current = null;
+ $current = NULL;
// Is the entry valid?
if (!$this->valid()) {
*/
public function current () {
// Default is null
- $current = null;
+ $current = NULL;
// Is the entry valid?
if (!$this->valid()) {
// Exception code constants
const EXCEPTION_INVALID_SOCKET = 0xa00;
const EXCEPTION_SOCKET_ALREADY_REGISTERED = 0xa01;
+ const EXCEPTION_SOCKET_CREATION_FAILED = 0xa02;
/**
* Used protocol (Default: invalid, which is indeed invalid...)
/**
* A peer pool instance
*/
- private $poolInstance = null;
+ private $poolInstance = NULL;
/**
* Protected constructor
<?php
-/**
- * A ??? 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 ???LookupTable extends BaseLookupTable implements Lookupable {
- /**
- * 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 final static function create???LookupTable () {
- // Get new instance
- $tableInstance = new ???LookupTable();
-
- // Return the prepared instance
- return $tableInstance;
- }
-}
-
-// [EOF]
+// @DEPRECATED
?>
<?php
-/**
- * A general LookupTable 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 BaseLookupTable extends BaseHubSystem {
- /**
- * Protected constructor
- *
- * @param $className Name of the class
- * @return void
- */
- protected function __construct ($className) {
- // Call parent constructor
- parent::__construct($className);
- }
-}
-
-// [EOF]
+// @DEPRECATED
?>
<?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]
+// @DEPRECATED
?>
/**
* Query connector instance
*/
- private $queryConnectorInstance = null;
+ private $queryConnectorInstance = NULL;
/**
* Queue connector instance
*/
- private $queueConnectorInstance = null;
+ private $queueConnectorInstance = NULL;
/**
* Wether this node is anncounced (KEEP ON false!)
* @return void
*/
private function initState() {
- // Get the state factory and create the initial state, we don't need
- // the state instance here
+ /*
+ * Get the state factory and create the initial state, we don't need
+ * the state instance here
+ */
NodeStateFactory::createNodeStateInstanceByName('init', $this);
}
/**
* Named array elements for package data
*/
- const PACKAGE_DATA_RECIPIENT = 'recipient';
const PACKAGE_DATA_SENDER = 'sender';
+ const PACKAGE_DATA_RECIPIENT = 'recipient';
const PACKAGE_DATA_CONTENT = 'content';
/**
* "Getter" for hash from given content and helper instance
*
* @param $content Raw package content
- * @param $helperInstance An instance of a BaseHubHelper class
+ * @param $helperInstance An instance of a HelpableHub class
* @param $nodeInstance An instance of a NodeHelper class
* @return $hash Hash for given package content
* @todo $helperInstance is unused
*/
- private function getHashFromContent ($content, BaseHubHelper $helperInstance, NodeHelper $nodeInstance) {
+ private function getHashFromContent ($content, HelpableHub $helperInstance, NodeHelper $nodeInstance) {
// Create the hash
- // @TODO crc32 is not very strong, but it needs to be fast
+ // @TODO crc32() is not very strong, but it needs to be fast
$hash = crc32(
$content .
self::PACKAGE_CHECKSUM_SEPERATOR .
// Now discover the right protocol
$socketResource = $discoveryInstance->discoverSocket($packageData);
+ // Get the listener from registry
+ $helperInstance = Registry::getRegistry()->getInstance('connection');
+
// We have to put this socket in our registry, so get an instance
$registryInstance = SocketRegistry::createSocketRegistry();
- // Get the listener from registry
- $connectionInstance = Registry::getRegistry()->getInstance('connection');
-
// Is it not there?
- if (!$registryInstance->isSocketRegistered($connectionInstance, $socketResource)) {
+ if ((is_resource($socketResource)) && (!$registryInstance->isSocketRegistered($helperInstance, $socketResource))) {
// Then register it
- $registryInstance->registerSocket($connectionInstance, $socketResource, $packageData);
+ $registryInstance->registerSocket($helperInstance, $socketResource, $packageData);
} // END - if
+ // Make sure the connection is up
+ $helperInstance->getStateInstance()->validatePeerStateConnected();
+
// We enqueue it again, but now in the out-going queue
$this->getStackerInstance()->pushNamed(self::STACKER_NAME_OUTGOING, $packageData);
}
* @return void
*/
private function sendOutgoingRawPackageData (array $packageData) {
+ // Init sent bytes
+ $sentBytes = 0;
+
// Get the right connection instance
- $connectionInstance = SocketRegistry::createSocketRegistry()->getHandlerInstanceFromPackageData($packageData);
+ $helperInstance = SocketRegistry::createSocketRegistry()->getHandlerInstanceFromPackageData($packageData);
// Is this connection still alive?
- if ($connectionInstance->isShuttedDown()) {
+ if ($helperInstance->isShuttedDown()) {
// This connection is shutting down
// @TODO We may want to do somthing more here?
return;
} // END - if
- // Sent it away (we catch exceptions one method above)
- $sentBytes = $connectionInstance->sendRawPackageData($packageData);
+ // Sent out package data
+ $sentBytes = $helperInstance->sendRawPackageData($packageData);
// Remember unsent raw bytes in back-buffer, if any
$this->storeUnsentBytesInBackBuffer($packageData, $sentBytes);
* "Enqueues" raw content into this delivery class by reading the raw content
* from given template instance and pushing it on the 'undeclared' stack.
*
- * @param $helperInstance An instance of a BaseHubHelper class
+ * @param $helperInstance An instance of a HelpableHub class
* @param $nodeInstance An instance of a NodeHelper class
* @return void
*/
- public function enqueueRawDataFromTemplate (BaseHubHelper $helperInstance, NodeHelper $nodeInstance) {
+ public function enqueueRawDataFromTemplate (HelpableHub $helperInstance, NodeHelper $nodeInstance) {
// Get the raw content ...
$content = $helperInstance->getTemplateInstance()->getRawTemplateData();
// Get the package again
$packageData = $this->getStackerInstance()->getNamed(self::STACKER_NAME_DECLARED);
- // And send it
- $this->deliverRawPackageData($packageData);
+ try {
+ // And try to send it
+ $this->deliverRawPackageData($packageData);
- // And remove it finally
- $this->getStackerInstance()->popNamed(self::STACKER_NAME_DECLARED);
+ // And remove it finally
+ $this->getStackerInstance()->popNamed(self::STACKER_NAME_DECLARED);
+ } catch (InvalidStateException $e) {
+ // The state is not excepected (shall be 'connected')
+ $this->debugOutput('PACKAGE: Unexpected state detected. message=' . $e->getMessage());
+ }
}
/**
$this->chunkHashes[$finalHash][] = $chunkHash;
// Prepend the hash to the chunk
- $chunk =
+ $chunk = (
$chunkHash . self::CHUNK_DATA_HASH_SEPERATOR .
$this->getNextHexSerialNumber() . self::CHUNK_DATA_HASH_SEPERATOR .
$chunk . self::CHUNK_SEPERATOR
- ;
+ );
// Make sure the chunk is not larger than a TCP package can hold
assert(strlen($chunk) <= NetworkPackage::TCP_PACKAGE_SIZE);
* to all chunks and prepends a chunk with all hashes only in it. It will
* return the final hash for faster processing of packages.
*
- * @param $packageData Raw package data array
- * @param $connectionInstance A helper instance for connections
- * @return $finalHash Final hash for faster processing
- * @todo $connectionInstance is unused
+ * @param $packageData Raw package data array
+ * @param $helperInstance An instance of a ConnectionHelper class
+ * @return $finalHash Final hash for faster processing
+ * @todo $helperInstance is unused
*/
- public function fragmentPackageArray (array $packageData, BaseConnectionHelper $connectionInstance) {
+ public function fragmentPackageArray (array $packageData, ConnectionHelper $helperInstance) {
// Is this package already fragmented?
if (!$this->isPackageProcessed($packageData)) {
// First we need to "implode" the array
// This may happen when the final hash is true
if ($finalHash === true) {
// Set current to null
- $current = null;
+ $current = NULL;
} else {
// Throw the exception
throw $e;
/**
* A list of pool entries
*/
- private $poolEntriesInstance = null;
+ private $poolEntriesInstance = NULL;
/**
* Protected constructor
*
* @param $socketResource A valid socket resource
* @return void
+ * @throws InvalidSocketException If the given socket has an error
*/
private function validateSocket ($socketResource) {
// Is it a valid resource?
/**
* Outgoing work-queue
*/
- private $outgoingQueueInstance = null;
+ private $outgoingQueueInstance = NULL;
/**
* Incoming raw data/items queue
*/
- private $incomingQueueInstance = null;
+ private $incomingQueueInstance = NULL;
/**
* Protected constructor
/**
* Instance of this class
*/
- private static $registryInstance = null;
+ private static $registryInstance = NULL;
/**
* Protected constructor
/**
* Instance of this class
*/
- private static $registryInstance = null;
+ private static $registryInstance = NULL;
/**
* Protected constructor
$socketInstance = ObjectFactory::CreateObjectByConfiguredName('socket_container_class', array($socketResource, $protocolInstance, $packageData));
// We have a sub-registry, the socket key and the socket, now we need to put all together
+ /* DEBUG: */ $this->debugOutput('SOCKET-REGISTRY: socketKey=' . $socketKey . ',socketResource=' . $socketResource);
$registryInstance->addInstance($socketKey, $socketInstance);
}
*/
public function getHandlerInstanceFromPackageData (array $packageData) {
// Init protocol instance
- $protocolInstance = null;
+ $protocolInstance = NULL;
// Get all keys and check them
foreach ($this->getInstanceRegistry() as $key=>$registryInstance) {
foreach ($registryInstance->getInstanceRegistry() as $subKey=>$containerInstance) {
// This is a SocketContainer instance, so does the recipient match?
if ($containerInstance->ifAddressMatches($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT])) {
- // Found one, so get the protocol instance and abort
+ // Found one, so get the protocol instance and abort any further search
$protocolInstance = $containerInstance->getProtocolInstance();
break;
} // END - if
public function resolveCommandByRequest (Requestable $requestInstance) {
// Init variables
$commandName = '';
- $commandInstance = null;
+ $commandInstance = NULL;
// This goes fine so let's resolve the command
$commandName = $requestInstance->getRequestElement('command');
*/
public function resolveCommand ($commandName) {
// Initiate the instance variable
- $commandInstance = null;
+ $commandInstance = NULL;
// Is the command empty? Then fall back to default command
if (empty($commandName)) $commandName = $this->getConfigInstance()->getConfigEntry('default_console_command');
*/
private function loadCommand ($commandName) {
// Init command instance
- $commandInstance = null;
+ $commandInstance = NULL;
// Create class name
$className = 'HubConsole' . $this->convertToClassName($commandName) . 'Command';
public function resolveController () {
// Init variables
$controllerName = '';
- $controllerInstance = null;
+ $controllerInstance = NULL;
// Get the command name
$controllerName = $this->getControllerName();
--- /dev/null
+Deny from all
*/
protected function loadState ($stateName) {
// Init state instance
- $stateInstance = null;
+ $stateInstance = NULL;
// Create state class name
$className = $this->getStatePrefix() . '' . $this->convertToClassName($stateName) . 'State';
if (class_exists($this->getClassName())) {
// This class does exist. :-)
$isValid = true;
- } elseif ($this->getClassName() != $this->statePrefix.'DefaultNewsState') {
+ } elseif ($this->getClassName() != $this->statePrefix . 'DefaultState') {
// Set default state
- $this->setClassName($this->statePrefix . 'DefaultNewsState');
+ $this->setClassName($this->statePrefix . 'DefaultState');
} else {
// All is tried, give it up here
throw new DefaultStateException($this, self::EXCEPTION_DEFAULT_STATE_GONE);
<?php
-/**
- * A resolver for resolving states locally
- *
- * @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 NetworkStateResolver extends BaseStateResolver implements StateResolver {
- /**
- * Last successfull resolved state (name)
- */
- private $lastStateName = '';
-
- /**
- * Last successfull resolved state (instance)
- */
- private $lastStateInstance = null;
-
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
-
- // Set prefix to 'Network'
- $this->setStatePrefix('Network');
- }
-
- /**
- * Creates an instance of a resolver class with a given state
- *
- * @return $resolverInstance The prepared state resolver instance
- */
- public static final function createNetworkStateResolver () {
- // Create the new instance
- $resolverInstance = new NetworkStateResolver();
-
- // Return the prepared instance
- return $resolverInstance;
- }
-
- /**
- * Returns an state instance for a given package class
- *
- * @param $packageInstance An instance of a package class
- * @param $packageData Raw package data
- * @param $socketResource A valid socket resource
- * @return $stateInstance An instance of the resolved state
- * @todo ~30% done
- */
- public function resolveStateByPackage (Networkable $packageInstance, array $packageData, $socketResource) {
- // Init state instance
- $stateInstance = null;
-
- // Get error code
- $errorCode = $packageInstance->getErrorCode();
-
- // Is the code a number, then we have to change it
- if (($errorCode == 134) || ($errorCode == 107)) {
- // Transport endpoint not connected, should be handled else!
- // @TODO On some systems it is 134, on some 107?
- $errorCode = BaseRawDataHandler::SOCKET_ERROR_TRANSPORT_ENDPOINT;
- } elseif (is_int($errorCode)) {
- // Unhandled error code detected, so first debug it because we may want to handle it like the others
- $this->debugOutput('[' . __METHOD__ . ':' . __LINE__ . '] UNKNOWN ERROR CODE = ' . $errorCode, ', MESSAGE = ' . socket_strerror($errorCode));
-
- // Change it only in this class
- $errorCode = BaseRawDataHandler::SOCKET_ERROR_UNKNOWN;
- } // END - if
-
- // Create a state instance based on $errorCode. This factory does the hard work for us
- $stateInstance = PeerStateFactory::createPeerStateInstanceByErrorCode($errorCode, $packageData, $socketResource);
-
- // Return the prepared instance
- return $stateInstance;
- }
-}
-
-// [EOF]
+// @DEPRECATED
?>
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A resolver for resolving peer states locally
+ *
+ * @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 PeerStateResolver extends BaseStateResolver implements StateResolver {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+
+ // Set prefix to 'Peer'
+ $this->setStatePrefix('Peer');
+ }
+
+ /**
+ * Creates an instance of a resolver class with a given state
+ *
+ * @return $resolverInstance The prepared state resolver instance
+ */
+ public static final function createPeerStateResolver () {
+ // Create the new instance
+ $resolverInstance = new PeerStateResolver();
+
+ // Return the prepared instance
+ return $resolverInstance;
+ }
+
+ /**
+ * Returns an state instance for a given raw package data and socket resource
+ *
+ * @param $helperInstance An instance of a ConnectionHelper class
+ * @param $packageData Raw package data
+ * @param $socketResource A valid socket resource
+ * @return $stateInstance An instance of the resolved state
+ * @todo ~30% done
+ */
+ public static function resolveStateByPackage (ConnectionHelper $helperInstance, array $packageData, $socketResource) {
+ // Get temporary resolver instance
+ $resolverInstance = self::createPeerStateResolver();
+
+ // Init state instance
+ $stateInstance = NULL;
+
+ // Is the socket resource valid?
+ if (!is_resource($socketResource)) {
+ // No, so get socket resource from helper
+ $socketResource = $helperInstance->getSocketResource();
+ } // END - if
+
+ // Get error code from it
+ $errorCode = socket_last_error($socketResource);
+
+ // Is the code a number, then we have to change it
+ if (($errorCode == 134) || ($errorCode == 107)) {
+ // Transport endpoint not connected, should be handled else!
+ // @TODO On some systems it is 134, on some 107?
+ $errorCode = BaseRawDataHandler::SOCKET_ERROR_TRANSPORT_ENDPOINT;
+ } elseif ($errorCode == 111) {
+ // Error 'connection refused'
+ $errorCode = BaseRawDataHandler::SOCKET_ERROR_CONNECTION_REFUSED;
+ } elseif ($errorCode > 0) {
+ // Unhandled error code detected, so first debug it because we may want to handle it like the others
+ $resolverInstance->debugOutput('[' . __METHOD__ . ':' . __LINE__ . '] UNKNOWN ERROR CODE = ' . $errorCode, ', MESSAGE = ' . socket_strerror($errorCode));
+
+ // Change it only in this class
+ $errorCode = BaseRawDataHandler::SOCKET_ERROR_UNKNOWN;
+ } else {
+ // Nothing bad happend
+ $errorCode = BaseRawDataHandler::SOCKET_CONNECTED;
+ }
+
+ // Create a state instance based on $errorCode. This factory does the hard work for us
+ $stateInstance = PeerStateFactory::createPeerStateInstanceBySocketStatusCode($helperInstance, $packageData, $socketResource, $errorCode);
+
+ // Return the prepared instance
+ return $stateInstance;
+ }
+}
+
+// [EOF]
+?>
// Get new instance
$stateInstance = new CruncherInitState();
- // Debug message
- $stateInstance->debugOutput('CRUNCHER-STATE: Has changed from ' . $cruncherInstance->getPrintableState() . ' to ' . $stateInstance->getStateName() . '.');
-
// Set the cruncher instance
$stateInstance->setCruncherInstance($cruncherInstance);
// Get new instance
$stateInstance = new CruncherVirginState();
- // Debug message
- $stateInstance->debugOutput('CRUNCHER-STATE: Has changed from ' . $cruncherInstance->getPrintableState() . ' to ' . $stateInstance->getStateName() . '.');
-
// Set the cruncher instance
$stateInstance->setCruncherInstance($cruncherInstance);
// Get new instance
$stateInstance = new NodeActiveState();
- // Debug message
- $stateInstance->debugOutput('NODE-STATE: Has changed from ' . $nodeInstance->getPrintableState() . ' to ' . $stateInstance->getStateName() . '.');
-
// Enable isActive flag in node instance
$nodeInstance->enableIsActive();
// Get new instance
$stateInstance = new NodeAnnouncedState();
- // Debug message
- $stateInstance->debugOutput('NODE-STATE: Has changed from ' . $nodeInstance->getPrintableState() . ' to ' . $stateInstance->getStateName() . '.');
-
// Set the node instance
$stateInstance->setNodeInstance($nodeInstance);
// Get new instance
$stateInstance = new NodeInitState();
- // Debug message
- $stateInstance->debugOutput('NODE-STATE: Has changed from ' . $nodeInstance->getPrintableState() . ' to ' . $stateInstance->getStateName() . '.');
-
// Set the node instance
$stateInstance->setNodeInstance($nodeInstance);
// Get new instance
$stateInstance = new NodeVirginState();
- // Debug message
- $stateInstance->debugOutput('NODE-STATE: Has changed from ' . $nodeInstance->getPrintableState() . ' to ' . $stateInstance->getStateName() . '.');
-
// Set the node instance
$stateInstance->setNodeInstance($nodeInstance);
protected function __construct () {
// Call parent constructor
parent::__construct(__CLASS__);
+
+ // Set state name
+ $this->setStateName('!!!');
}
/**
// Call parent constructor
parent::__construct($className);
}
+
+ /**
+ * Validates wether the state is 'connected' or throws an exception if
+ * it is every other state.
+ *
+ * @return void
+ * @throws InvalidStateException If the state is not 'connected'
+ */
+ public function validatePeerStateConnected () {
+ // Just compare it...
+ if (!$this->isPeerStateConnected()) {
+ // Throw the exception
+ throw new InvalidStateException($this, self::EXCEPTION_INVALID_STATE);
+ } // END - if
+ }
+
+ /**
+ * Checks wether the peer's state is 'connected'
+ *
+ * @return $isConnected Wether the state is 'connected'
+ */
+ public function isPeerStateConnected () {
+ // Just compare it...
+ return ($this instanceof ConnectedPeerState);
+ }
}
// [EOF]
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A Connected 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 ConnectedPeerState extends BasePeerState implements PeerStateable {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+
+ // Set state name
+ $this->setStateName('');
+ }
+
+ /**
+ * Creates an instance of this class
+ *
+ * @return $stateInstance An instance of a PeerStateable class
+ */
+ public final static function createConnectedPeerState () {
+ // Get new instance
+ $stateInstance = new ConnectedPeerState();
+
+ // Return the prepared instance
+ return $stateInstance;
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A ConnectionRefused 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 ConnectionRefusedPeerState extends BasePeerState implements PeerStateable {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+
+ // Set state name
+ $this->setStateName('connection_refused');
+ }
+
+ /**
+ * Creates an instance of this class
+ *
+ * @return $stateInstance An instance of a PeerStateable class
+ */
+ public final static function createConnectionRefusedPeerState () {
+ // Get new instance
+ $stateInstance = new ConnectionRefusedPeerState();
+
+ // Return the prepared instance
+ return $stateInstance;
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A Init 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 InitPeerState extends BasePeerState implements PeerStateable {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+
+ // Set state name
+ $this->setStateName('init');
+ }
+
+ /**
+ * Creates an instance of this class
+ *
+ * @return $stateInstance An instance of a PeerStateable class
+ */
+ public final static function createInitPeerState () {
+ // Get new instance
+ $stateInstance = new InitPeerState();
+
+ // Return the prepared instance
+ return $stateInstance;
+ }
+}
+
+// [EOF]
+?>
<?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]
+// @DEPRECATED
?>
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A TransportEndpointGone 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 TransportEndpointGonePeerState extends BasePeerState implements PeerStateable {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+
+ // Set state name
+ $this->setStateName('transport_endpoint');
+ }
+
+ /**
+ * Creates an instance of this class
+ *
+ * @return $stateInstance An instance of a PeerStateable class
+ */
+ public final static function createTransportEndpointGonePeerState () {
+ // Get new instance
+ $stateInstance = new TransportEndpointGonePeerState();
+
+ // Return the prepared instance
+ return $stateInstance;
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+Deny from all
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A helper class for maintaining connection statistics, no instance is
+ * required to use this class.
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2011 Core Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.ship-simu.org
+ * @todo Find an interface for hub helper
+ *
+ * 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 ConnectionStatisticsHelper extends BaseHubSystem {
+ /**
+ * Statistics array
+ */
+ private static $connectionStatistics = array(
+ // Statistics for TCP connections
+ 'tcp' => array(
+ // Tried connection attempts
+ 'retry_count' => array(),
+ ),
+ // Statistics for UDP connections
+ 'udp' => array(
+ 'retry_count' => array(),
+ )
+ );
+
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Checks wether the retry count has reached a configured limit for given
+ * connection.
+ *
+ * @param $helperInstance An instance of a ConnectionHelper class
+ * @return $isExhausted Wether the retry count has been reached
+ */
+ public static function isConnectRetryExhausted (ConnectionHelper $helperInstance) {
+ //* DEBUG: */ $helperInstance->debugOutput(__METHOD__ . ':helperInstance=' . $helperInstance->__toString() . ' - ENTERED!');
+ // Construct config entry
+ $configEntry = $helperInstance->getProtocol() . '_connect_retry_max';
+
+ // Check it out
+ $isExhausted = (
+ (
+ isset(self::$connectionStatistics[$helperInstance->getProtocol()][$helperInstance->__toString()]['retry_count'])
+ ) && (
+ self::$connectionStatistics[$helperInstance->getProtocol()][$helperInstance->__toString()]['retry_count'] >= $helperInstance->getConfigInstance()->getConfigEntry($configEntry)
+ )
+ );
+
+ // Return it
+ //* DEBUG: */ $helperInstance->debugOutput(__METHOD__ . ':helperInstance=' . $helperInstance->__toString() . ',isExhausted=' . intval($isExhausted) . ' - EXIT!');
+ return $isExhausted;
+ }
+
+ /**
+ * Increaes connect-retry count for given connection
+ *
+ * @param $helperInstance An instance of a ConnectionHelper class
+ * @return void
+ */
+ public static function increaseConnectRetry (ConnectionHelper $helperInstance) {
+ //* DEBUG: */ $helperInstance->debugOutput(__METHOD__ . ':helperInstance=' . $helperInstance->__toString() . ' - ENTERED!');
+ // Is the counter there
+ if (!isset(self::$connectionStatistics[$helperInstance->getProtocol()][$helperInstance->__toString()]['retry_count'])) {
+ // First attempt
+ //* DEBUG: */ $helperInstance->debugOutput(__METHOD__ . ':helperInstance=' . $helperInstance->__toString() . ' - FIRST!');
+ self::$connectionStatistics[$helperInstance->getProtocol()][$helperInstance->__toString()]['retry_count'] = 1;
+ } else {
+ // Next attempt
+ //* DEBUG: */ $helperInstance->debugOutput(__METHOD__ . ':helperInstance=' . $helperInstance->__toString() . ' - INCREMENT!');
+ self::$connectionStatistics[$helperInstance->getProtocol()][$helperInstance->__toString()]['retry_count']++;
+ }
+
+ // Create/update 'last_update' for later purging
+ self::$connectionStatistics[$helperInstance->getProtocol()][$helperInstance->__toString()]['last_update'] = time();
+ }
+}
+
+// [EOF]
+?>
/**
* Instance for the object registry
*/
- private $objectRegistryInstance = null;
+ private $objectRegistryInstance = NULL;
/**
* Main nodes in the XML tree
/**
* Self instance
*/
- private static $selfInstance = null;
+ private static $selfInstance = NULL;
/**
* Protected constructor
} // END - if
} elseif (preg_match('/([a-f0-9]{' . $selfInstance->getSessionIdLength() . '})/', $sessionId)) {
// Debug message
- $selfInstance->debugOutput('HUB-TOOLS: Using internal resolver.');
+ $selfInstance->debugOutput('HUB-TOOLS: Using internal session id resolver.');
// Resolve session id into a ip:port combination
$recipient = $selfInstance->resolveIpPortBySessionId($sessionId);
* "Visit" method to do the actual request. Here we want to shutdown the
* attached socket.
*
- * @param $helperInstance A BaseConnectionHelper instance
+ * @param $helperInstance A ConnectionHelper instance
* @return void
*/
- public function visitConnectionHelper (BaseConnectionHelper $helperInstance) {
+ public function visitConnectionHelper (ConnectionHelper $helperInstance) {
// Do we have reached the retry count?
- if ($helperInstance->isConnectRetryExhausted()) {
+ if (ConnectionStatisticsHelper::isConnectRetryExhausted($helperInstance)) {
// Shutdown the connection
$helperInstance->doShutdown();
} else {
// We can still move on and retry the connection attempt
- $helperInstance->increaseConnectRetry();
+ ConnectionStatisticsHelper::increaseConnectRetry($helperInstance);
}
}
}
--- /dev/null
+Deny from all
[2009-04-30]
------------
- Detection of own IP address fixed (but might still be rewritten)
-- Boot-node code moved from NaseHubNode class to its own class (cleanup)
+- Boot-node code moved from BaseHubNode class to its own class (cleanup)
- FileNotFoundException in ConsoleTools was caught without any console
ouput which is not recommended.
- README updated to reflect changes in some revisions ago
This software is simply called "hub". This has a simple reason that this is,
first, the "working title" for it. And second, I have found no better name than
"Generic Object Sharing Hub" for this. I would not shortcut it to "Gosh" or
-"GNU Gosh" or such other title, because the word "gosh" is english and
+"GNU Gosh" or such other title, because the word "gosh" is English and
completely misleading.
So if you have a really good ("selling") name, please send it to me:
### WARNING: THIS FILE IS AUTO-GENERATED BY ./todo-builder.sh ###
### DO NOT EDIT THIS FILE. ###
+./application/hub/interfaces/chat/class_Chatter.php:10: * @todo We need to find a better name for this interface
./application/hub/interfaces/cruncher/class_CruncherHelper.php:10: * @todo We need to find a better name for this interface
-./application/hub/interfaces/helper/connections/class_ConnectionHelper.php:44: * @todo We may want to implement a filter for ease notification of other objects like our pool
+./application/hub/interfaces/helper/connections/class_ConnectionHelper.php:10: * @todo Please find another name for this interface
+./application/hub/interfaces/helper/connections/class_ConnectionHelper.php:38: * @todo We may want to implement a filter for ease notification of other objects like our pool
+./application/hub/interfaces/helper/messages/class_MessageHelper.php:10: * @todo Please find another name for this interface
./application/hub/interfaces/nodes/class_NodeHelper.php:10: * @todo We need to find a better name for this interface
+./application/hub/main/commands/console/class_HubConsoleChatCommand.php:107: * @todo Should we add some more filters?
+./application/hub/main/commands/console/class_HubConsoleChatCommand.php:58: * @todo Try to create a ChatActivationTask or so
./application/hub/main/commands/console/class_HubConsoleCruncherCommand.php:107: * @todo Should we add some more filters?
./application/hub/main/commands/console/class_HubConsoleCruncherCommand.php:58: * @todo Try to create a CruncherActivationTask or so
./application/hub/main/commands/console/class_HubConsoleMainCommand.php:114: * @todo Should we add some more filters?
./application/hub/main/cruncher/mcrypt/class_HubMcryptCruncher.php:108: * @todo Implement this method
./application/hub/main/cruncher/mcrypt/class_HubMcryptCruncher.php:138: * @todo 0% done
./application/hub/main/cruncher/mcrypt/class_HubMcryptCruncher.php:98: // @TODO Implement this method
-./application/hub/main/discovery/socket/class_PackageSocketDiscovery.php:102: // @TODO We may need some locking here
+./application/hub/main/database/wrapper/states/class_PeerStateLookupDatabaseWrapper.php:165: * @todo Unfinished area
+./application/hub/main/discovery/socket/class_PackageSocketDiscovery.php:102: // @TODO We may need some logging here
./application/hub/main/factories/socket/class_SocketFactory.php:10: * @todo Find an interface for hub helper
+./application/hub/main/filter/bootstrap/chat/class_ChatBootstrapGenericActivationFilter.php:54: * @todo Maybe we want to do somthing more here?
./application/hub/main/filter/bootstrap/cruncher/class_CruncherBootstrapBufferQueueInitializerFilter.php:54: * @todo 0% done
./application/hub/main/filter/bootstrap/cruncher/class_CruncherBootstrapGenericActivationFilter.php:54: * @todo Maybe we want to do somthing more here?
+./application/hub/main/filter/chat/class_ChatInitializationFilter.php:54: * @todo 0% done
+./application/hub/main/filter/chat/class_ChatPhpRequirementsFilter.php:55: * @todo Add more test and try to add an extra message to the thrown exception
+./application/hub/main/filter/chat/class_ChatWelcomeTeaserFilter.php:55: * @todo Handle over the $responseInstance to outputConsoleTeaser()
./application/hub/main/filter/cruncher/class_CruncherInitializationFilter.php:54: * @todo 0% done
./application/hub/main/filter/cruncher/class_CruncherInitializationFilter.php:87: // @TODO Can we rewrite this to app_die() ?
./application/hub/main/filter/cruncher/class_CruncherPhpRequirementsFilter.php:55: * @todo Add more test and try to add an extra message to the thrown exception
-./application/hub/main/filter/cruncher/class_CruncherWelcomeTeaserFilter.php:55: * @todo Handle over the $responseInstance to outputCruncherTeaser()
+./application/hub/main/filter/cruncher/class_CruncherWelcomeTeaserFilter.php:55: * @todo Handle over the $responseInstance to outputConsoleTeaser()
./application/hub/main/filter/node/class_NodeInitializationFilter.php:54: * @todo 0% done
./application/hub/main/filter/node/class_NodeInitializationFilter.php:87: // @TODO Can we rewrite this to app_die() ?
./application/hub/main/filter/node/class_NodePhpRequirementsFilter.php:55: * @todo Add more test and try to add an extra message to the thrown exception
./application/hub/main/filter/shutdown/node/class_NodeShutdownDeinitQueuesFilter.php:55: * @todo 0% done
./application/hub/main/filter/shutdown/node/class_NodeShutdownFlushNodeListFilter.php:55: * @todo 0% done
./application/hub/main/filter/shutdown/node/class_NodeShutdownTaskHandlerFilter.php:55: * @todo 0% done
+./application/hub/main/filter/task/chat/class_ChatTaskHandlerInitializerFilter.php:55: * @todo 5% done
./application/hub/main/filter/task/cruncher/class_CruncherTaskHandlerInitializerFilter.php:55: * @todo 5% done
./application/hub/main/filter/task/node/class_NodeTaskHandlerInitializerFilter.php:55: * @todo Maybe some more tasks needs to be added?
-./application/hub/main/handler/network/class_BaseRawDataHandler.php:142: * @todo This method will be moved to a better place
-./application/hub/main/handler/network/class_BaseRawDataHandler.php:149: // @TODO Numeric or alpha-numeric index?
+./application/hub/main/handler/network/class_BaseRawDataHandler.php:144: * @todo This method will be moved to a better place
+./application/hub/main/handler/network/class_BaseRawDataHandler.php:151: // @TODO Numeric or alpha-numeric index?
./application/hub/main/handler/network/udp/class_UdpRawDataHandler.php:58: * @todo 0%
./application/hub/main/handler/tasks/class_TaskHandler.php:140: // @TODO Messurement can be added around this call
./application/hub/main/helper/connection/tcp/class_TcpConnectionHelper.php:10: * @todo Find an interface for hub helper
-./application/hub/main/helper/connection/tcp/class_TcpConnectionHelper.php:141: * @todo We may want to implement a filter for ease notification of other objects like our pool
+./application/hub/main/helper/connection/tcp/class_TcpConnectionHelper.php:149: * @todo We may want to implement a filter for ease notification of other objects like our pool
./application/hub/main/helper/connection/udp/class_UdpConnectionHelper.php:10: * @todo Find an interface for hub helper
./application/hub/main/helper/connection/udp/class_UdpConnectionHelper.php:54: * @todo We may want to implement a filter for ease notification of other objects like our pool
./application/hub/main/helper/hub/announcement/class_HubDescriptorHelper.php:10: * @todo Find an interface for hub helper
./application/hub/main/nodes/boot/class_HubBootNode.php:119: // @TODO Add some filters here
./application/hub/main/nodes/boot/class_HubBootNode.php:58: * @todo add some more special bootstrap things for this boot node
./application/hub/main/nodes/boot/class_HubBootNode.php:99: * @todo Unfinished method
-./application/hub/main/nodes/class_BaseHubNode.php:382: * @todo Try to make this method more generic so we can move it in BaseFrameworkSystem
-./application/hub/main/nodes/class_BaseHubNode.php:422: * @todo Change the first if() block to check for a specific state
-./application/hub/main/nodes/class_BaseHubNode.php:595: // @TODO Add some criteria, e.g. if the node is active or so
+./application/hub/main/nodes/class_BaseHubNode.php:384: * @todo Try to make this method more generic so we can move it in BaseFrameworkSystem
+./application/hub/main/nodes/class_BaseHubNode.php:424: * @todo Change the first if() block to check for a specific state
+./application/hub/main/nodes/class_BaseHubNode.php:597: // @TODO Add some criteria, e.g. if the node is active or so
./application/hub/main/nodes/list/class_HubListNode.php:58: * @todo Implement more bootstrap steps
./application/hub/main/nodes/list/class_HubListNode.php:68: * @todo Unfinished method
./application/hub/main/nodes/list/class_HubListNode.php:91: // @TODO Add some filters here
./application/hub/main/nodes/regular/class_HubRegularNode.php:68: * @todo Unfinished method
./application/hub/main/nodes/regular/class_HubRegularNode.php:91: // @TODO Add some filters here
./application/hub/main/package/class_NetworkPackage.php:210: * @todo $helperInstance is unused
-./application/hub/main/package/class_NetworkPackage.php:214: // @TODO crc32 is not very strong, but it needs to be fast
+./application/hub/main/package/class_NetworkPackage.php:214: // @TODO crc32() is not very strong, but it needs to be fast
./application/hub/main/package/class_NetworkPackage.php:23: * @todo Needs to add functionality for handling the object's type
-./application/hub/main/package/class_NetworkPackage.php:330: // @TODO We may want to do somthing more here?
-./application/hub/main/package/class_NetworkPackage.php:429: // @TODO Add some logging here
-./application/hub/main/package/class_NetworkPackage.php:455: // @TODO Add some logging here
-./application/hub/main/package/class_NetworkPackage.php:548: // @TODO Add some logging here
-./application/hub/main/package/class_NetworkPackage.php:626: // @TODO Add some content here
-./application/hub/main/package/fragmenter/class_PackageFragmenter.php:426: * @todo $connectionInstance is unused
-./application/hub/main/pools/peer/class_DefaultPeerPool.php:148: // @TODO Check for IP
+./application/hub/main/package/class_NetworkPackage.php:336: // @TODO We may want to do somthing more here?
+./application/hub/main/package/class_NetworkPackage.php:435: // @TODO Add some logging here
+./application/hub/main/package/class_NetworkPackage.php:461: // @TODO Add some logging here
+./application/hub/main/package/class_NetworkPackage.php:559: // @TODO Add some logging here
+./application/hub/main/package/class_NetworkPackage.php:637: // @TODO Add some content here
+./application/hub/main/package/fragmenter/class_PackageFragmenter.php:426: * @todo $helperInstance is unused
+./application/hub/main/pools/peer/class_DefaultPeerPool.php:149: // @TODO Check for IP
./application/hub/main/producer/cruncher/keys/class_CruncherKeyProducer.php:106: // @TODO Do something with it
./application/hub/main/producer/cruncher/keys/class_CruncherKeyProducer.php:62: * @todo Find something for init phase of this key producer
./application/hub/main/producer/cruncher/keys/class_CruncherKeyProducer.php:72: * @todo ~30% done
./application/hub/main/producer/cruncher/work_units/class_CruncherTestUnitProducer.php:79: * @todo ~60% done
./application/hub/main/producer/cruncher/work_units/class_CruncherTestUnitProducer.php:99: // @TODO Unfinished work here
-./application/hub/main/resolver/state/network/class_NetworkStateResolver.php:68: * @todo ~30% done
-./application/hub/main/resolver/state/network/class_NetworkStateResolver.php:80: // @TODO On some systems it is 134, on some 107?
-./application/hub/main/states/node/init/class_NodeInitState.php:63: * @todo We might want to move some calls to this method to fill it with life
+./application/hub/main/resolver/state/peer/class_PeerStateResolver.php:58: * @todo ~30% done
+./application/hub/main/resolver/state/peer/class_PeerStateResolver.php:79: // @TODO On some systems it is 134, on some 107?
+./application/hub/main/states/node/init/class_NodeInitState.php:60: * @todo We might want to move some calls to this method to fill it with life
+./application/hub/main/statistics/connection/class_ConnectionStatisticsHelper.php:11: * @todo Find an interface for hub helper
./application/hub/main/streams/raw_data/input/class_RawDataInputStream.php:57: * @todo Do we need to do something more here?
./application/hub/main/streams/raw_data/output/class_RawDataOutputStream.php:53: * @todo Do we need to do something more here?
./application/hub/main/tasks/cruncher/class_CruncherKeyProducerTask.php:53: * @todo Maybe visit some sub-objects
./inc/classes/main/controller/web/class_WebStatusController.php:10: * @todo This controller shall still provide some headlines for sidebars
./inc/classes/main/criteria/search/class_SearchCriteria.php:126: * @todo Find a nice casting here. (int) allows until and including 32766.
./inc/classes/main/criteria/search/class_SearchCriteria.php:94: * @todo Find a nice casting here. (int) allows until and including 32766.
-./inc/classes/main/database/databases/class_LocalFileDatabase.php:360: * @todo Do some checks on the database directory and files here
+./inc/classes/main/database/databases/class_LocalFileDatabase.php:331: * @todo Do some checks on the database directory and files here
./inc/classes/main/decorator/template/class_XmlRewriterTemplateDecorator.php:426: * @todo Find something useful with this!
./inc/classes/main/discovery/payment/class_LocalPaymentDiscovery.php:82: * @todo 0% done
./inc/classes/main/filter/change/class_EmailChangeFilter.php:54: * @todo Implement email change of the user here. HINT: Use the User class!
./inc/classes/main/output/class_ConsoleOutput.php:56: // @TODO Need to rewrite this to $requestInstance->addHeader()
./inc/classes/main/parser/xml/class_XmlParser.php:76: // @TODO We need to find a fallback solution here
./inc/classes/main/points/class_UserPoints.php:100: * @todo Finish loading part of points
-./inc/classes/main/request/console/class_ConsoleRequest.php:115: // @TODO There are no cookies on console
-./inc/classes/main/request/console/class_ConsoleRequest.php:55: * @todo Needs to be implemented
+./inc/classes/main/request/console/class_ConsoleRequest.php:106: // @TODO Can't this be 'CONSOLE' ?
./inc/classes/main/request/web/class_HttpRequest.php:10: * @todo Move out the cookie part to a seperate class, e.g. Cookie
./inc/classes/main/response/http/class_HttpResponse.php:77: * @todo Encryption of cookie data not yet supported.
./inc/classes/main/response/http/class_HttpResponse.php:78: * @todo Why are these parameters conflicting?
./application/hub/main/database/wrapper/class_NodeInformationDatabaseWrapper.php:2:// @DEPRECATED
./application/hub/main/database/wrapper/class_NodeListDatabaseWrapper.php:2:// @DEPRECATED
./application/hub/main/database/wrapper/class_PeerStateLookupDatabaseWrapper.php:2:// @DEPRECATED
-./application/hub/main/database/wrapper/states/class_PeerStateLookupDatabaseWrapper.php:2:// @DEPRECATED
+./application/hub/main/database/wrapper/states/class_NodeStateLookupDatabaseWrapper.php:2:// @DEPRECATED
./application/hub/main/factories/states/class_StateFactory.php:2:// @DEPRECATED
./application/hub/main/filter/activation/class_HubActivationSelfAnnouncementFilter.php:2:// @DEPRECATED
./application/hub/main/filter/bootstrap/class_HubBootstrapAquireHubIdFilter.php:2:// @DEPRECATED
./application/hub/main/filter/shutdown/class_HubShutdownListenerPoolFilter.php:2:// @DEPRECATED
./application/hub/main/filter/shutdown/class_HubShutdownNodeFilter.php:2:// @DEPRECATED
./application/hub/main/filter/shutdown/class_HubShutdownTaskHandlerFilter.php:2:// @DEPRECATED
+./application/hub/main/filter/shutdown/cruncher/class_CruncherShutdownCruncherFilter.php:2:// @DEPRECATED
./application/hub/main/filter/task/class_CruncherTaskHandlerInitializerFilter.php:2:// @DEPRECATED
./application/hub/main/filter/task/class_HubTaskHandlerInitializerFilter.php:2:// @DEPRECATED
./application/hub/main/filter/task/class_TaskHandlerInitializerFilter.php:2:// @DEPRECATED
./application/hub/main/iterator/producer/class_TestUnitKeyProducerIterator.php:2:// @DEPRECATED
./application/hub/main/listener/tcp/decorators/class_PeerTcpListenerDecorator.php:2:// @DEPRECATED
./application/hub/main/listener/udp/decorators/class_PeerUdpListenerDecorator.php:2:// @DEPRECATED
+./application/hub/main/lookup/class_BaseLookupTable.php:2:// @DEPRECATED
+./application/hub/main/lookup/peer/class_NodeStateLookupTable.php:2:// @DEPRECATED
./application/hub/main/lookup/peer/class_PeerStateLookupTable.php:2:// @DEPRECATED
./application/hub/main/nodes/class_BaseHubNode.php:53: * @deprecated
+./application/hub/main/resolver/state/network/class_NetworkStateResolver.php:2:// @DEPRECATED
+./application/hub/main/states/peer/new/class_NewConnectionNodeState.php:2:// @DEPRECATED
./application/hub/main/states/peer/new/class_NewConnectionPeerState.php:2:// @DEPRECATED
./application/hub/main/streams/package/input/class_PackageInputStream.php:2:// @DEPRECATED
./application/hub/main/streams/package/output/class_PackageOutputStream.php:2:// @DEPRECATED
$languageInstance = LanguageSystem::getInstance();
// Initialize template instance here to avoid warnings in IDE
- $templateInstance = null;
+ $templateInstance = NULL;
// Get response instance
$responseInstance = ApplicationHelper::getInstance()->getResponseInstance();
} // END - foreach
// Init application instance
- $applicationInstance = null;
+ $applicationInstance = NULL;
// Is the class there?
if (class_exists('ApplicationHelper')) {