From cf39be5d5645b195e967ccf8bb16f2da5a5ff37a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Mon, 29 May 2017 21:22:54 +0200 Subject: [PATCH] Continued: - method renamed to getConnectionClassNameFromSocket() which now only accepts a StorableSocket class - resolveStateByPackage() now accepts StorableSocket instead of socket resource - also extend HubInterface - introduced BaseHubHandler to implement HubInterface (or what is missing + protected setter/getter) - introduced BaseHubDatabaseWrapper to implement HubInterface - more debug messages - other stuff improved - imported (Base|Peer)StateResolver - imported StorableSocket - imported (Lookupable)PeerState - imported PeerStateable - created new namespaces - moved classes around MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- .../hub/classes/class_BaseHubSystem.php | 27 +++ .../socket/class_SocketContainer.php | 10 +- .../frontend/class_BaseHubDatabaseWrapper.php | 229 ++++++++++++++++++ .../class_CruncherUnitDatabaseWrapper.php | 6 +- ...odeDistributedHashTableDatabaseWrapper.php | 4 +- .../class_NodeInformationDatabaseWrapper.php | 4 +- .../class_PeerStateLookupDatabaseWrapper.php | 26 +- .../socket/class_PackageSocketDiscovery.php | 1 + .../handler/chunks/class_ChunkHandler.php | 4 +- .../classes/handler/class_BaseHubHandler.php | 229 ++++++++++++++++++ .../handler/{answer-status => data}/.htaccess | 0 .../answer-status}/.htaccess | 0 .../answer-status/announcement}/.htaccess | 0 ...lass_NodeAnnouncementAnswerOkayHandler.php | 0 .../handler/{ => data}/answer-status/class_ | 0 .../class_BaseAnserStatusHandler.php | 0 .../answer-status/requests}/.htaccess | 0 ...class_RequestNodeListAnswerOkayHandler.php | 0 .../handler/{raw_data/network => data}/class_ | 37 +-- .../class_BaseDataHandler.php | 5 +- .../message-types}/.htaccess | 0 .../message-types/announcement}/.htaccess | 0 .../class_NodeMessageAnnouncementHandler.php | 0 .../message-types/answer}/.htaccess | 0 ...s_NodeMessageAnnouncementAnswerHandler.php | 0 ...s_NodeMessageDhtBootstrapAnswerHandler.php | 0 ...odeMessageRequestNodeListAnswerHandler.php | 0 .../handler/{ => data}/message-types/class_ | 0 .../class_BaseMessageHandler.php | 0 .../message-types/dht}/.htaccess | 0 .../class_NodeMessageDhtBootstrapHandler.php | 0 .../message-types/requests}/.htaccess | 0 ...lass_NodeMessageRequestNodeListHandler.php | 0 .../message-types/self-connect}/.htaccess | 0 .../class_NodeMessageSelfConnectHandler.php | 0 .../protocol/class_BaseProtocolHandler.php | 33 +-- .../hub/classes/handler/raw_data/class_ | 37 ++- .../class_BaseRawDataHandler.php | 6 +- .../handler/raw_data/network/.htaccess | 1 - .../{network => raw_data}/socket/.htaccess | 0 .../socket/class_SocketRawDataHandler.php | 0 .../{network => raw_data}/tcp/.htaccess | 0 .../handler/{network => raw_data}/tcp/class_ | 0 .../tcp/class_TcpRawDataHandler.php | 0 .../{network => raw_data}/udp/.htaccess | 0 .../udp/class_UdpRawDataHandler.php | 0 .../connection/class_BaseConnectionHelper.php | 10 +- .../listener/class_BaseListenerDecorator.php | 23 ++ .../state/peer/class_PeerStateResolver.php | 2 + application/hub/classes/states/peer/class_ | 1 + .../connected/class_ConnectedPeerState.php | 1 + .../class_ConnectionRefusedPeerState.php | 5 +- .../class_ConnectionTimedOutPeerState.php | 5 +- .../errors/class_NoRouteToHostPeerState.php | 5 +- ...lass_OperationAlreadyProgressPeerState.php | 5 +- .../peer/errors/class_ProblemPeerState.php | 5 +- .../class_TransportEndpointGonePeerState.php | 5 +- .../states/peer/init/class_InitPeerState.php | 4 +- application/hub/config.php | 2 +- .../hub/interfaces/class_HubInterface.php | 7 + .../class_HandleableAnswerStatus.php | 7 +- .../handler/chunks/class_HandleableChunks.php | 9 +- .../message-types/class_HandleableMessage.php | 7 +- .../handler/network/class_Networkable.php | 9 +- .../protocol/class_HandleableProtocol.php | 12 +- .../connections/class_ConnectionHelper.php | 7 +- .../node_states/class_LookupableNodeState.php | 9 +- .../peer_states/class_LookupablePeerState.php | 10 +- .../resolver/state/class_StateResolver.php | 5 +- .../states/peer/class_PeerStateable.php | 3 - 70 files changed, 655 insertions(+), 162 deletions(-) create mode 100644 application/hub/classes/database/frontend/class_BaseHubDatabaseWrapper.php create mode 100644 application/hub/classes/handler/class_BaseHubHandler.php rename application/hub/classes/handler/{answer-status => data}/.htaccess (100%) rename application/hub/classes/handler/{answer-status/announcement => data/answer-status}/.htaccess (100%) rename application/hub/classes/handler/{answer-status/requests => data/answer-status/announcement}/.htaccess (100%) rename application/hub/classes/handler/{ => data}/answer-status/announcement/class_NodeAnnouncementAnswerOkayHandler.php (100%) rename application/hub/classes/handler/{ => data}/answer-status/class_ (100%) rename application/hub/classes/handler/{ => data}/answer-status/class_BaseAnserStatusHandler.php (100%) rename application/hub/classes/handler/{message-types => data/answer-status/requests}/.htaccess (100%) rename application/hub/classes/handler/{ => data}/answer-status/requests/class_RequestNodeListAnswerOkayHandler.php (100%) rename application/hub/classes/handler/{raw_data/network => data}/class_ (54%) rename application/hub/classes/handler/{raw_data => data}/class_BaseDataHandler.php (97%) rename application/hub/classes/handler/{message-types/announcement => data/message-types}/.htaccess (100%) rename application/hub/classes/handler/{message-types/answer => data/message-types/announcement}/.htaccess (100%) rename application/hub/classes/handler/{ => data}/message-types/announcement/class_NodeMessageAnnouncementHandler.php (100%) rename application/hub/classes/handler/{message-types/dht => data/message-types/answer}/.htaccess (100%) rename application/hub/classes/handler/{ => data}/message-types/answer/class_NodeMessageAnnouncementAnswerHandler.php (100%) rename application/hub/classes/handler/{ => data}/message-types/answer/class_NodeMessageDhtBootstrapAnswerHandler.php (100%) rename application/hub/classes/handler/{ => data}/message-types/answer/class_NodeMessageRequestNodeListAnswerHandler.php (100%) rename application/hub/classes/handler/{ => data}/message-types/class_ (100%) rename application/hub/classes/handler/{ => data}/message-types/class_BaseMessageHandler.php (100%) rename application/hub/classes/handler/{message-types/requests => data/message-types/dht}/.htaccess (100%) rename application/hub/classes/handler/{ => data}/message-types/dht/class_NodeMessageDhtBootstrapHandler.php (100%) rename application/hub/classes/handler/{message-types/self-connect => data/message-types/requests}/.htaccess (100%) rename application/hub/classes/handler/{ => data}/message-types/requests/class_NodeMessageRequestNodeListHandler.php (100%) rename application/hub/classes/handler/{network => data/message-types/self-connect}/.htaccess (100%) rename application/hub/classes/handler/{ => data}/message-types/self-connect/class_NodeMessageSelfConnectHandler.php (100%) rename application/hub/classes/handler/raw_data/{network => }/class_BaseRawDataHandler.php (96%) delete mode 100644 application/hub/classes/handler/raw_data/network/.htaccess rename application/hub/classes/handler/{network => raw_data}/socket/.htaccess (100%) rename application/hub/classes/handler/{network => raw_data}/socket/class_SocketRawDataHandler.php (100%) rename application/hub/classes/handler/{network => raw_data}/tcp/.htaccess (100%) rename application/hub/classes/handler/{network => raw_data}/tcp/class_ (100%) rename application/hub/classes/handler/{network => raw_data}/tcp/class_TcpRawDataHandler.php (100%) rename application/hub/classes/handler/{network => raw_data}/udp/.htaccess (100%) rename application/hub/classes/handler/{network => raw_data}/udp/class_UdpRawDataHandler.php (100%) diff --git a/application/hub/classes/class_BaseHubSystem.php b/application/hub/classes/class_BaseHubSystem.php index dbad5a778..dff2ac434 100644 --- a/application/hub/classes/class_BaseHubSystem.php +++ b/application/hub/classes/class_BaseHubSystem.php @@ -9,6 +9,7 @@ use Hub\Handler\Network\RawData\BaseRawDataHandler; use Hub\Information\ShareableInfo; use Hub\Listener\BaseListener; use Hub\Listener\Listenable; +use Hub\Locator\Node\LocateableNode; use Hub\Network\Deliver\Deliverable; use Hub\Network\Package\Assembler\Assembler; use Hub\Network\Package\Fragment\Fragmentable; @@ -114,6 +115,11 @@ class BaseHubSystem extends BaseFrameworkSystem implements HubInterface { */ private $socketInstance = NULL; + /** + * An instance of a LocateableNode class + */ + private $universalNodeLocatorInstance = NULL; + /** * Name of used protocol */ @@ -416,4 +422,25 @@ class BaseHubSystem extends BaseFrameworkSystem implements HubInterface { return $this->socketInstance; } + /** + * Setter for UNL instance + * + * @para $unlInstance An instance of a LocateableNode class + * @return void + */ + protected final function setUniversalNodeLocatorInstance (LocateableNode $unlInstance) { + // Set new UNL data array + $this->universalNodeLocatorInstance = $unlInstance; + } + + /** + * Getter for UNL instance + * + * @return $unlData An instance of a LocateableNode class + */ + public final function getUniversalNodeLocatorInstance () { + // Return UNL data array + return $this->universalNodeLocatorInstance; + } + } diff --git a/application/hub/classes/container/socket/class_SocketContainer.php b/application/hub/classes/container/socket/class_SocketContainer.php index c4d88636c..52ef686dc 100644 --- a/application/hub/classes/container/socket/class_SocketContainer.php +++ b/application/hub/classes/container/socket/class_SocketContainer.php @@ -465,6 +465,9 @@ class SocketContainer extends BaseContainer implements StorableSocket, Visitable * @throws InvalidSocketException If stored socket is invalid */ public function connectToSocketRecipient () { + // Trace message + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: CALLED!', strtoupper($this->getSocketProtocol()))); + // Should be valid socket if (!$this->isValidSocket()) { // Throw exception @@ -480,6 +483,9 @@ class SocketContainer extends BaseContainer implements StorableSocket, Visitable // Try to connect to it $result = socket_connect($this->getSocketResource(), $unlInstance->getUnlAddress(), $unlInstance->getUnlPort()); + // Trace message + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: result=%d - EXIT!', strtoupper($this->getSocketProtocol()), intval($result))); + // Return result return $result; } @@ -489,7 +495,7 @@ class SocketContainer extends BaseContainer implements StorableSocket, Visitable * * @return void * @throws SocketShutdownException If the current socket could not be shut down - * @throws BaseMethodCallException If this method is possibly called twice + * @throws BadMethodCallException If this method is possibly called twice * @todo We may want to implement a filter for ease notification of other objects like our pool * @todo rewrite this! */ @@ -497,7 +503,7 @@ class SocketContainer extends BaseContainer implements StorableSocket, Visitable // Should be valid socket if (!$this->isValidSocket()) { // Throw exception - throw new BaseMethodCallException(sprintf('[%s:%d]: Shutdown on invalid socket. Maybe called already?', __METHOD__, __LINE__), self::EXCEPTION_INVALID_SOCKET); + throw new BadMethodCallException(sprintf('[%s:%d]: Shutdown on invalid socket. Maybe called already?', __METHOD__, __LINE__), self::EXCEPTION_INVALID_SOCKET); } // END - if // Debug message diff --git a/application/hub/classes/database/frontend/class_BaseHubDatabaseWrapper.php b/application/hub/classes/database/frontend/class_BaseHubDatabaseWrapper.php new file mode 100644 index 000000000..de83717bf --- /dev/null +++ b/application/hub/classes/database/frontend/class_BaseHubDatabaseWrapper.php @@ -0,0 +1,229 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2011 - 2014 Cruncher Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseHubDatabaseWrapper extends BaseDatabaseWrapper implements HubInterface { + + /** + * Listener pool instance + */ + private $listenerPoolInstance = NULL; + + /** + * Info instance + */ + private $infoInstance = NULL; + + /** + * A StorableSocket instance + */ + private $socketInstance = NULL; + + /** + * An instance of a LocateableNode class + */ + private $universalNodeLocatorInstance = NULL; + + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } + + /** + * Checks whether start/end marker are set + * + * @param $data Data to be checked + * @return $isset Whether start/end marker are set + */ + public final function ifStartEndMarkersSet ($data) { + // Determine it + $isset = ((substr($data, 0, strlen(BaseRawDataHandler::STREAM_START_MARKER)) == BaseRawDataHandler::STREAM_START_MARKER) && (substr($data, -1 * strlen(BaseRawDataHandler::STREAM_END_MARKER), strlen(BaseRawDataHandler::STREAM_END_MARKER)) == BaseRawDataHandler::STREAM_END_MARKER)); + + // ... and return it + return $isset; + } + + /** + * Setter for listener pool instance + * + * @param $listenerPoolInstance The new listener pool instance + * @return void + */ + protected final function setListenerPoolInstance (Poolable $listenerPoolInstance) { + $this->listenerPoolInstance = $listenerPoolInstance; + } + + /** + * Getter for listener pool instance + * + * @return $listenerPoolInstance Our current listener pool instance + */ + public final function getListenerPoolInstance () { + return $this->listenerPoolInstance; + } + + /** + * Setter for info instance + * + * @param $infoInstance A ShareableInfo instance + * @return void + */ + protected final function setInfoInstance (ShareableInfo $infoInstance) { + $this->infoInstance = $infoInstance; + } + + /** + * Getter for info instance + * + * @return $infoInstance An instance of a ShareableInfo class + */ + public final function getInfoInstance () { + return $this->infoInstance; + } + + /** + * Setter for socket instance + * + * @param $socketInstance A StorableSocket instance + * @return void + */ + public final function setSocketInstance (StorableSocket $socketInstance) { + $this->socketInstance = $socketInstance; + } + + /** + * Getter for socket instance + * + * @return $socketInstance An instance of a StorableSocket class + */ + public final function getSocketInstance () { + return $this->socketInstance; + } + + /** + * Setter for UNL instance + * + * @para $unlInstance An instance of a LocateableNode class + * @return void + */ + protected final function setUniversalNodeLocatorInstance (LocateableNode $unlInstance) { + // Set new UNL data array + $this->universalNodeLocatorInstance = $unlInstance; + } + + /** + * Getter for UNL instance + * + * @return $unlData An instance of a LocateableNode class + */ + public final function getUniversalNodeLocatorInstance () { + // Return UNL data array + return $this->universalNodeLocatorInstance; + } + + /** + * Setter for node id + * + * @param $nodeId The new node id + * @return void + */ + protected final function setNodeId ($nodeId) { + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } + + /** + * Getter for node id + * + * @return $nodeId Current node id + */ + public final function getNodeId () { + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } + + /** + * Setter for private key + * + * @param $privateKey The new private key + * @return void + */ + protected final function setPrivateKey ($privateKey) { + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } + + /** + * Getter for private key + * + * @return $privateKey Current private key + */ + public final function getPrivateKey () { + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } + + /** + * Setter for private key hash + * + * @param $privateKeyHash The new private key hash + * @return void + */ + protected final function setPrivateKeyHash ($privateKeyHash) { + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } + + /** + * Getter for private key hash + * + * @return $privateKeyHash Current private key hash + */ + public final function getPrivateKeyHash () { + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } + + /** + * Getter for session id + * + * @return $sessionId Current session id + */ + public final function getSessionId () { + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } + +} diff --git a/application/hub/classes/database/frontend/cruncher/class_CruncherUnitDatabaseWrapper.php b/application/hub/classes/database/frontend/cruncher/class_CruncherUnitDatabaseWrapper.php index ce93c37f9..f48f6e4a2 100644 --- a/application/hub/classes/database/frontend/cruncher/class_CruncherUnitDatabaseWrapper.php +++ b/application/hub/classes/database/frontend/cruncher/class_CruncherUnitDatabaseWrapper.php @@ -2,8 +2,10 @@ // Own namespace namespace Hub\Database\Frontend\Cruncher\Unit; +// Import application-specific stuff +use Hub\Database\Frontend\BaseHubDatabaseWrapper; + // Import framework stuff -use CoreFramework\Database\Frontend\BaseDatabaseWrapper; use CoreFramework\Factory\ObjectFactory; use CoreFramework\Registry\Registerable; @@ -29,7 +31,7 @@ use CoreFramework\Registry\Registerable; * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -class CruncherUnitDatabaseWrapper extends BaseDatabaseWrapper implements UnitDatabaseWrapper, Registerable { +class CruncherUnitDatabaseWrapper extends BaseHubDatabaseWrapper implements UnitDatabaseWrapper, Registerable { // Constants for database table names const DB_TABLE_CRUNCHER_UNITS = 'cruncher_units'; diff --git a/application/hub/classes/database/frontend/node/class_NodeDistributedHashTableDatabaseWrapper.php b/application/hub/classes/database/frontend/node/class_NodeDistributedHashTableDatabaseWrapper.php index b8c64aa69..a4a8ce8d7 100644 --- a/application/hub/classes/database/frontend/node/class_NodeDistributedHashTableDatabaseWrapper.php +++ b/application/hub/classes/database/frontend/node/class_NodeDistributedHashTableDatabaseWrapper.php @@ -3,6 +3,7 @@ namespace Hub\Database\Frontend\Node\Dht; // Import application-specific stuff +use Hub\Database\Frontend\BaseHubDatabaseWrapper; use Hub\Database\Frontend\Node\Information\NodeInformationDatabaseWrapper; use Hub\Factory\Node\NodeObjectFactory; use Hub\Network\Package\NetworkPackage; @@ -12,7 +13,6 @@ use Hub\Node\BaseHubNode; use CoreFramework\Bootstrap\FrameworkBootstrap; use CoreFramework\Criteria\Local\LocalSearchCriteria; use CoreFramework\Criteria\Storing\StoreableCriteria; -use CoreFramework\Database\Frontend\BaseDatabaseWrapper; use CoreFramework\Factory\ObjectFactory; use CoreFramework\Handler\DataSet\HandleableDataSet; use CoreFramework\Registry\Registerable; @@ -39,7 +39,7 @@ use CoreFramework\Registry\Registerable; * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -class NodeDistributedHashTableDatabaseWrapper extends BaseDatabaseWrapper implements NodeDhtWrapper, Registerable { +class NodeDistributedHashTableDatabaseWrapper extends BaseHubDatabaseWrapper implements NodeDhtWrapper, Registerable { /** * "Cached" results for dabase for looking for unpublished entries */ diff --git a/application/hub/classes/database/frontend/node/class_NodeInformationDatabaseWrapper.php b/application/hub/classes/database/frontend/node/class_NodeInformationDatabaseWrapper.php index 92fb1b5d3..a7e40a57c 100644 --- a/application/hub/classes/database/frontend/node/class_NodeInformationDatabaseWrapper.php +++ b/application/hub/classes/database/frontend/node/class_NodeInformationDatabaseWrapper.php @@ -3,6 +3,7 @@ namespace Hub\Database\Frontend\Node\Information; // Import application-specific stuff +use Hub\Database\Frontend\BaseHubDatabaseWrapper; use Hub\Database\Frontend\Node\NodeInformationWrapper; use Hub\Node\BaseHubNode; use Hub\Helper\Node\NodeHelper; @@ -10,7 +11,6 @@ use Hub\Helper\Node\NodeHelper; // Import framework stuff use CoreFramework\Bootstrap\FrameworkBootstrap; use CoreFramework\Criteria\Local\LocalSearchCriteria; -use CoreFramework\Database\Frontend\BaseDatabaseWrapper; use CoreFramework\Factory\ObjectFactory; use CoreFramework\Registry\Registerable; use CoreFramework\Request\Requestable; @@ -37,7 +37,7 @@ use CoreFramework\Request\Requestable; * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -class NodeInformationDatabaseWrapper extends BaseDatabaseWrapper implements NodeInformationWrapper, Registerable { +class NodeInformationDatabaseWrapper extends BaseHubDatabaseWrapper implements NodeInformationWrapper, Registerable { // Constants for database table names const DB_TABLE_NODE_INFORMATION = 'node_data'; diff --git a/application/hub/classes/database/frontend/states/class_PeerStateLookupDatabaseWrapper.php b/application/hub/classes/database/frontend/states/class_PeerStateLookupDatabaseWrapper.php index 594416bc4..1f305f780 100644 --- a/application/hub/classes/database/frontend/states/class_PeerStateLookupDatabaseWrapper.php +++ b/application/hub/classes/database/frontend/states/class_PeerStateLookupDatabaseWrapper.php @@ -3,14 +3,18 @@ namespace Hub\Database\Frontend\Node\PeerState; // Import application-specific sutff +use Hub\Container\Socket\StorableSocket; +use Hub\Database\Frontend\BaseHubDatabaseWrapper; use Hub\Helper\Connection\ConnectionHelper; use Hub\Network\Package\NetworkPackage; +use Hub\LookupTable\Lookupable; +use Hub\State\Peer\Lookup\LookupablePeerState; +use Hub\State\Peer\PeerStateable; use Hub\Tools\HubTools; // Import framework stuff use CoreFramework\Criteria\Local\LocalSearchCriteria; use CoreFramework\Criteria\Storing\StoreableCriteria; -use CoreFramework\Database\Frontend\BaseDatabaseWrapper; use CoreFramework\Factory\ObjectFactory; /** @@ -35,7 +39,7 @@ use CoreFramework\Factory\ObjectFactory; * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -class PeerStateLookupDatabaseWrapper extends BaseDatabaseWrapper implements LookupablePeerState { +class PeerStateLookupDatabaseWrapper extends BaseHubDatabaseWrapper implements LookupablePeerState { // Exception constants const EXCEPTION_PEER_ALREADY_REGISTERED = 0x300; @@ -137,11 +141,11 @@ class PeerStateLookupDatabaseWrapper extends BaseDatabaseWrapper implements Look * Registers a new peer with given package data. We use the session id from it. * * @param $packageData Raw package data - * @param $socketResource A valid socket resource + * @param $socketResource An instance of a StorableSocket class * @return void * @throws PeerAlreadyRegisteredException If a peer is already registered */ - public function registerPeerByPackageData (array $packageData, $socketResource) { + public function registerPeerByPackageData (array $packageData, StorableSocket $socketInstance) { // Make sure only new peers can be registered with package data if (!$this->isSenderNewPeer($packageData)) { // Throw an exception because this should normally not happen @@ -162,9 +166,9 @@ class PeerStateLookupDatabaseWrapper extends BaseDatabaseWrapper implements Look $peerPort = '0'; // Get peer name - if (!@socket_getpeername($socketResource, $peerAddress, $peerPort)) { + if (!@socket_getpeername($socketInstance, $peerAddress, $peerPort)) { // Get last error - $lastError = socket_last_error($socketResource); + $lastError = socket_last_error($socketInstance); // ... and cleartext message from it and put both into criteria $dataSetInstance->addCriteria(self::DB_COLUMN_SOCKET_ERROR_CODE, $lastError); @@ -228,19 +232,19 @@ class PeerStateLookupDatabaseWrapper extends BaseDatabaseWrapper implements Look /** * Purges old entries of given socket resource. We use the IP address from that resource. * - * @param $socketResource A valid socket resource + * @param $socketInstance An instance of a StorableSocket class * @return void * @throws InvalidSocketException If the socket resource was invalid * @todo Unfinished area, please rewrite! */ - public function purgeOldEntriesBySocketResource ($socketResource) { + public function purgeOldEntriesBysocketInstance (StorableSocket $socketInstance) { // Get peer name - if (!@socket_getpeername($socketResource, $peerAddress, $peerPort)) { + if (!@socket_getpeername($socketInstance, $peerAddress, $peerPort)) { // Get last error - $lastError = socket_last_error($socketResource); + $lastError = socket_last_error($socketInstance); // Doesn't work! - throw new InvalidSocketException(array($this, $socketResource, $lastError, socket_strerror($lastError)), self::EXCEPTION_INVALID_SOCKET); + throw new InvalidSocketException(array($this, $socketInstance, $lastError, socket_strerror($lastError)), self::EXCEPTION_INVALID_SOCKET); } // END - if // Debug message diff --git a/application/hub/classes/discovery/recipient/socket/class_PackageSocketDiscovery.php b/application/hub/classes/discovery/recipient/socket/class_PackageSocketDiscovery.php index dc1205db1..6f80c04f5 100644 --- a/application/hub/classes/discovery/recipient/socket/class_PackageSocketDiscovery.php +++ b/application/hub/classes/discovery/recipient/socket/class_PackageSocketDiscovery.php @@ -13,6 +13,7 @@ use Hub\Generic\BaseHubSystem; use Hub\Handler\Protocol\HandleableProtocol; use Hub\Listener\Listenable; use Hub\Network\Package\NetworkPackage; +use Hub\Resolver\State\Peer\PeerStateResolver; // Import framework stuff use CoreFramework\Generic\NullPointerException; diff --git a/application/hub/classes/handler/chunks/class_ChunkHandler.php b/application/hub/classes/handler/chunks/class_ChunkHandler.php index f9469078a..e83314387 100644 --- a/application/hub/classes/handler/chunks/class_ChunkHandler.php +++ b/application/hub/classes/handler/chunks/class_ChunkHandler.php @@ -4,11 +4,11 @@ namespace Hub\Handler\Network\RawData\Chunks; // Import application-specific stuff use Hub\Factory\Fragmenter\FragmenterFactory; +use Hub\Handler\BaseHubHandler; use Hub\Network\Package\Fragment\PackageFragmenter; // Import framework stuff use CoreFramework\Factory\ObjectFactory; -use CoreFramework\Handler\BaseHandler; use CoreFramework\Registry\Registerable; /** @@ -33,7 +33,7 @@ use CoreFramework\Registry\Registerable; * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -class ChunkHandler extends BaseHandler implements HandleableChunks, Registerable { +class ChunkHandler extends BaseHubHandler implements HandleableChunks, Registerable { /** * Stacker for chunks with final EOP */ diff --git a/application/hub/classes/handler/class_BaseHubHandler.php b/application/hub/classes/handler/class_BaseHubHandler.php new file mode 100644 index 000000000..a0d486109 --- /dev/null +++ b/application/hub/classes/handler/class_BaseHubHandler.php @@ -0,0 +1,229 @@ + + * @version 0.0.0 + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team + * @license GNU GPL 3.0 or any newer version + * @link http://www.shipsimu.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +class BaseHubHandler extends BaseHandler implements Handleable, HubInterface { + /** + * Listener pool instance + */ + private $listenerPoolInstance = NULL; + + /** + * Info instance + */ + private $infoInstance = NULL; + + /** + * A StorableSocket instance + */ + private $socketInstance = NULL; + + /** + * An instance of a LocateableNode class + */ + private $universalNodeLocatorInstance = NULL; + + /** + * Protected constructor + * + * @param $className Name of the class + * @return void + */ + protected function __construct ($className) { + // Call parent constructor + parent::__construct($className); + } + + /** + * Checks whether start/end marker are set + * + * @param $data Data to be checked + * @return $isset Whether start/end marker are set + */ + public final function ifStartEndMarkersSet ($data) { + // Determine it + $isset = ((substr($data, 0, strlen(BaseRawDataHandler::STREAM_START_MARKER)) == BaseRawDataHandler::STREAM_START_MARKER) && (substr($data, -1 * strlen(BaseRawDataHandler::STREAM_END_MARKER), strlen(BaseRawDataHandler::STREAM_END_MARKER)) == BaseRawDataHandler::STREAM_END_MARKER)); + + // ... and return it + return $isset; + } + + /** + * Setter for listener pool instance + * + * @param $listenerPoolInstance The new listener pool instance + * @return void + */ + protected final function setListenerPoolInstance (Poolable $listenerPoolInstance) { + $this->listenerPoolInstance = $listenerPoolInstance; + } + + /** + * Getter for listener pool instance + * + * @return $listenerPoolInstance Our current listener pool instance + */ + public final function getListenerPoolInstance () { + return $this->listenerPoolInstance; + } + + /** + * Setter for info instance + * + * @param $infoInstance A ShareableInfo instance + * @return void + */ + protected final function setInfoInstance (ShareableInfo $infoInstance) { + $this->infoInstance = $infoInstance; + } + + /** + * Getter for info instance + * + * @return $infoInstance An instance of a ShareableInfo class + */ + public final function getInfoInstance () { + return $this->infoInstance; + } + + /** + * Setter for socket instance + * + * @param $socketInstance A StorableSocket instance + * @return void + */ + public final function setSocketInstance (StorableSocket $socketInstance) { + $this->socketInstance = $socketInstance; + } + + /** + * Getter for socket instance + * + * @return $socketInstance An instance of a StorableSocket class + */ + public final function getSocketInstance () { + return $this->socketInstance; + } + + /** + * Setter for UNL instance + * + * @para $unlInstance An instance of a LocateableNode class + * @return void + */ + protected final function setUniversalNodeLocatorInstance (LocateableNode $unlInstance) { + // Set new UNL data array + $this->universalNodeLocatorInstance = $unlInstance; + } + + /** + * Getter for UNL instance + * + * @return $unlData An instance of a LocateableNode class + */ + public final function getUniversalNodeLocatorInstance () { + // Return UNL data array + return $this->universalNodeLocatorInstance; + } + + /** + * Setter for node id + * + * @param $nodeId The new node id + * @return void + */ + protected final function setNodeId ($nodeId) { + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } + + /** + * Getter for node id + * + * @return $nodeId Current node id + */ + public final function getNodeId () { + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } + + /** + * Setter for private key + * + * @param $privateKey The new private key + * @return void + */ + protected final function setPrivateKey ($privateKey) { + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } + + /** + * Getter for private key + * + * @return $privateKey Current private key + */ + public final function getPrivateKey () { + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } + + /** + * Setter for private key hash + * + * @param $privateKeyHash The new private key hash + * @return void + */ + protected final function setPrivateKeyHash ($privateKeyHash) { + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } + + /** + * Getter for private key hash + * + * @return $privateKeyHash Current private key hash + */ + public final function getPrivateKeyHash () { + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } + + /** + * Getter for session id + * + * @return $sessionId Current session id + */ + public final function getSessionId () { + throw new UnsupportedOperationException(array($this, __FUNCTION__), self::EXCEPTION_UNSPPORTED_OPERATION); + } + +} diff --git a/application/hub/classes/handler/answer-status/.htaccess b/application/hub/classes/handler/data/.htaccess similarity index 100% rename from application/hub/classes/handler/answer-status/.htaccess rename to application/hub/classes/handler/data/.htaccess diff --git a/application/hub/classes/handler/answer-status/announcement/.htaccess b/application/hub/classes/handler/data/answer-status/.htaccess similarity index 100% rename from application/hub/classes/handler/answer-status/announcement/.htaccess rename to application/hub/classes/handler/data/answer-status/.htaccess diff --git a/application/hub/classes/handler/answer-status/requests/.htaccess b/application/hub/classes/handler/data/answer-status/announcement/.htaccess similarity index 100% rename from application/hub/classes/handler/answer-status/requests/.htaccess rename to application/hub/classes/handler/data/answer-status/announcement/.htaccess diff --git a/application/hub/classes/handler/answer-status/announcement/class_NodeAnnouncementAnswerOkayHandler.php b/application/hub/classes/handler/data/answer-status/announcement/class_NodeAnnouncementAnswerOkayHandler.php similarity index 100% rename from application/hub/classes/handler/answer-status/announcement/class_NodeAnnouncementAnswerOkayHandler.php rename to application/hub/classes/handler/data/answer-status/announcement/class_NodeAnnouncementAnswerOkayHandler.php diff --git a/application/hub/classes/handler/answer-status/class_ b/application/hub/classes/handler/data/answer-status/class_ similarity index 100% rename from application/hub/classes/handler/answer-status/class_ rename to application/hub/classes/handler/data/answer-status/class_ diff --git a/application/hub/classes/handler/answer-status/class_BaseAnserStatusHandler.php b/application/hub/classes/handler/data/answer-status/class_BaseAnserStatusHandler.php similarity index 100% rename from application/hub/classes/handler/answer-status/class_BaseAnserStatusHandler.php rename to application/hub/classes/handler/data/answer-status/class_BaseAnserStatusHandler.php diff --git a/application/hub/classes/handler/message-types/.htaccess b/application/hub/classes/handler/data/answer-status/requests/.htaccess similarity index 100% rename from application/hub/classes/handler/message-types/.htaccess rename to application/hub/classes/handler/data/answer-status/requests/.htaccess diff --git a/application/hub/classes/handler/answer-status/requests/class_RequestNodeListAnswerOkayHandler.php b/application/hub/classes/handler/data/answer-status/requests/class_RequestNodeListAnswerOkayHandler.php similarity index 100% rename from application/hub/classes/handler/answer-status/requests/class_RequestNodeListAnswerOkayHandler.php rename to application/hub/classes/handler/data/answer-status/requests/class_RequestNodeListAnswerOkayHandler.php diff --git a/application/hub/classes/handler/raw_data/network/class_ b/application/hub/classes/handler/data/class_ similarity index 54% rename from application/hub/classes/handler/raw_data/network/class_ rename to application/hub/classes/handler/data/class_ index 0b5036feb..9a2846c67 100644 --- a/application/hub/classes/handler/raw_data/network/class_ +++ b/application/hub/classes/handler/data/class_ @@ -1,19 +1,18 @@ + * @author Roland Haeder * @version 0.0.0 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 Hub Developer Team * @license GNU GPL 3.0 or any newer version - * @link http://www.shipsimu.org + * @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 @@ -28,7 +27,7 @@ use Hub\Network\Networkable; * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -class ???RawDataHandler extends BaseRawDataHandler implements Networkable { +class ???NetworkPackageHandler extends BaseNetworkPackageHandler implements Networkable { /** * Protected constructor * @@ -39,30 +38,40 @@ class ???RawDataHandler extends BaseRawDataHandler implements Networkable { parent::__construct(__CLASS__); // Set handler name - $this->setHandlerName('|||'); + $this->setHandlerName('!!!'); } /** * Creates an instance of this class * - * @return $handlerInstance An instance of a Networkable class + * @return $handlerInstance An instance of a Networkable class */ - public static final function create???RawDataHandler () { + public final static function create???NetworkPackageHandler () { // Get new instance - $handlerInstance = new ???RawDataHandler(); + $handlerInstance = new ???NetworkPackageHandler(); // Return the prepared instance return $handlerInstance; } /** - * Processes raw data from given resource. This is mostly useful for TCP - * package handling and is implemented in the ???Listener class + * Processes a package from given resource. This is mostly useful for TCP + * package handling and is implemented in the TcpListener class * - * @param $resource A valid socket resource array + * @param $resource A valid resource identifier * @return void + * @throws InvalidResourceException If the given resource is invalid + * @todo 0% */ - public function processRawDataFromResource (array $socketArray) { + public function processResourcePackage ($resource) { + // Check the resource + if (!is_resource($resource)) { + // Throw an exception + throw new InvalidResourceException($this, self::EXCEPTION_INVALID_RESOURCE); + } // END - if + + // Implement processing here + $this->partialStub('Please implement this method.'); } } diff --git a/application/hub/classes/handler/raw_data/class_BaseDataHandler.php b/application/hub/classes/handler/data/class_BaseDataHandler.php similarity index 97% rename from application/hub/classes/handler/raw_data/class_BaseDataHandler.php rename to application/hub/classes/handler/data/class_BaseDataHandler.php index 6b06d8972..744a14c9c 100644 --- a/application/hub/classes/handler/raw_data/class_BaseDataHandler.php +++ b/application/hub/classes/handler/data/class_BaseDataHandler.php @@ -4,12 +4,13 @@ namespace Hub\Handler\Data; // Import application-specific stuff use Hub\Factory\Node\NodeObjectFactory; +use Hub\Generic\HubInterface; +use Hub\Handler\BaseHubHandler; use Hub\Network\Deliver\Deliverable; // Import framework stuff use CoreFramework\Factory\ObjectFactory; use CoreFramework\Generic\FrameworkException; -use CoreFramework\Handler\BaseHandler; /** * A general data Handler @@ -33,7 +34,7 @@ use CoreFramework\Handler\BaseHandler; * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -abstract class BaseDataHandler extends BaseHandler { +abstract class BaseDataHandler extends BaseHubHandler implements HubInterface { /** * Last exception instance from database layer or NULL (default) */ diff --git a/application/hub/classes/handler/message-types/announcement/.htaccess b/application/hub/classes/handler/data/message-types/.htaccess similarity index 100% rename from application/hub/classes/handler/message-types/announcement/.htaccess rename to application/hub/classes/handler/data/message-types/.htaccess diff --git a/application/hub/classes/handler/message-types/answer/.htaccess b/application/hub/classes/handler/data/message-types/announcement/.htaccess similarity index 100% rename from application/hub/classes/handler/message-types/answer/.htaccess rename to application/hub/classes/handler/data/message-types/announcement/.htaccess diff --git a/application/hub/classes/handler/message-types/announcement/class_NodeMessageAnnouncementHandler.php b/application/hub/classes/handler/data/message-types/announcement/class_NodeMessageAnnouncementHandler.php similarity index 100% rename from application/hub/classes/handler/message-types/announcement/class_NodeMessageAnnouncementHandler.php rename to application/hub/classes/handler/data/message-types/announcement/class_NodeMessageAnnouncementHandler.php diff --git a/application/hub/classes/handler/message-types/dht/.htaccess b/application/hub/classes/handler/data/message-types/answer/.htaccess similarity index 100% rename from application/hub/classes/handler/message-types/dht/.htaccess rename to application/hub/classes/handler/data/message-types/answer/.htaccess diff --git a/application/hub/classes/handler/message-types/answer/class_NodeMessageAnnouncementAnswerHandler.php b/application/hub/classes/handler/data/message-types/answer/class_NodeMessageAnnouncementAnswerHandler.php similarity index 100% rename from application/hub/classes/handler/message-types/answer/class_NodeMessageAnnouncementAnswerHandler.php rename to application/hub/classes/handler/data/message-types/answer/class_NodeMessageAnnouncementAnswerHandler.php diff --git a/application/hub/classes/handler/message-types/answer/class_NodeMessageDhtBootstrapAnswerHandler.php b/application/hub/classes/handler/data/message-types/answer/class_NodeMessageDhtBootstrapAnswerHandler.php similarity index 100% rename from application/hub/classes/handler/message-types/answer/class_NodeMessageDhtBootstrapAnswerHandler.php rename to application/hub/classes/handler/data/message-types/answer/class_NodeMessageDhtBootstrapAnswerHandler.php diff --git a/application/hub/classes/handler/message-types/answer/class_NodeMessageRequestNodeListAnswerHandler.php b/application/hub/classes/handler/data/message-types/answer/class_NodeMessageRequestNodeListAnswerHandler.php similarity index 100% rename from application/hub/classes/handler/message-types/answer/class_NodeMessageRequestNodeListAnswerHandler.php rename to application/hub/classes/handler/data/message-types/answer/class_NodeMessageRequestNodeListAnswerHandler.php diff --git a/application/hub/classes/handler/message-types/class_ b/application/hub/classes/handler/data/message-types/class_ similarity index 100% rename from application/hub/classes/handler/message-types/class_ rename to application/hub/classes/handler/data/message-types/class_ diff --git a/application/hub/classes/handler/message-types/class_BaseMessageHandler.php b/application/hub/classes/handler/data/message-types/class_BaseMessageHandler.php similarity index 100% rename from application/hub/classes/handler/message-types/class_BaseMessageHandler.php rename to application/hub/classes/handler/data/message-types/class_BaseMessageHandler.php diff --git a/application/hub/classes/handler/message-types/requests/.htaccess b/application/hub/classes/handler/data/message-types/dht/.htaccess similarity index 100% rename from application/hub/classes/handler/message-types/requests/.htaccess rename to application/hub/classes/handler/data/message-types/dht/.htaccess diff --git a/application/hub/classes/handler/message-types/dht/class_NodeMessageDhtBootstrapHandler.php b/application/hub/classes/handler/data/message-types/dht/class_NodeMessageDhtBootstrapHandler.php similarity index 100% rename from application/hub/classes/handler/message-types/dht/class_NodeMessageDhtBootstrapHandler.php rename to application/hub/classes/handler/data/message-types/dht/class_NodeMessageDhtBootstrapHandler.php diff --git a/application/hub/classes/handler/message-types/self-connect/.htaccess b/application/hub/classes/handler/data/message-types/requests/.htaccess similarity index 100% rename from application/hub/classes/handler/message-types/self-connect/.htaccess rename to application/hub/classes/handler/data/message-types/requests/.htaccess diff --git a/application/hub/classes/handler/message-types/requests/class_NodeMessageRequestNodeListHandler.php b/application/hub/classes/handler/data/message-types/requests/class_NodeMessageRequestNodeListHandler.php similarity index 100% rename from application/hub/classes/handler/message-types/requests/class_NodeMessageRequestNodeListHandler.php rename to application/hub/classes/handler/data/message-types/requests/class_NodeMessageRequestNodeListHandler.php diff --git a/application/hub/classes/handler/network/.htaccess b/application/hub/classes/handler/data/message-types/self-connect/.htaccess similarity index 100% rename from application/hub/classes/handler/network/.htaccess rename to application/hub/classes/handler/data/message-types/self-connect/.htaccess diff --git a/application/hub/classes/handler/message-types/self-connect/class_NodeMessageSelfConnectHandler.php b/application/hub/classes/handler/data/message-types/self-connect/class_NodeMessageSelfConnectHandler.php similarity index 100% rename from application/hub/classes/handler/message-types/self-connect/class_NodeMessageSelfConnectHandler.php rename to application/hub/classes/handler/data/message-types/self-connect/class_NodeMessageSelfConnectHandler.php diff --git a/application/hub/classes/handler/protocol/class_BaseProtocolHandler.php b/application/hub/classes/handler/protocol/class_BaseProtocolHandler.php index 8353fa0c9..a66f951c4 100644 --- a/application/hub/classes/handler/protocol/class_BaseProtocolHandler.php +++ b/application/hub/classes/handler/protocol/class_BaseProtocolHandler.php @@ -3,13 +3,10 @@ namespace Hub\Handler\Protocol; // Import application-specific sutff +use Hub\Handler\BaseHubHandler; use Hub\Handler\Protocol\HandleableProtocol; -use Hub\Locator\Node\LocateableNode; use Hub\Tools\HubTools; -// Import framework stuff -use CoreFramework\Handler\BaseHandler; - /** * A general handler for protocols such as TCP, UDP and others. * @@ -32,12 +29,7 @@ use CoreFramework\Handler\BaseHandler; * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -abstract class BaseProtocolHandler extends BaseHandler implements HandleableProtocol { - /** - * Whole UNL instance - */ - private $universalNodeLocatorInstance = NULL; - +abstract class BaseProtocolHandler extends BaseHubHandler implements HandleableProtocol { /** * Name of used protocol */ @@ -54,17 +46,6 @@ abstract class BaseProtocolHandler extends BaseHandler implements HandleableProt parent::__construct($className); } - /** - * Setter for UNL instance - * - * @para $unlInstance An instance of a LocateableNode class - * @return void - */ - protected final function setUniversalNodeLocatorInstance (LocateableNode $unlInstance) { - // Set new UNL data array - $this->universalNodeLocatorInstance = $unlInstance; - } - /** * Validates given UNL very basicly by given regular expression. You * normally don't need/want to overwrite this method as this is a very basic @@ -104,16 +85,6 @@ abstract class BaseProtocolHandler extends BaseHandler implements HandleableProt $this->protocolName = $protocolName; } - /** - * Getter for UNL instance - * - * @return $unlData An instance of a LocateableNode class - */ - public final function getUniversalNodeLocatorInstance () { - // Return UNL data array - return $this->universalNodeLocatorInstance; - } - /** * Default implementation for returning address part, may not be suitable * for IPv4/IPv6 protocol handlers. So you have to overwrite (NOT CHANGE!) this method. diff --git a/application/hub/classes/handler/raw_data/class_ b/application/hub/classes/handler/raw_data/class_ index 9a2846c67..0b5036feb 100644 --- a/application/hub/classes/handler/raw_data/class_ +++ b/application/hub/classes/handler/raw_data/class_ @@ -1,18 +1,19 @@ + * @author Roland Haeder * @version 0.0.0 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 Hub Developer Team * @license GNU GPL 3.0 or any newer version - * @link http://www.ship-simu.org + * @link http://www.shipsimu.org * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -27,7 +28,7 @@ use Hub\Network\Networkable; * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -class ???NetworkPackageHandler extends BaseNetworkPackageHandler implements Networkable { +class ???RawDataHandler extends BaseRawDataHandler implements Networkable { /** * Protected constructor * @@ -38,40 +39,30 @@ class ???NetworkPackageHandler extends BaseNetworkPackageHandler implements Netw parent::__construct(__CLASS__); // Set handler name - $this->setHandlerName('!!!'); + $this->setHandlerName('|||'); } /** * Creates an instance of this class * - * @return $handlerInstance An instance of a Networkable class + * @return $handlerInstance An instance of a Networkable class */ - public final static function create???NetworkPackageHandler () { + public static final function create???RawDataHandler () { // Get new instance - $handlerInstance = new ???NetworkPackageHandler(); + $handlerInstance = new ???RawDataHandler(); // Return the prepared instance return $handlerInstance; } /** - * Processes a package from given resource. This is mostly useful for TCP - * package handling and is implemented in the TcpListener class + * Processes raw data from given resource. This is mostly useful for TCP + * package handling and is implemented in the ???Listener class * - * @param $resource A valid resource identifier + * @param $resource A valid socket resource array * @return void - * @throws InvalidResourceException If the given resource is invalid - * @todo 0% */ - public function processResourcePackage ($resource) { - // Check the resource - if (!is_resource($resource)) { - // Throw an exception - throw new InvalidResourceException($this, self::EXCEPTION_INVALID_RESOURCE); - } // END - if - - // Implement processing here - $this->partialStub('Please implement this method.'); + public function processRawDataFromResource (array $socketArray) { } } diff --git a/application/hub/classes/handler/raw_data/network/class_BaseRawDataHandler.php b/application/hub/classes/handler/raw_data/class_BaseRawDataHandler.php similarity index 96% rename from application/hub/classes/handler/raw_data/network/class_BaseRawDataHandler.php rename to application/hub/classes/handler/raw_data/class_BaseRawDataHandler.php index 914baddf6..b05eb66e1 100644 --- a/application/hub/classes/handler/raw_data/network/class_BaseRawDataHandler.php +++ b/application/hub/classes/handler/raw_data/class_BaseRawDataHandler.php @@ -5,11 +5,13 @@ namespace Hub\Handler\Network\RawData; // Import application-specific stuff use Hub\Container\Socket\StorableSocket; use Hub\Factory\Node\NodeObjectFactory; +use Hub\Generic\HubInterface; +use Hub\Handler\BaseHubHandler; use Hub\Network\Package\NetworkPackage; // Import framework stuff use CoreFramework\Factory\ObjectFactory; -use CoreFramework\Handler\BaseHandler; +use CoreFramework\Generic\UnsupportedOperationException; /** * A general Handler for raw data from sockets @@ -33,7 +35,7 @@ use CoreFramework\Handler\BaseHandler; * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -class BaseRawDataHandler extends BaseHandler { +class BaseRawDataHandler extends BaseHubHandler implements HubInterface { // - Package errors const PACKAGE_ERROR_INVALID_DATA = 'invalid_data'; // Invalid data in package found const PACKAGE_ERROR_INCOMPLETE_DATA = 'incomplete_data'; // Incomplete data sent (e.g. field is missing) diff --git a/application/hub/classes/handler/raw_data/network/.htaccess b/application/hub/classes/handler/raw_data/network/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/classes/handler/raw_data/network/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/classes/handler/network/socket/.htaccess b/application/hub/classes/handler/raw_data/socket/.htaccess similarity index 100% rename from application/hub/classes/handler/network/socket/.htaccess rename to application/hub/classes/handler/raw_data/socket/.htaccess diff --git a/application/hub/classes/handler/network/socket/class_SocketRawDataHandler.php b/application/hub/classes/handler/raw_data/socket/class_SocketRawDataHandler.php similarity index 100% rename from application/hub/classes/handler/network/socket/class_SocketRawDataHandler.php rename to application/hub/classes/handler/raw_data/socket/class_SocketRawDataHandler.php diff --git a/application/hub/classes/handler/network/tcp/.htaccess b/application/hub/classes/handler/raw_data/tcp/.htaccess similarity index 100% rename from application/hub/classes/handler/network/tcp/.htaccess rename to application/hub/classes/handler/raw_data/tcp/.htaccess diff --git a/application/hub/classes/handler/network/tcp/class_ b/application/hub/classes/handler/raw_data/tcp/class_ similarity index 100% rename from application/hub/classes/handler/network/tcp/class_ rename to application/hub/classes/handler/raw_data/tcp/class_ diff --git a/application/hub/classes/handler/network/tcp/class_TcpRawDataHandler.php b/application/hub/classes/handler/raw_data/tcp/class_TcpRawDataHandler.php similarity index 100% rename from application/hub/classes/handler/network/tcp/class_TcpRawDataHandler.php rename to application/hub/classes/handler/raw_data/tcp/class_TcpRawDataHandler.php diff --git a/application/hub/classes/handler/network/udp/.htaccess b/application/hub/classes/handler/raw_data/udp/.htaccess similarity index 100% rename from application/hub/classes/handler/network/udp/.htaccess rename to application/hub/classes/handler/raw_data/udp/.htaccess diff --git a/application/hub/classes/handler/network/udp/class_UdpRawDataHandler.php b/application/hub/classes/handler/raw_data/udp/class_UdpRawDataHandler.php similarity index 100% rename from application/hub/classes/handler/network/udp/class_UdpRawDataHandler.php rename to application/hub/classes/handler/raw_data/udp/class_UdpRawDataHandler.php diff --git a/application/hub/classes/helper/connection/class_BaseConnectionHelper.php b/application/hub/classes/helper/connection/class_BaseConnectionHelper.php index 355c76685..5fe5b8341 100644 --- a/application/hub/classes/helper/connection/class_BaseConnectionHelper.php +++ b/application/hub/classes/helper/connection/class_BaseConnectionHelper.php @@ -3,6 +3,7 @@ namespace Hub\Helper\Connection; // Import application-specific stuff +use Hub\Container\Socket\StorableSocket; use Hub\Factory\Fragmenter\FragmenterFactory; use Hub\Factory\Network\NetworkPackageFactory; use Hub\Factory\State\Peer\PeerStateFactory; @@ -109,7 +110,7 @@ class BaseConnectionHelper extends BaseHubSystemHelper implements Visitable, Reg */ public final function __toString () { // Class name representation - $class = self::getConnectionClassName($this->getSocketInstance(), parent::__toString()); + $class = self::getConnectionClassNameFromSocket($this->getSocketInstance(), parent::__toString()); // Return it return $class; @@ -137,12 +138,11 @@ class BaseConnectionHelper extends BaseHubSystemHelper implements Visitable, Reg /** * Static "getter" for this connection class' name * - * @param $address IP address - * @param $port Port number - * @param $className Original class name + * @param $socketInstance An instance of a StorableSocket class * @return $class Expanded class name */ - public static function getConnectionClassName ($address, $port, $className) { + public static function getConnectionClassNameFromSocket (StorableSocket $socketInstance) { + die(__METHOD__.':socketInstance='.print_r($socketInstance, TRUE)); // Construct it $class = $address . ':' . $port . ':' . $className; diff --git a/application/hub/classes/listener/class_BaseListenerDecorator.php b/application/hub/classes/listener/class_BaseListenerDecorator.php index 0d8564113..46fecd8ce 100644 --- a/application/hub/classes/listener/class_BaseListenerDecorator.php +++ b/application/hub/classes/listener/class_BaseListenerDecorator.php @@ -6,10 +6,12 @@ namespace Hub\Listener; use Hub\Container\Socket\StorableSocket; use Hub\Factory\Network\NetworkPackageFactory; use Hub\Listener\Listenable; +use Hub\Locator\Node\LocateableNode; use Hub\Network\Networkable; // Import framework stuff use CoreFramework\Generic\BaseDecorator; +use CoreFramework\Generic\UnsupportedOperationException; use CoreFramework\Visitor\Visitable; use CoreFramework\Visitor\Visitor; @@ -284,4 +286,25 @@ class BaseListenerDecorator extends BaseDecorator implements Visitable { $this->protocolName = $protocolName; } + /** + * Setter for UNL instance + * + * @para $unlInstance An instance of a LocateableNode class + * @return void + * @throws UnsupportedOperationException If this method is called + */ + protected final function setUniversalNodeLocatorInstance (LocateableNode $unlInstance) { + throw new UnsupportedOperationException('This method should not be called.'); + } + + /** + * Getter for UNL instance + * + * @return $unlData An instance of a LocateableNode class + * @throws UnsupportedOperationException If this method is called + */ + public final function getUniversalNodeLocatorInstance () { + throw new UnsupportedOperationException('This method should not be called.'); + } + } diff --git a/application/hub/classes/resolver/state/peer/class_PeerStateResolver.php b/application/hub/classes/resolver/state/peer/class_PeerStateResolver.php index f526eebf2..8fec88c5c 100644 --- a/application/hub/classes/resolver/state/peer/class_PeerStateResolver.php +++ b/application/hub/classes/resolver/state/peer/class_PeerStateResolver.php @@ -6,6 +6,8 @@ namespace Hub\Resolver\State\Peer; use Hub\Container\Socket\StorableSocket; use Hub\Factory\State\Peer\PeerStateFactory; use Hub\Helper\Connection\ConnectionHelper; +use Hub\Resolver\State\BaseStateResolver; +use Hub\Resolver\State\StateResolver; // Import framework stuff use CoreFramework\Socket\InvalidSocketException; diff --git a/application/hub/classes/states/peer/class_ b/application/hub/classes/states/peer/class_ index e9e2ac927..13cbe515c 100644 --- a/application/hub/classes/states/peer/class_ +++ b/application/hub/classes/states/peer/class_ @@ -4,6 +4,7 @@ namespace Hub\State\Peer; // Import application-specific stuff use Hub\Container\Socket\StorableSocket; +use Hub\State\Peer\PeerStateable; // Import framework stuff use CoreFramework\State\Stateable; diff --git a/application/hub/classes/states/peer/connected/class_ConnectedPeerState.php b/application/hub/classes/states/peer/connected/class_ConnectedPeerState.php index 9b71fe1e3..45e82c18a 100644 --- a/application/hub/classes/states/peer/connected/class_ConnectedPeerState.php +++ b/application/hub/classes/states/peer/connected/class_ConnectedPeerState.php @@ -4,6 +4,7 @@ namespace Hub\State\Peer; // Import application-specific stuff use Hub\Container\Socket\StorableSocket; +use Hub\State\Peer\PeerStateable; // Import framework stuff use CoreFramework\State\Stateable; diff --git a/application/hub/classes/states/peer/errors/class_ConnectionRefusedPeerState.php b/application/hub/classes/states/peer/errors/class_ConnectionRefusedPeerState.php index f12869ae6..cf42313a9 100644 --- a/application/hub/classes/states/peer/errors/class_ConnectionRefusedPeerState.php +++ b/application/hub/classes/states/peer/errors/class_ConnectionRefusedPeerState.php @@ -4,6 +4,7 @@ namespace Hub\State\Peer; // Import application-specific stuff use Hub\Container\Socket\StorableSocket; +use Hub\State\Peer\PeerStateable; // Import framework stuff use CoreFramework\State\Stateable; @@ -56,7 +57,5 @@ class ConnectionRefusedPeerState extends BasePeerState implements PeerStateable // Return the prepared instance return $stateInstance; } -} -// [EOF] -?> +} diff --git a/application/hub/classes/states/peer/errors/class_ConnectionTimedOutPeerState.php b/application/hub/classes/states/peer/errors/class_ConnectionTimedOutPeerState.php index 7313e9390..2de0616eb 100644 --- a/application/hub/classes/states/peer/errors/class_ConnectionTimedOutPeerState.php +++ b/application/hub/classes/states/peer/errors/class_ConnectionTimedOutPeerState.php @@ -4,6 +4,7 @@ namespace Hub\State\Peer; // Import application-specific stuff use Hub\Container\Socket\StorableSocket; +use Hub\State\Peer\PeerStateable; // Import framework stuff use CoreFramework\State\Stateable; @@ -56,7 +57,5 @@ class ConnectionTimedOutPeerState extends BasePeerState implements PeerStateable // Return the prepared instance return $stateInstance; } -} -// [EOF] -?> +} diff --git a/application/hub/classes/states/peer/errors/class_NoRouteToHostPeerState.php b/application/hub/classes/states/peer/errors/class_NoRouteToHostPeerState.php index edaa29f83..b90fb9ebe 100644 --- a/application/hub/classes/states/peer/errors/class_NoRouteToHostPeerState.php +++ b/application/hub/classes/states/peer/errors/class_NoRouteToHostPeerState.php @@ -4,6 +4,7 @@ namespace Hub\State\Peer; // Import application-specific stuff use Hub\Container\Socket\StorableSocket; +use Hub\State\Peer\PeerStateable; // Import framework stuff use CoreFramework\State\Stateable; @@ -56,7 +57,5 @@ class NoRouteToHostPeerState extends BasePeerState implements PeerStateable { // Return the prepared instance return $stateInstance; } -} -// [EOF] -?> +} diff --git a/application/hub/classes/states/peer/errors/class_OperationAlreadyProgressPeerState.php b/application/hub/classes/states/peer/errors/class_OperationAlreadyProgressPeerState.php index 99d39acc9..f33ed8994 100644 --- a/application/hub/classes/states/peer/errors/class_OperationAlreadyProgressPeerState.php +++ b/application/hub/classes/states/peer/errors/class_OperationAlreadyProgressPeerState.php @@ -4,6 +4,7 @@ namespace Hub\State\Peer; // Import application-specific stuff use Hub\Container\Socket\StorableSocket; +use Hub\State\Peer\PeerStateable; // Import framework stuff use CoreFramework\State\Stateable; @@ -56,7 +57,5 @@ class OperationAlreadyProgressPeerState extends BasePeerState implements PeerSta // Return the prepared instance return $stateInstance; } -} -// [EOF] -?> +} diff --git a/application/hub/classes/states/peer/errors/class_ProblemPeerState.php b/application/hub/classes/states/peer/errors/class_ProblemPeerState.php index ca6d00f2d..51fce8833 100644 --- a/application/hub/classes/states/peer/errors/class_ProblemPeerState.php +++ b/application/hub/classes/states/peer/errors/class_ProblemPeerState.php @@ -4,6 +4,7 @@ namespace Hub\State\Peer; // Import application-specific stuff use Hub\Container\Socket\StorableSocket; +use Hub\State\Peer\PeerStateable; // Import framework stuff use CoreFramework\State\Stateable; @@ -56,7 +57,5 @@ class ProblemPeerState extends BasePeerState implements PeerStateable { // Return the prepared instance return $stateInstance; } -} -// [EOF] -?> +} diff --git a/application/hub/classes/states/peer/errors/class_TransportEndpointGonePeerState.php b/application/hub/classes/states/peer/errors/class_TransportEndpointGonePeerState.php index 30aa74d6c..3a6430742 100644 --- a/application/hub/classes/states/peer/errors/class_TransportEndpointGonePeerState.php +++ b/application/hub/classes/states/peer/errors/class_TransportEndpointGonePeerState.php @@ -4,6 +4,7 @@ namespace Hub\State\Peer; // Import application-specific stuff use Hub\Container\Socket\StorableSocket; +use Hub\State\Peer\PeerStateable; // Import framework stuff use CoreFramework\State\Stateable; @@ -56,7 +57,5 @@ class TransportEndpointGonePeerState extends BasePeerState implements PeerStatea // Return the prepared instance return $stateInstance; } -} -// [EOF] -?> +} diff --git a/application/hub/classes/states/peer/init/class_InitPeerState.php b/application/hub/classes/states/peer/init/class_InitPeerState.php index da101a976..a3aab4723 100644 --- a/application/hub/classes/states/peer/init/class_InitPeerState.php +++ b/application/hub/classes/states/peer/init/class_InitPeerState.php @@ -53,7 +53,5 @@ class InitPeerState extends BasePeerState implements PeerStateable { // Return the prepared instance return $stateInstance; } -} -// [EOF] -?> +} diff --git a/application/hub/config.php b/application/hub/config.php index e0a9a1704..391824b0e 100644 --- a/application/hub/config.php +++ b/application/hub/config.php @@ -61,7 +61,7 @@ $cfg->setConfigEntry('node_dht_db_wrapper_class', 'Hub\Database\Frontend\Node\Dh $cfg->setConfigEntry('node_dht_list_limit', 20); // CFG: PEER-LOOKUP-DB-WRAPPER-CLASS -$cfg->setConfigEntry('peer_state_lookup_db_wrapper_class', 'PeerStateLookupDatabaseWrapper'); +$cfg->setConfigEntry('peer_state_lookup_db_wrapper_class', 'Hub\Database\Frontend\Node\PeerState\PeerStateLookupDatabaseWrapper'); // CFG: WEB-CONTENT-TYPE $cfg->setConfigEntry('web_content_type', ''); diff --git a/application/hub/interfaces/class_HubInterface.php b/application/hub/interfaces/class_HubInterface.php index 68b7d2147..2abd9c85c 100644 --- a/application/hub/interfaces/class_HubInterface.php +++ b/application/hub/interfaces/class_HubInterface.php @@ -98,4 +98,11 @@ interface HubInterface extends FrameworkInterface { */ function getSocketInstance (); + /** + * Getter for UNL instance + * + * @return $unlInstance An instance of a LocateableNode class + */ + function getUniversalNodeLocatorInstance (); + } diff --git a/application/hub/interfaces/handler/answer-status/class_HandleableAnswerStatus.php b/application/hub/interfaces/handler/answer-status/class_HandleableAnswerStatus.php index b8e7c78f4..74f64de7e 100644 --- a/application/hub/interfaces/handler/answer-status/class_HandleableAnswerStatus.php +++ b/application/hub/interfaces/handler/answer-status/class_HandleableAnswerStatus.php @@ -3,6 +3,7 @@ namespace Hub\AnswerStatus\Node; // Import application-specific stuff +use Hub\Generic\HubInterface; use Hub\Network\Receive\Receivable; // Import framework stuff @@ -31,7 +32,7 @@ use CoreFramework\Handler\DataSet\HandleableDataSet; * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -interface HandleableAnswerStatus extends HandleableDataSet { +interface HandleableAnswerStatus extends HandleableDataSet, HubInterface { /** * Handles given message data array * @@ -49,7 +50,5 @@ interface HandleableAnswerStatus extends HandleableDataSet { * @return void */ function addArrayToDataSet (StoreableCriteria $dataSetInstance, array $messageData); -} -// [EOF] -?> +} diff --git a/application/hub/interfaces/handler/chunks/class_HandleableChunks.php b/application/hub/interfaces/handler/chunks/class_HandleableChunks.php index 1d0a90a09..f8f920d37 100644 --- a/application/hub/interfaces/handler/chunks/class_HandleableChunks.php +++ b/application/hub/interfaces/handler/chunks/class_HandleableChunks.php @@ -2,6 +2,9 @@ // Own namespace namespace Hub\Handler\Network\RawData\Chunks; +// Import application-specific stuff +use Hub\Generic\HubInterface; + // Import framework stuff use CoreFramework\Handler\Handleable; @@ -27,7 +30,7 @@ use CoreFramework\Handler\Handleable; * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -interface HandleableChunks extends Handleable { +interface HandleableChunks extends Handleable, HubInterface { /** * Adds all chunks if the last one verifies as a 'final chunk'. * @@ -101,7 +104,5 @@ interface HandleableChunks extends Handleable { * @return void */ function handledAssembledRawPackageData (); -} -// [EOF] -?> +} diff --git a/application/hub/interfaces/handler/message-types/class_HandleableMessage.php b/application/hub/interfaces/handler/message-types/class_HandleableMessage.php index 5ad7ee260..ba9653576 100644 --- a/application/hub/interfaces/handler/message-types/class_HandleableMessage.php +++ b/application/hub/interfaces/handler/message-types/class_HandleableMessage.php @@ -3,6 +3,7 @@ namespace Hub\Handler\Message; // Import application-specific stuff +use Hub\Generic\HubInterface; use Hub\Network\Receive\Receivable; // Import framework stuff @@ -30,7 +31,7 @@ use CoreFramework\Handler\DataSet\HandleableDataSet; * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -interface HandleableMessage extends HandleableDataSet { +interface HandleableMessage extends HandleableDataSet, HubInterface { /** * Handles data array of the message * @@ -48,7 +49,5 @@ interface HandleableMessage extends HandleableDataSet { * @return void */ function postHandleMessageData (array $messageData, Receivable $packageInstance); -} -// [EOF] -?> +} diff --git a/application/hub/interfaces/handler/network/class_Networkable.php b/application/hub/interfaces/handler/network/class_Networkable.php index caf56cf9e..4cd6ed37c 100644 --- a/application/hub/interfaces/handler/network/class_Networkable.php +++ b/application/hub/interfaces/handler/network/class_Networkable.php @@ -2,6 +2,9 @@ // Own namespace namespace Hub\Network; +// Import application-specific stuff +use Hub\Generic\HubInterface; + // Import framework stuff use CoreFramework\Handler\DataSet\HandleableDataSet; @@ -27,7 +30,7 @@ use CoreFramework\Handler\DataSet\HandleableDataSet; * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -interface Networkable extends HandleableDataSet { +interface Networkable extends HandleableDataSet, HubInterface { /** * Processes raw data from given resource. This is mostly useful for TCP * package handling and is implemented in the TcpListener class @@ -51,7 +54,5 @@ interface Networkable extends HandleableDataSet { * @return $decodedData Raw data from the stacker */ function getNextRawData (); -} -// [EOF] -?> +} diff --git a/application/hub/interfaces/handler/protocol/class_HandleableProtocol.php b/application/hub/interfaces/handler/protocol/class_HandleableProtocol.php index 79575b8b8..33528ffe5 100644 --- a/application/hub/interfaces/handler/protocol/class_HandleableProtocol.php +++ b/application/hub/interfaces/handler/protocol/class_HandleableProtocol.php @@ -2,6 +2,9 @@ // Own namespace namespace Hub\Handler\Protocol; +// Import application-specific stuff +use Hub\Generic\HubInterface; + // Import framework stuff use CoreFramework\Handler\Handleable; @@ -27,14 +30,7 @@ use CoreFramework\Handler\Handleable; * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -interface HandleableProtocol extends Handleable { - /** - * Getter for UNL instance - * - * @return $unlInstance An instance of a LocateableNode class - */ - function getUniversalNodeLocatorInstance (); - +interface HandleableProtocol extends Handleable, HubInterface { /** * Getter for port number to satify HandleableProtocol * diff --git a/application/hub/interfaces/helper/connections/class_ConnectionHelper.php b/application/hub/interfaces/helper/connections/class_ConnectionHelper.php index be49b0561..511bd8f6a 100644 --- a/application/hub/interfaces/helper/connections/class_ConnectionHelper.php +++ b/application/hub/interfaces/helper/connections/class_ConnectionHelper.php @@ -3,6 +3,7 @@ namespace Hub\Helper\Connection; // Import application-specific stuff +use Hub\Container\Socket\StorableSocket; use Hub\Helper\HubHelper; /** @@ -50,12 +51,10 @@ interface ConnectionHelper extends HubHelper { /** * Static "getter" for this connection class' name * - * @param $address IP address - * @param $port Port number - * @param $className Original class name + * @param $socketInstance An instance of a StorableSocket class * @return $class Expanded class name */ - static function getConnectionClassName ($address, $port, $className); + static function getConnectionClassNameFromSocket (StorableSocket $socketInstance); /** * Getter for shuttedDown diff --git a/application/hub/interfaces/lookup/node_states/class_LookupableNodeState.php b/application/hub/interfaces/lookup/node_states/class_LookupableNodeState.php index d3f24b44f..c651cf691 100644 --- a/application/hub/interfaces/lookup/node_states/class_LookupableNodeState.php +++ b/application/hub/interfaces/lookup/node_states/class_LookupableNodeState.php @@ -1,4 +1,10 @@ diff --git a/application/hub/interfaces/lookup/peer_states/class_LookupablePeerState.php b/application/hub/interfaces/lookup/peer_states/class_LookupablePeerState.php index 7385a22e5..01b8a3bcc 100644 --- a/application/hub/interfaces/lookup/peer_states/class_LookupablePeerState.php +++ b/application/hub/interfaces/lookup/peer_states/class_LookupablePeerState.php @@ -5,6 +5,8 @@ namespace Hub\State\Peer\Lookup; // Import application-specific stuff use Hub\Container\Socket\StorableSocket; use Hub\Helper\Connection\ConnectionHelper; +use Hub\LookupTable\Lookupable; +use Hub\State\Peer\PeerStateable; // Import framework stuff use CoreFramework\State\Stateable; @@ -61,10 +63,10 @@ interface LookupablePeerState extends Lookupable { /** * Purges old entries of given socket resource. We use the IP address from that resource. * - * @param $socketResource A valid socket resource + * @param $socketInstance An instance of a StorableSocket class * @return void */ - function purgeOldEntriesBySocketResource ($socketResource); + function purgeOldEntriesBysocketInstance (StorableSocket $socketInstance); /** * Checks whether a given peer state (in helper instance) is same as stored @@ -75,7 +77,5 @@ interface LookupablePeerState extends Lookupable { * @return $isSamePeerState Whether the peer's state is the same */ function isSamePeerState (ConnectionHelper $helperInstance, array $packageData); -} -// [EOF] -?> +} diff --git a/application/hub/interfaces/resolver/state/class_StateResolver.php b/application/hub/interfaces/resolver/state/class_StateResolver.php index dabe7930d..85554f55f 100644 --- a/application/hub/interfaces/resolver/state/class_StateResolver.php +++ b/application/hub/interfaces/resolver/state/class_StateResolver.php @@ -3,6 +3,7 @@ namespace Hub\Resolver\State; // Import application-specific stuff +use Hub\Container\Socket\StorableSocket; use Hub\Helper\Connection\ConnectionHelper; // Import framework stuff @@ -36,10 +37,10 @@ interface StateResolver extends Resolver { * * @param $helperInstance An instance of a ConnectionHelper class * @param $packageData Raw package data - * @param $socketResource A valid socket resource + * @param $socketInstance An instance of a StorableSocket class * @return $stateInstance An instance of the resolved state */ - static function resolveStateByPackage (ConnectionHelper $helperInstance, array $packageData, $socketResource); + static function resolveStateByPackage (ConnectionHelper $helperInstance, array $packageData, StorableSocket $socketInstance); /** * Checks whether the given state is valid diff --git a/application/hub/interfaces/states/peer/class_PeerStateable.php b/application/hub/interfaces/states/peer/class_PeerStateable.php index e1de0cb0f..57ab4fdc9 100644 --- a/application/hub/interfaces/states/peer/class_PeerStateable.php +++ b/application/hub/interfaces/states/peer/class_PeerStateable.php @@ -29,6 +29,3 @@ use CoreFramework\State\Stateable; */ interface PeerStateable extends Stateable { } - -// [EOF] -?> -- 2.39.5