]> git.mxchange.org Git - hub.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Mon, 29 May 2017 18:13:47 +0000 (20:13 +0200)
committerRoland Häder <roland@mxchange.org>
Fri, 21 Aug 2020 16:50:09 +0000 (18:50 +0200)
- moved socketInstance +getter/setter to BaseHubSystem
- implemented getUnlAddress()
- implemented getSocketRecipient()
- imported PeerStateFactory
- imported OutputStream
- imported BaseResolver
- other small fixes
- added missing namespaces to configuration entries
- updated core framework

Signed-off-by: Roland Häder <roland@mxchange.org>
19 files changed:
application/hub/classes/class_BaseHubSystem.php
application/hub/classes/container/socket/class_SocketContainer.php
application/hub/classes/helper/connection/class_BaseConnectionHelper.php
application/hub/classes/helper/connection/ipv4/class_BaseIpV4ConnectionHelper.php
application/hub/classes/helper/connection/ipv4/tcp/class_TcpConnectionHelper.php
application/hub/classes/info/connection/class_ConnectionInfo.php
application/hub/classes/listener/class_BaseListener.php
application/hub/classes/locator/class_UniversalNodeLocator.php
application/hub/classes/resolver/state/class_BaseStateResolver.php
application/hub/classes/resolver/state/peer/class_PeerStateResolver.php
application/hub/classes/states/peer/class_BasePeerState.php
application/hub/classes/streams/raw_data/output/class_RawDataOutputStream.php
application/hub/config.php
application/hub/interfaces/class_HubInterface.php
application/hub/interfaces/container/socket/class_StorableSocket.php
application/hub/interfaces/helper/connections/class_ConnectionHelper.php
application/hub/interfaces/listener/class_Listenable.php
application/hub/interfaces/locator/class_LocateableNode.php
core

index 76e8b27aaf885d33f247a2398fa1fcd9811ed290..dbad5a7783de28cf54793d231d87ac2bd9b6a814 100644 (file)
@@ -3,6 +3,7 @@
 namespace Hub\Generic;
 
 // Import application-specific stuff
+use Hub\Container\Socket\StorableSocket;
 use Hub\Handler\Protocol\HandleableProtocol;
 use Hub\Handler\Network\RawData\BaseRawDataHandler;
 use Hub\Information\ShareableInfo;
@@ -108,6 +109,11 @@ class BaseHubSystem extends BaseFrameworkSystem implements HubInterface {
         */
        private $protocolInstance = NULL;
 
+       /**
+        * A StorableSocket instance
+        */
+       private $socketInstance = NULL;
+
        /**
         * Name of used protocol
         */
@@ -391,4 +397,23 @@ class BaseHubSystem extends BaseFrameworkSystem implements HubInterface {
                $this->protocolName = $protocolName;
        }
 
+       /**
+        * 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;
+       }
+
 }
index f718d9ce9b582f95fc626badd02eb34202c12e0f..c4d88636cd06df083e96d8d1d6015c9d217e54dd 100644 (file)
@@ -4,6 +4,7 @@ namespace Hub\Container\Socket;
 
 // Import application-specific stuff
 use Hub\Handler\Network\RawData\BaseRawDataHandler;
+use Hub\Factory\Network\Locator\UniversalNodeLocatorFactory;
 use Hub\Factory\Socket\SocketFactory;
 use Hub\Helper\Connection\BaseConnectionHelper;
 use Hub\Information\ShareableInfo;
@@ -26,6 +27,7 @@ use CoreFramework\Visitor\Visitor;
 
 // Import SPL stuff
 use \BadMethodCallException;
+use \LogicException;
 
 /**
  * A Socket Container class
@@ -291,6 +293,26 @@ class SocketContainer extends BaseContainer implements StorableSocket, Visitable
                return $this->socketProtocol;
        }
 
+       /**
+        * Getter for socket recipient array element
+        *
+        * @return      $recipient      Recipient array element
+        * @throws      LogicException  If 'recipient' array element is not found
+        */
+       public function getSocketRecipient () {
+               // Get package data
+               $packageData = $this->getPackageData();
+
+               // Is the element there?
+               if (!isset($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT])) {
+                       // Abort here
+                       throw new LogicException(sprintf('packageData[%s] is not set.', NetworkPackage::PACKAGE_DATA_RECIPIENT));
+               } // END - if
+
+               // Return it
+               return $packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT];
+       }
+
        /**
         * Validates stored stocket
         *
@@ -436,15 +458,48 @@ class SocketContainer extends BaseContainer implements StorableSocket, Visitable
                return $result;
        }
 
+       /**
+        * Connects to socket recipient (supplied in package data array
+        *
+        * @return      $result         Result from calling socket_connect()
+        * @throws      InvalidSocketException  If stored socket is invalid
+        */
+       public function connectToSocketRecipient () {
+               // Should be valid socket
+               if (!$this->isValidSocket()) {
+                       // Throw exception
+                       throw new InvalidSocketException(array($this, $this->getSocketResource()), self::EXCEPTION_INVALID_SOCKET);
+               } // END - if
+
+               // Get recipient UNL
+               $unlRecipient = $this->getSocketRecipient();
+
+               // Create UNL instance from it. This will validate the connection
+               $unlInstance = UniversalNodeLocatorFactory::createUnlInstanceFromString($unlRecipient);
+
+               // Try to connect to it
+               $result = socket_connect($this->getSocketResource(), $unlInstance->getUnlAddress(), $unlInstance->getUnlPort());
+
+               // Return result
+               return $result;
+       }
+
        /**
         * Do the shutdown sequence for this connection helper
         *
         * @return      void
         * @throws      SocketShutdownException         If the current socket could not be shut down
+        * @throws      BaseMethodCallException         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!
         */
        public function doShutdown () {
+               // 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);
+               } // END - if
+
                // Debug message
                self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($this->getSocketProtocol()) . '-SOCKET: Shutting down socket ' . $this->getSocketResource());
                $this->partialStub('Please rewrite this method.');
@@ -611,6 +666,34 @@ class SocketContainer extends BaseContainer implements StorableSocket, Visitable
         * @return      $result         Whether OOB has been enabled
         */
        public function enableSocketOutOfBandData () {
+               $this->partialStub('Please implement this method.');
+       }
+
+       /**
+        * Clears last socket error
+        *
+        * @return      void
+        * @throws      InvalidSocketException  If stored socket is invalid
+        * @throws      BadMethodCallException  If no socket error was reported but method called
+        */
+       public function clearLastSocketError () {
+               // Trace message
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($this->getSocketProtocol()) . '-SOCKET: Clearing socket error - CALLED!');
+
+               // Should be valid socket
+               if (!$this->isValidSocket()) {
+                       // Throw exception
+                       throw new InvalidSocketException(array($this, $this->getSocketResource()), self::EXCEPTION_INVALID_SOCKET);
+               } elseif ($this->getLastSocketErrorCode() === 0) {
+                       // Nothing to clear
+                       throw new BadMethodCallException(sprintf('Socket "%s" has no error reported, but method is called.', $this->getSocketResource()));
+               }
+
+               // Clear last error
+               socket_clear_error($this->getSocketResource());
+
+               // Trace message
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($this->getSocketProtocol()) . '-SOCKET: Error cleared - EXIT!');
        }
 
        /**
@@ -798,8 +881,7 @@ class SocketContainer extends BaseContainer implements StorableSocket, Visitable
 
        /**
         * Handles socket error 'operation already in progress' which happens in
-        * method connectToPeerByUnlInstance() on timed out connection
-        * attempts.
+        * method connectToPeerBySocketRecipient() on timed-out connection attempts.
         *
         * @param       $socketData             Valid socket data array
         * @return      void
@@ -989,31 +1071,4 @@ class SocketContainer extends BaseContainer implements StorableSocket, Visitable
                return $result;
        }
 
-       /**
-        * Clears last socket error
-        *
-        * @return      void
-        * @throws      InvalidSocketException  If stored socket is invalid
-        * @throws      BadMethodCallException  If no socket error was reported but method called
-        */
-       private function clearLastSocketError () {
-               // Trace message
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($this->getSocketProtocol()) . '-SOCKET: Clearing socket error - CALLED!');
-
-               // Should be valid socket
-               if (!$this->isValidSocket()) {
-                       // Throw exception
-                       throw new InvalidSocketException(array($this, $this->getSocketResource()), self::EXCEPTION_INVALID_SOCKET);
-               } elseif ($this->getLastSocketErrorCode() === 0) {
-                       // Nothing to clear
-                       throw new BadMethodCallException(sprintf('Socket "%s" has no error reported, but method is called.', $this->getSocketResource()));
-               }
-
-               // Clear last error
-               socket_clear_error($this->getSocketResource());
-
-               // Trace message
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($this->getSocketProtocol()) . '-SOCKET: Error cleared - EXIT!');
-       }
-
 }
index 1e3e7505470d7d3ac9860e680a07bbddc1f3cc2b..355c7668502bd2e115961d0923e3c961c1c216a5 100644 (file)
@@ -5,6 +5,7 @@ namespace Hub\Helper\Connection;
 // Import application-specific stuff
 use Hub\Factory\Fragmenter\FragmenterFactory;
 use Hub\Factory\Network\NetworkPackageFactory;
+use Hub\Factory\State\Peer\PeerStateFactory;
 use Hub\Helper\BaseHubSystemHelper;
 use Hub\Network\Package\NetworkPackage;
 
@@ -41,11 +42,6 @@ class BaseConnectionHelper extends BaseHubSystemHelper implements Visitable, Reg
        // Exception codes
        const EXCEPTION_UNSUPPORTED_ERROR_HANDLER = 0x9100;
 
-       /**
-        * (IP) Adress used
-        */
-       private $address = 0;
-
        /**
         * Sent data in bytes
         */
@@ -113,31 +109,12 @@ class BaseConnectionHelper extends BaseHubSystemHelper implements Visitable, Reg
         */
        public final function __toString () {
                // Class name representation
-               $class = self::getConnectionClassName($this->getAddress(), $this->getConnectionPort(), parent::__toString());
+               $class = self::getConnectionClassName($this->getSocketInstance(), parent::__toString());
 
                // Return it
                return $class;
        }
 
-       /**
-        * 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;
-       }
-
        /**
         * Setter for isInitialized
         *
index f40fb6d067fa3d01ecf317cbca8a022189a0cf4e..ec16978f6ee3cc4c6cc78ab8adde6d6070a907b9 100644 (file)
@@ -3,6 +3,7 @@
 namespace Hub\Helper\Connection\Network\IpV4;
 
 // Import application-specific stuff
+use Hub\Factory\State\Peer\PeerStateFactory;
 use Hub\Helper\Connection\BaseConnectionHelper;
 use Hub\Locator\Node\LocateableNode;
 
@@ -30,11 +31,6 @@ use Hub\Locator\Node\LocateableNode;
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
 class BaseIpV4ConnectionHelper extends BaseConnectionHelper {
-       /**
-        * Port number used
-        */
-       private $connectionPort = 0;
-
        /**
         * Protected constructor
         *
@@ -46,57 +42,34 @@ class BaseIpV4ConnectionHelper extends BaseConnectionHelper {
                parent::__construct($className);
        }
 
-       /**
-        * Getter for port number to
-        *
-        * @return      $connectionPort The port number
-        */
-       public final function getConnectionPort () {
-               return $this->connectionPort;
-       }
-
-       /**
-        * Setter for port number
-        *
-        * @param       $connectionPort The port number
-        * @return      void
-        */
-       protected final function setConnectionPort ($connectionPort) {
-               $this->connectionPort = $connectionPort;
-       }
-
        /**
         * Attempts to connect to a peer by given IP number and port from an UNL
         * instance with currently configured timeout.
         *
-        * @param       $unlInstance    An instance of a LocateableNode class
         * @return      $isConnected    Whether the connection went fine
         * @see         Please see http://de.php.net/manual/en/function.socket-connect.php#84465 for original code
         * @todo        Rewrite the while() loop to a iterator to not let the software stay very long here
         */
-       protected function connectToPeerByUnlInstance (LocateableNode $unlInstance) {
+       protected function connectToPeerBySocketRecipient () {
+               //* DEBUG-DIE: */ die(__METHOD__.':socketInstance='.print_r($this->getSocketInstance(), TRUE));
+
                // Only call this if the connection is fully initialized
                assert($this->isInitialized());
 
-               // Is the UNL data complete?
-               assert($unlInstance->isValidUnl());
-
                // "Cache" socket resource and timeout config
                $timeout = $this->getConfigInstance()->getConfigEntry('socket_timeout_seconds');
 
                // Debug output
-               self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CONNECTION-HELPER: Trying to connect to ' . $unlInstance->getUnlAddress() . ':' . $unlInstance->getUnlPort() . ' with socketResource[' . gettype($this->getSocketInstance()->getSocketResource()) . ']=' . $this->getSocketInstance()->getSocketResource() . ' ...');
+               self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('CONNECTION-HELPER: Trying to connect to %s with socketResource[%s]=%s ...', $this->getSocketInstance()->getSocketRecipient(), gettype($this->getSocketInstance()->getSocketResource()), $this->getSocketInstance()->getSocketResource()));
 
                // Get current time
                $hasTimedOut = FALSE;
                $time = time();
-               $this->partialStub('Please rewrite this part.');
-               return;
 
                // Try to connect until it is connected
-               while ($isConnected = !@socket_connect($this->getSocketInstance(), $unlData[LocateableNode::UNL_PART_ADDRESS], $unlData[LocateableNode::UNL_PART_PORT])) {
+               while ($isConnected = !$this->getSocketInstance()->connectToSocketRecipient()) {
                        // Get last socket error
-                       $socketError = socket_last_error($this->getSocketInstance());
+                       $socketError = $this->getSocketInstance()->getLastSocketErrorCode();
 
                        // Log error code and status
                        /* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CONNECTION-HELPER: socketError=' . $socketError . ',isConnected=' . intval($isConnected));
@@ -143,7 +116,7 @@ class BaseIpV4ConnectionHelper extends BaseConnectionHelper {
                        $isConnected = TRUE;
 
                        // Clear error
-                       socket_clear_error($this->getSocketInstance());
+                       $this->getSocketInstance()->clearLastSocketError();
                } // END - if
 
                // Is the peer connected?
index 50efbbaa878a42ab7435f389894264089c20de58..7513b416a554d23e5c713551fa73f9ce8b0eba0e 100644 (file)
@@ -114,21 +114,17 @@ class TcpConnectionHelper extends BaseIpV4ConnectionHelper implements Connection
                        }
                }
 
-               // Set address and maybe port
-               $helperInstance->setAddress($unlInstance->getUnlAddress());
-               $helperInstance->setConnectionPort($unlInstance->getUnlPort());
-
                // Now connect to it
-               if (!$helperInstance->connectToPeerByUnlInstance($unlData)) {
+               if (!$helperInstance->connectToPeerBySocketRecipient()) {
                        // Debug message
-                       self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('HELPER: helperInstance=' . $helperInstance->__toString() . ',unlData=' . print_r($unlData, TRUE));
+                       self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('TCP-CONNECTION-HELPER: helperInstance=%s,unlInstance.unlData=%s', $helperInstance->__toString(), print_r($unlInstance->getUnlData(), TRUE)));
 
                        // Handle socket error
-                       $helperInstance->handleSocketError(__METHOD__, __LINE__, $socketResource, $unlData);
+                       $socketInstance->handleSocketError(__METHOD__, __LINE__, $unlInstance->getUnlData());
                } // END - if
 
                // Okay, that should be it. Return it...
-               return $socketResource;
+               return $socketInstance;
        }
 
        /**
@@ -140,7 +136,7 @@ class TcpConnectionHelper extends BaseIpV4ConnectionHelper implements Connection
         */
        public function doShutdown () {
                // Debug message
-               self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('HELPER: Shutting down connection ... - CALLED!');
+               self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('TCP-CONNECTION-HELPER: Shutting down connection ... - CALLED!');
 
                $this->partialStub('Please implement this method.');
        }
index 45c048b16bd75caf80f29f576aca28067f0c2092..1d6c48b10da07987ca54880a063bb54bfdf2d9e9 100644 (file)
@@ -91,9 +91,9 @@ class ConnectionInfo extends BaseInfo implements ShareableInfo, Registerable {
                //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(': protocolName=' . $helperInstance->getProtocolName() . ',helperInstance=' . $helperInstance->__toString() . ',socketResource=' . $helperInstance->getSocketResource() . ' - CALLED!');
 
                // Fill the generic array with several data from the listener:
-               $this->setProtocolName($helperInstance->getProtocolName());
-               $this->setGenericArrayElement('connection', 'dummy', 'dummy', LocateableNode::UNL_PART_ADDRESS , $helperInstance->getAddress());
-               $this->setGenericArrayElement('connection', 'dummy', 'dummy', LocateableNode::UNL_PART_PORT    , $helperInstance->getConnectionPort());
+               $this->setProtocolName($helperInstance->getSocketInstance()->getSocketProtocol());
+               $this->setGenericArrayElement('connection', 'dummy', 'dummy', LocateableNode::UNL_PART_ADDRESS , $helperInstance->getSocketInstance()->getRecipientAddress());
+               $this->setGenericArrayElement('connection', 'dummy', 'dummy', LocateableNode::UNL_PART_PORT    , $helperInstance->getSocketInstance()->getRecipientPort());
 
                // Set helper here
                $this->setHelperInstance($helperInstance);
index f367f33cc3d368dce642ec39326e3c97db3ade6b..a7bf4602b27925e6ba6dad984b3081f22ea9547f 100644 (file)
@@ -68,11 +68,6 @@ class BaseListener extends BaseHubSystem implements Visitable {
         */
        private $poolInstance = NULL;
 
-       /**
-        * A StorableSocket instance
-        */
-       private $socketInstance = NULL;
-
        /**
         * Protected constructor
         *
@@ -322,23 +317,4 @@ class BaseListener extends BaseHubSystem implements Visitable {
                $this->getIteratorInstance()->next();
        }
 
-       /**
-        * 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;
-       }
-
 }
index 1a5ad11aa3fa047f1d74e058a962756c09fdcdfc..b4b51f95e1e3d54910ba205d493f6a847791d066 100644 (file)
@@ -117,11 +117,33 @@ class UniversalNodeLocator extends BaseHubSystem implements LocateableNode, Regi
                return $unlData[NodeInformationDatabaseWrapper::DB_COLUMN_INTERNAL_UNL];
        }
 
+       /**
+        * Some "getter" for UNL address part.
+        *
+        * @return      $unlAddress UNL address part
+        */
+       public function getUnlAddress () {
+               // Get UNL data
+               $unlData = $this->getUnlData();
+
+               // Default value is NULL
+               $unlPort = NULL;
+
+               // Is the element there?
+               if (isset($unlData[LocateableNode::UNL_PART_ADDRESS])) {
+                       // Use it
+                       $unlPort = $unlData[LocateableNode::UNL_PART_ADDRESS];
+               } // END - if
+
+               // Return it
+               return $unlPort;
+       }
+
        /**
         * Some "getter" for UNL port (if supported). If not supported, NULL is
         * being returned.
         *
-        * @return      $unlPort Port number of UNL
+        * @return      $unlPort        Port number of UNL or NULL
         */
        public function getUnlPort () {
                // Get UNL data
@@ -157,6 +179,15 @@ class UniversalNodeLocator extends BaseHubSystem implements LocateableNode, Regi
                $this->parseUniversalNodeLocator($unl);
        }
 
+       /**
+        * Getter for UNL data array
+        *
+        * @return      $unlData        An array with UNL data
+        */
+       public final function getUnlData () {
+               return $this->unlData;
+       }
+
        /**
         * Parses the given UNL by splitting it up in its components. The UNL ...
         *
@@ -243,15 +274,6 @@ class UniversalNodeLocator extends BaseHubSystem implements LocateableNode, Regi
                } // END - foreach
        }
 
-       /**
-        * Getter for UNL data array
-        *
-        * @return      $unlData        An array with UNL data
-        */
-       private function getUnlData () {
-               return $this->unlData;
-       }
-
        /**
         * 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
index eaceee675d424624a2a2f01805a5f0ad401237b4..e6107574c68d8fe33af0e7e57a1c47574d631141 100644 (file)
@@ -4,6 +4,7 @@ namespace Hub\Resolver\State;
 
 // Import framework stuff
 use CoreFramework\Factory\ObjectFactory;
+use CoreFramework\Resolver\BaseResolver;
 
 /**
  * A generic state resolver class
index bf689f6371b0ce0361d30ead81f14b9a8ee0cfce..f526eebf208cb3e79f0443b79fddf3635b5ccc02 100644 (file)
@@ -4,6 +4,7 @@ namespace Hub\Resolver\State\Peer;
 
 // Import application-specific stuff
 use Hub\Container\Socket\StorableSocket;
+use Hub\Factory\State\Peer\PeerStateFactory;
 use Hub\Helper\Connection\ConnectionHelper;
 
 // Import framework stuff
index 1113b34932e77cdd43791fbcd9a9e3156a84e8ee..abfdc3c5212038d0dd71734241568fd7623bce20 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 // Own namespace
-namespace Hub\Peer\State;
+namespace Hub\State\Peer;
 
 // Import framework stuff
 use CoreFramework\State\BaseState;
index e692fa81bf5c1eb2bf0cc24334331582f321fa42..c6c4b2b82fb0f62575f6a83da767fd5af3526885 100644 (file)
@@ -7,6 +7,7 @@ use Hub\Handler\Network\RawData\BaseRawDataHandler;
 
 // Import framework stuff
 use CoreFramework\Stream\BaseStream;
+use CoreFramework\Stream\Output\OutputStream;
 
 /**
  * A RawDataOutputStream class
index 16cfc7cffc954aeca059fb4b915fbc833f95b246..e0a9a17048dd415224842a45839b9cd843c59a21 100644 (file)
@@ -875,28 +875,28 @@ $cfg->setConfigEntry('node_announcement_completed_state_class', 'Hub\State\Node\
 ///////////////////////////////////////////////////////////////////////////////
 
 // CFG: PEER-INIT-STATE-CLASS
-$cfg->setConfigEntry('peer_init_state_class', 'InitPeerState');
+$cfg->setConfigEntry('peer_init_state_class', 'Hub\State\Peer\InitPeerState');
 
 // CFG: PEER-CONNECTED-STATE-CLASS
-$cfg->setConfigEntry('peer_connected_state_class', 'ConnectedPeerState');
+$cfg->setConfigEntry('peer_connected_state_class', 'Hub\State\Peer\ConnectedPeerState');
 
 // CFG: PEER-PROBLEM-STATE-CLASS
-$cfg->setConfigEntry('peer_problem_state_class', 'ProblemPeerState');
+$cfg->setConfigEntry('peer_problem_state_class', 'Hub\State\Peer;\ProblemPeerState');
 
 // CFG: PEER-CONNECTION-REFUSED-STATE-CLASS
-$cfg->setConfigEntry('peer_connection_refused_state_class', 'ConnectionRefusedPeerState');
+$cfg->setConfigEntry('peer_connection_refused_state_class', 'Hub\State\Peer\ConnectionRefusedPeerState');
 
 // CFG: PEER-CONNECTION-TIMED-OUT-STATE-CLASS
-$cfg->setConfigEntry('peer_connection_timed_out_state_class', 'ConnectionTimedOutPeerState');
+$cfg->setConfigEntry('peer_connection_timed_out_state_class', 'Hub\State\Peer\ConnectionTimedOutPeerState');
 
 // CFG: PEER-TRANSPORT-ENDPOINT-STATE-CLASS
-$cfg->setConfigEntry('peer_transport_endpoint_state_class', 'TransportEndpointGonePeerState');
+$cfg->setConfigEntry('peer_transport_endpoint_state_class', 'Hub\State\Peer\TransportEndpointGonePeerState');
 
 // CFG: PEER-OPERATION-ALREADY-PROGRESS-STATE-CLASS
-$cfg->setConfigEntry('peer_operation_already_progress_state_class', 'OperationAlreadyProgressPeerState');
+$cfg->setConfigEntry('peer_operation_already_progress_state_class', 'Hub\State\Peer\OperationAlreadyProgressPeerState');
 
 // CFG: PEER-NO-ROUTE-TO-HOST-STATE-CLASS
-$cfg->setConfigEntry('peer_no_route_to_host_state_class', 'NoRouteToHostPeerState');
+$cfg->setConfigEntry('peer_no_route_to_host_state_class', 'Hub\State\Peer\NoRouteToHostPeerState');
 
 ///////////////////////////////////////////////////////////////////////////////
 //                               DHT states
index 9ba4ce7186031c1c3a2fd4f46c52dd8b3ffd835c..68b7d2147dc79c6c8ac39ef7f2adef740201a317 100644 (file)
@@ -3,6 +3,7 @@
 namespace Hub\Generic;
 
 // Import application-specific stuff
+use Hub\Container\Socket\StorableSocket;
 
 // Inport frameworks stuff
 use CoreFramework\Generic\FrameworkInterface;
@@ -82,4 +83,19 @@ interface HubInterface extends FrameworkInterface {
         */
        function getSessionId ();
 
+       /**
+        * Setter for socket instance
+        *
+        * @param       $socketInstance A StorableSocket instance
+        * @return      void
+        */
+       function setSocketInstance (StorableSocket $socketInstance);
+
+       /**
+        * Getter for socket instance
+        *
+        * @return      $socketInstance An instance of a StorableSocket class
+        */
+       function getSocketInstance ();
+
 }
index bc02cb2b4295ab61d00cb07d9d247c247dc8415f..b217b079953b467a37cc698f76a9bd18773ff89e 100644 (file)
@@ -145,6 +145,14 @@ interface StorableSocket extends FrameworkInterface {
         */
        function enableSocketOutOfBandData ();
 
+       /**
+        * Connects to socket recipient (supplied in package data array
+        *
+        * @return      $result         Result from calling socket_connect()
+        * @throws      InvalidSocketException  If stored socket is invalid
+        */
+       function connectToSocketRecipient ();
+
        /**
         * Getter for socket procotol field
         *
@@ -152,6 +160,14 @@ interface StorableSocket extends FrameworkInterface {
         */
        function getSocketProtocol ();
 
+       /**
+        * Getter for socket recipient array element
+        *
+        * @return      $recipient      Recipient array element
+        * @throws      LogicException  If 'recipient' array element is not found
+        */
+       function getSocketRecipient ();
+
        /**
         * Checks whether the given Universal Node Locator matches with the one from package data
         *
@@ -227,6 +243,7 @@ interface StorableSocket extends FrameworkInterface {
         *
         * @return      void
         * @throws      SocketShutdownException         If the current socket could not be shut down
+        * @throws      BaseMethodCallException         If this method is possibly called twice
         */
        function doShutdown ();
 
@@ -238,4 +255,13 @@ interface StorableSocket extends FrameworkInterface {
         */
        function isValidConnectionType ($connectionType);
 
+       /**
+        * Clears last socket error
+        *
+        * @return      void
+        * @throws      InvalidSocketException  If stored socket is invalid
+        * @throws      BadMethodCallException  If no socket error was reported but method called
+        */
+       function clearLastSocketError ();
+
 }
index a5c805badc9b666e3e5e8d7e771cd26133448041..be49b0561c8acbac86a350fd6d700e6243d6c450 100644 (file)
@@ -47,20 +47,6 @@ interface ConnectionHelper extends HubHelper {
         */
        function doShutdown ();
 
-       /**
-        * Getter for port number
-        *
-        * @return      $port   The port number
-        */
-       function getConnectionPort ();
-
-       /**
-        * Getter for IP address
-        *
-        * @return      $address        The IP address
-        */
-       function getAddress ();
-
        /**
         * Static "getter" for this connection class' name
         *
index e6470884cec67c4f8a9f3a4af5a140b8f09964dd..93c4fd0e5be1a309c5bd500233cd46738aaf4bb5 100644 (file)
@@ -3,7 +3,6 @@
 namespace Hub\Listener;
 
 // Import application-specific stuff
-use Hub\Container\Socket\StorableSocket;
 use Hub\Generic\HubInterface;
 
 /**
@@ -80,19 +79,4 @@ interface Listenable extends HubInterface {
         */
        function getPoolInstance ();
 
-       /**
-        * Setter for socket instance
-        *
-        * @param       $socketInstance A StorableSocket instance
-        * @return      void
-        */
-       function setSocketInstance (StorableSocket $socketInstance);
-
-       /**
-        * Getter for socket instance
-        *
-        * @return      $socketInstance An instance of a StorableSocket class
-        */
-       function getSocketInstance ();
-
 }
index 39a89bd7a33742356ac82358116d38f048189d2a..e7eb24c230e1be33bbf81c40637ed192e68618b2 100644 (file)
@@ -59,14 +59,28 @@ interface LocateableNode extends HubInterface {
         */
        function getInternalUnl ();
 
+       /**
+        * Some "getter" for UNL address.
+        *
+        * @return      $unlAddress Address part of UNL
+        */
+       function getUnlAddress ();
+
        /**
         * Some "getter" for UNL port (if supported). If not supported, NULL is
         * being returned.
         *
-        * @return      $unlPort Port number of UNL
+        * @return      $unlPort        Port number of UNL or NULL
         */
        function getUnlPort ();
 
+       /**
+        * Getter for UNL data array
+        *
+        * @return      $unlData        An array with UNL data
+        */
+       function getUnlData ();
+
        /**
         * Parses given UNL string as UNL array
         *
diff --git a/core b/core
index fd5598626e163040b19bf8e153d4898a49038b23..e9e5242797adec674d25da4e641965f8d6dcbecd 160000 (submodule)
--- a/core
+++ b/core
@@ -1 +1 @@
-Subproject commit fd5598626e163040b19bf8e153d4898a49038b23
+Subproject commit e9e5242797adec674d25da4e641965f8d6dcbecd