]> git.mxchange.org Git - hub.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Wed, 2 Dec 2020 02:57:06 +0000 (03:57 +0100)
committerRoland Häder <roland@mxchange.org>
Wed, 2 Dec 2020 03:00:25 +0000 (04:00 +0100)
- introduced new trait StorableSocketTrait
- added missing methods to interface(s)
- updated core framework

Signed-off-by: Roland Häder <roland@mxchange.org>
20 files changed:
application/hub/classes/class_BaseHubSystem.php
application/hub/classes/container/class_BaseHubContainer.php
application/hub/classes/database/frontend/class_BaseHubDatabaseFrontend.php
application/hub/classes/handler/class_BaseHubHandler.php
application/hub/classes/handler/package/class_NetworkPackageHandler.php
application/hub/classes/helper/connection/ipv4/class_BaseIpV4ConnectionHelper.php
application/hub/classes/info/connection/class_ConnectionInfo.php
application/hub/classes/listener/class_BaseListener.php
application/hub/classes/listener/class_BaseListenerDecorator.php
application/hub/classes/nodes/class_BaseHubNode.php
application/hub/classes/package/assembler/class_PackageAssembler.php
application/hub/classes/streams/raw_data/input/class_RawDataInputStream.php
application/hub/classes/streams/raw_data/output/class_RawDataOutputStream.php
application/hub/interfaces/class_HubInterface.php
application/hub/interfaces/helper/connections/class_ConnectionHelper.php
application/hub/interfaces/listener/class_Listenable.php
application/hub/interfaces/nodes/class_Node.php
application/hub/interfaces/shareable/info/class_ShareableInfo.php
application/hub/traits/container/socket/class_StorableSocketTrait.php [new file with mode: 0644]
core

index 3e4c41e1cbf185e452e4ac21b03b4ff5433faf92..b1af3fa71828c6f7b74304c660348dbeebb3b389 100644 (file)
@@ -4,7 +4,6 @@ namespace Org\Shipsimu\Hub\Generic;
 
 // Import application-specific stuff
 use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
-use Org\Shipsimu\Hub\Container\Socket\StorableSocket;
 use Org\Shipsimu\Hub\Handler\Network\RawData\HandleableRawData;
 use Org\Shipsimu\Hub\Network\Delivery\Deliverable;
 
@@ -56,11 +55,6 @@ abstract class BaseHubSystem extends BaseFrameworkSystem implements HubInterface
         */
        const BOOTSTRAP_NODES_SEPARATOR = ';';
 
-       /**
-        * A StorableSocket instance
-        */
-       private $socketInstance = NULL;
-
        /**
         * Protected constructor
         *
@@ -72,129 +66,4 @@ abstract class BaseHubSystem extends BaseFrameworkSystem implements HubInterface
                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) {
-               // Trace message
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('HUB-SYSTEM: data()=%d - CALLED!', strlen($data)));
-
-               // Determine it
-               $isset = (
-                       (
-                               substr($data, 0, strlen(HandleableRawData::STREAM_START_MARKER)) == HandleableRawData::STREAM_START_MARKER
-                       ) && (
-                               substr($data, -1 * strlen(HandleableRawData::STREAM_END_MARKER), strlen(HandleableRawData::STREAM_END_MARKER)) == HandleableRawData::STREAM_END_MARKER
-                       )
-               );
-
-               // ... and return it
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('HUB-SYSTEM: isset=%d - EXIT!', intval($isset)));
-               return $isset;
-       }
-
-       /**
-        * Setter for node id
-        *
-        * @param       $nodeId         The new node id
-        * @return      void
-        */
-       protected final function setNodeId ($nodeId) {
-               // Set it config now
-               FrameworkBootstrap::getConfigurationInstance()->setConfigEntry('node_id', (string) $nodeId);
-       }
-
-       /**
-        * Getter for node id
-        *
-        * @return      $nodeId         Current node id
-        */
-       public final function getNodeId () {
-               // Get it from config
-               return FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('node_id');
-       }
-
-       /**
-        * Setter for private key
-        *
-        * @param       $privateKey             The new private key
-        * @return      void
-        */
-       protected final function setPrivateKey (string $privateKey) {
-               // Set it config now
-               FrameworkBootstrap::getConfigurationInstance()->setConfigEntry('private_key', (string) $privateKey);
-       }
-
-       /**
-        * Getter for private key
-        *
-        * @return      $privateKey             Current private key
-        */
-       public final function getPrivateKey () {
-               // Get it from config
-               return FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('private_key');
-       }
-
-       /**
-        * Setter for private key hash
-        *
-        * @param       $privateKeyHash         The new private key hash
-        * @return      void
-        */
-       protected final function setNodePrivateKeyHash (string $privateKeyHash) {
-               // Set it config now
-               FrameworkBootstrap::getConfigurationInstance()->setConfigEntry('private_key_hash', $privateKeyHash);
-       }
-
-       /**
-        * Getter for private key hash
-        *
-        * @return      $privateKeyHash         Current private key hash
-        */
-       public final function getNodePrivateKeyHash () {
-               // Get it from config
-               return FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('private_key_hash');
-       }
-
-       /**
-        * Setter for session id
-        *
-        * @param       $sessionId      The new session id
-        * @return      void
-        */
-       protected final function setSessionId (string $sessionId) {
-               FrameworkBootstrap::getConfigurationInstance()->setConfigEntry('session_id', $sessionId);
-       }
-
-       /**
-        * Getter for session id
-        *
-        * @return      $sessionId      Current session id
-        */
-       public final function getSessionId () {
-               return FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('session_id');
-       }
-
-       /**
-        * 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 3e842fc44f6e1572660577d224e92d479a81795e..1a3a29582bdf1d17c4fe02312db700def328ecf0 100644 (file)
@@ -3,8 +3,6 @@
 namespace Org\Shipsimu\Hub\Container;
 
 // Import application-specific stuff
-use Org\Shipsimu\Hub\Container\Socket\StorableSocket;
-use Org\Shipsimu\Hub\Handler\Network\RawData\HandleableRawData;
 use Org\Shipsimu\Hub\Generic\HubInterface;
 use Org\Shipsimu\Hub\Listener\Listenable;
 use Org\Shipsimu\Hub\Pool\Poolable;
@@ -45,11 +43,6 @@ abstract class BaseHubContainer extends BaseContainer implements HubInterface {
         */
        private $listenerPoolInstance = NULL;
 
-       /**
-        * A StorableSocket instance
-        */
-       private $socketInstance = NULL;
-
        /**
         * Protected constructor
         *
@@ -62,28 +55,6 @@ abstract class BaseHubContainer extends BaseContainer implements HubInterface {
                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
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-HUB-CONTAINER: data()=%d - CALLED!', strlen($data)));
-               $isset = (
-                       (
-                               substr($data, 0, strlen(HandleableRawData::STREAM_START_MARKER)) == HandleableRawData::STREAM_START_MARKER
-                       ) && (
-                               substr($data, -1 * strlen(HandleableRawData::STREAM_END_MARKER), strlen(HandleableRawData::STREAM_END_MARKER)) == HandleableRawData::STREAM_END_MARKER
-                       )
-               );
-
-               // ... and return it
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-HUB-CONTAINER: isset=%d - EXIT!', intval($isset)));
-               return $isset;
-       }
-
        /**
         * Setter for listener pool instance
         *
@@ -103,91 +74,6 @@ abstract class BaseHubContainer extends BaseContainer implements HubInterface {
                return $this->listenerPoolInstance;
        }
 
-       /**
-        * 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 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 setNodePrivateKeyHash ($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 getNodePrivateKeyHash () {
-               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);
-       }
-
        /**
         * Setter for listener instance
         *
index ef72ac266a64e3f94c5ae6620f0002c818341bad..3b678b9b3fa0b26f17d7c1230711bab86dbaad71 100644 (file)
@@ -3,8 +3,6 @@
 namespace Org\Shipsimu\Hub\Database\Frontend;
 
 // Import application-specific stuff
-use Org\Shipsimu\Hub\Container\Socket\StorableSocket;
-use Org\Shipsimu\Hub\Handler\Network\RawData\HandleableRawData;
 use Org\Shipsimu\Hub\Generic\HubInterface;
 use Org\Shipsimu\Hub\Node\Node;
 use Org\Shipsimu\Hub\Pool\Poolable;
@@ -46,11 +44,6 @@ abstract class BaseHubDatabaseFrontend extends BaseDatabaseFrontend implements H
         */
        private $listenerPoolInstance = NULL;
 
-       /**
-        * A StorableSocket instance
-        */
-       private $socketInstance = NULL;
-
        /**
         * Node instance
         */
@@ -67,23 +60,6 @@ abstract class BaseHubDatabaseFrontend extends BaseDatabaseFrontend implements H
                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) {
-               // Trace message
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('HUB-DATABASE-WRAPPER: data()=%d - CALLED!', strlen($data)));
-
-               // Determine it
-               $isset = ((substr($data, 0, strlen(HandleableRawData::STREAM_START_MARKER)) == HandleableRawData::STREAM_START_MARKER) && (substr($data, -1 * strlen(HandleableRawData::STREAM_END_MARKER), strlen(HandleableRawData::STREAM_END_MARKER)) == HandleableRawData::STREAM_END_MARKER));
-
-               // ... and return it
-               return $isset;
-       }
-
        /**
         * Setter for listener pool instance
         *
@@ -103,91 +79,6 @@ abstract class BaseHubDatabaseFrontend extends BaseDatabaseFrontend implements H
                return $this->listenerPoolInstance;
        }
 
-       /**
-        * 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 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 setNodePrivateKeyHash ($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 getNodePrivateKeyHash () {
-               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);
-       }
-
        /**
         * Setter for listener instance
         *
index d87e3e39aa93f0b71a07f5c5861557072b7134a2..eef5130f4ec3fb4a5b347304dadc49781ddd2c5c 100644 (file)
@@ -3,8 +3,6 @@
 namespace Org\Shipsimu\Hub\Handler;
 
 // Import application-specific stuff
-use Org\Shipsimu\Hub\Container\Socket\StorableSocket;
-use Org\Shipsimu\Hub\Handler\Network\RawData\HandleableRawData;
 use Org\Shipsimu\Hub\Generic\HubInterface;
 use Org\Shipsimu\Hub\Listener\Listenable;
 use Org\Shipsimu\Hub\Locator\Node\LocateableNode;
@@ -57,11 +55,6 @@ abstract class BaseHubHandler extends BaseHandler implements Handleable, HubInte
         */
        private $nodeInstance = NULL;
 
-       /**
-        * A StorableSocket instance
-        */
-       private $socketInstance = NULL;
-
        /**
         * An instance of a LocateableNode class
         */
@@ -93,24 +86,6 @@ abstract class BaseHubHandler extends BaseHandler implements Handleable, HubInte
                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) {
-               // Trace message
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('HUB-HANDLER: data(%d)=%s - CALLED!', strlen($data), $data));
-
-               // Determine it
-               $isset = ((substr($data, 0, strlen(HandleableRawData::STREAM_START_MARKER)) == HandleableRawData::STREAM_START_MARKER) && (substr($data, -1 * strlen(HandleableRawData::STREAM_END_MARKER), strlen(HandleableRawData::STREAM_END_MARKER)) == HandleableRawData::STREAM_END_MARKER));
-
-               // ... and return it
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('HUB-HANDLER: isset=%d - EXIT!', intval($isset)));
-               return $isset;
-       }
-
        /**
         * Setter for listener pool instance
         *
@@ -130,25 +105,6 @@ abstract class BaseHubHandler extends BaseHandler implements Handleable, HubInte
                return $this->listenerPoolInstance;
        }
 
-       /**
-        * 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
         *
@@ -170,72 +126,6 @@ abstract class BaseHubHandler extends BaseHandler implements Handleable, HubInte
                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 setNodePrivateKeyHash ($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 getNodePrivateKeyHash () {
-               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);
-       }
-
        /**
         * Setter for listener instance
         *
index a338aecaa8a1eb6752148f299f5dc8b52d7f4f8a..3e6d1c5e15ce2c6414b37f99fd9242105d7efd5a 100644 (file)
@@ -16,7 +16,6 @@ use Org\Shipsimu\Hub\Factory\Network\Locator\UniversalNodeLocatorFactory;
 use Org\Shipsimu\Hub\Factory\Node\NodeObjectFactory;
 use Org\Shipsimu\Hub\Generic\BaseHubSystem;
 use Org\Shipsimu\Hub\Handler\BaseHubHandler;
-use Org\Shipsimu\Hub\Handler\Network\RawData\HandleableRawData;
 use Org\Shipsimu\Hub\Helper\Connection\ConnectionHelper;
 use Org\Shipsimu\Hub\Helper\HubHelper;
 use Org\Shipsimu\Hub\Information\ShareableInfo;
@@ -572,6 +571,7 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei
        public function getHashFromPackageSessionId (DeliverablePackage $packageInstance) {
                // Is session id set?
                /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-HANDLER: packageInstance=%s - CALLED!', $packageInstance->__toString()));
+               /* DEBUG-DIE: */ die(sprintf('[%s:%d]: packageInstance=%s', __METHOD__, __LINE__, print_r($packageInstance, TRUE)));
                if (empty($packageInstance->getSessionId())) {
                        // Throw exception
                        throw new InvalidArgumentException('packageInstance has no sessionId set.');
index 853fc73abffec2972bf8b22ceb49eb3d13884c7c..407b84537ca362650c6511ebed88cd251b5dd681 100644 (file)
@@ -6,6 +6,7 @@ namespace Org\Shipsimu\Hub\Helper\Connection\Network\IpV4;
 use Org\Shipsimu\Hub\Factory\State\Peer\PeerStateFactory;
 use Org\Shipsimu\Hub\Helper\Connection\BaseConnectionHelper;
 use Org\Shipsimu\Hub\Locator\Node\LocateableNode;
+use Org\Shipsimu\Hub\Traits\Container\Socket\StorableSocketTrait;
 
 // Import framework stuff
 use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
@@ -35,6 +36,9 @@ use Org\Mxchange\CoreFramework\Handler\Handleable;
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
 abstract class BaseIpV4ConnectionHelper extends BaseConnectionHelper {
+       // Load traits
+       use StorableSocketTrait;
+
        /**
         * Name of used protocol
         */
index b71b77256800d0508b1852f3e4ef653d287f292d..aaa0e308b13d0f1cc7fe49ae9102ee38dc8c554a 100644 (file)
@@ -9,6 +9,7 @@ use Org\Shipsimu\Hub\Information\BaseInfo;
 use Org\Shipsimu\Hub\Information\ShareableInfo;
 use Org\Shipsimu\Hub\Listener\Listenable;
 use Org\Shipsimu\Hub\Locator\Node\LocateableNode;
+use Org\Shipsimu\Hub\Traits\Container\Socket\StorableSocketTrait;
 
 // Import framework stuff
 use Org\Mxchange\CoreFramework\Registry\Registerable;
@@ -40,6 +41,9 @@ use \InvalidArgumentException;
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 class ConnectionInfo extends BaseInfo implements ShareableInfo, Registerable {
+       // Load traits
+       use StorableSocketTrait;
+
        /**
         * Listener instance
         */
index b0803415bd15e15105f5943fbc9deaed88b41f25..3d27b7a29207561f4948d0a76044c1db1bc8d296 100644 (file)
@@ -14,6 +14,7 @@ use Org\Shipsimu\Hub\Information\ShareableInfo;
 use Org\Shipsimu\Hub\Network\Package\DeliverablePackage;
 use Org\Shipsimu\Hub\Pool\Peer\PoolablePeer;
 use Org\Shipsimu\Hub\Pool\Poolable;
+use Org\Shipsimu\Hub\Traits\Container\Socket\StorableSocketTrait;
 
 // Import framework stuff
 use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
@@ -57,6 +58,7 @@ use \LogicException;
 abstract class BaseListener extends BaseHubSystem implements Visitable {
        // Load traits
        use IteratorTrait;
+       use StorableSocketTrait;
 
        // Exception code constants
        const EXCEPTION_SOCKET_ALREADY_REGISTERED        = 0xa01;
index 69c9f54d22d546b5df80b10dae6f8258522c26dd..08384f31afeaa671a4988ed81ab4fe9e11e422dd 100644 (file)
@@ -224,61 +224,6 @@ abstract class BaseListenerDecorator extends BaseDecorator implements Visitable
                return $this->socketInstance;
        }
 
-       /**
-        * Checks whether start/end marker are set
-        *
-        * @param       $data   Data to be checked
-        * @return      $isset  Whether start/end marker are set
-        */
-       public function ifStartEndMarkersSet ($data) {
-               $this->partialSub('Please implement this method.');
-       }
-
-       /**
-        * Getter for listener pool instance
-        *
-        * @return      $listenerPoolInstance   Our current listener pool instance
-        */
-       public function getListenerPoolInstance () {
-               $this->partialSub('Please implement this method.');
-       }
-
-       /**
-        * Getter for node id
-        *
-        * @return      $nodeId         Current node id
-        */
-       public function getNodeId () {
-               $this->partialSub('Please implement this method.');
-       }
-
-       /**
-        * Getter for private key
-        *
-        * @return      $privateKey             Current private key
-        */
-       public function getPrivateKey () {
-               $this->partialSub('Please implement this method.');
-       }
-
-       /**
-        * Getter for private key hash
-        *
-        * @return      $privateKeyHash         Current private key hash
-        */
-       public function getNodePrivateKeyHash () {
-               $this->partialSub('Please implement this method.');
-       }
-
-       /**
-        * Getter for session id
-        *
-        * @return      $sessionId      Current session id
-        */
-       public function getSessionId () {
-               $this->partialSub('Please implement this method.');
-       }
-
        /**
         * Setter for listener instance
         *
index 180bd612fd720ac70a2178ae9ca2f6fd2705beb2..765b46814a2f3280373e267b5a07d51c35e1152e 100644 (file)
@@ -112,6 +112,26 @@ abstract class BaseHubNode extends BaseHubSystem implements Updateable, AddableC
         */
        private $searchInstance = NULL;
 
+       /**
+        * Node id
+        */
+       private $nodeId = 'invalid';
+
+       /**
+        * Private key
+        */
+       private $privateKey = 'invalid';
+
+       /**
+        * Node's private-key hash
+        */
+       private $nodePrivateKeyHash = 'invalid';
+
+       /**
+        * Session id
+        */
+       private $sessionId = 'invalid';
+
        /**
         * Protected constructor
         *
@@ -677,6 +697,141 @@ abstract class BaseHubNode extends BaseHubSystem implements Updateable, AddableC
                $this->isActive = $isActive;
        }
 
+       /**
+        * Enables whether this node accepts announcements
+        *
+        * @param       $acceptAnnouncements    Whether this node accepts announcements (default: TRUE)
+        * @return      void
+        */
+       protected final function enableAcceptingAnnouncements (bool $acceptAnnouncements = TRUE) {
+               $this->acceptAnnouncements = $acceptAnnouncements;
+       }
+
+       /**
+        * Enables whether this node accepts DHT bootstrap requests
+        *
+        * @param       $acceptDhtBootstrap     Whether this node accepts DHT bootstrap requests (default: TRUE)
+        * @return      void
+        */
+       public final function enableAcceptDhtBootstrap (bool $acceptDhtBootstrap = TRUE) {
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NODE: Enabling DHT bootstrap requests ...');
+               $this->acceptDhtBootstrap = $acceptDhtBootstrap;
+       }
+
+       /**
+        * 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 search instance
+        *
+        * @param       $searchInstance         Searchable criteria instance
+        * @return      void
+        */
+       public final function setSearchInstance (LocalSearchCriteria $searchInstance) {
+               $this->searchInstance = $searchInstance;
+       }
+
+       /**
+        * Getter for search instance
+        *
+        * @return      $searchInstance         Searchable criteria instance
+        */
+       public final function getSearchInstance () {
+               return $this->searchInstance;
+       }
+
+       /**
+        * Setter for node id
+        *
+        * @param       $nodeId         The new node id
+        * @return      void
+        */
+       protected final function setNodeId (string $nodeId) {
+               $this->nodeId = $nodeId;
+       }
+
+       /**
+        * Getter for node id
+        *
+        * @return      $nodeId         Current node id
+        */
+       public final function getNodeId () {
+               return $this->nodeId;
+       }
+
+       /**
+        * Setter for private key
+        *
+        * @param       $privateKey             The new private key
+        * @return      void
+        */
+       protected final function setPrivateKey (string $privateKey) {
+               $this->privateKey = $privateKey;
+       }
+
+       /**
+        * Getter for private key
+        *
+        * @return      $privateKey             Current private key
+        */
+       public final function getPrivateKey () {
+               return $this->privateKey;
+       }
+
+       /**
+        * Setter for private key hash
+        *
+        * @param       $nodePrivateKeyHash             The new private key hash
+        * @return      void
+        */
+       protected final function setNodePrivateKeyHash (string $nodePrivateKeyHash) {
+               $this->nodePrivateKeyHash = $nodePrivateKeyHash;
+       }
+
+       /**
+        * Getter for private key hash
+        *
+        * @return      $privateKeyHash         Current private key hash
+        */
+       public final function getNodePrivateKeyHash () {
+               return $this->nodePrivateKeyHash;
+       }
+
+       /**
+        * Setter for session id
+        *
+        * @param       $sessionId      The new session id
+        * @return      void
+        */
+       protected final function setSessionId (string $sessionId) {
+               $this->sessionId = $sessionId;
+       }
+
+       /**
+        * Getter for session id
+        *
+        * @return      $sessionId      Current session id
+        */
+       public final function getSessionId () {
+               return $this->sessionId;
+       }
+
        /**
         * Checks whether this node accepts announcements
         *
@@ -743,27 +898,6 @@ abstract class BaseHubNode extends BaseHubSystem implements Updateable, AddableC
                return $hasAnnouncementCompleted;
        }
 
-       /**
-        * Enables whether this node accepts announcements
-        *
-        * @param       $acceptAnnouncements    Whether this node accepts announcements (default: TRUE)
-        * @return      void
-        */
-       protected final function enableAcceptingAnnouncements (bool $acceptAnnouncements = TRUE) {
-               $this->acceptAnnouncements = $acceptAnnouncements;
-       }
-
-       /**
-        * Enables whether this node accepts DHT bootstrap requests
-        *
-        * @param       $acceptDhtBootstrap     Whether this node accepts DHT bootstrap requests (default: TRUE)
-        * @return      void
-        */
-       public final function enableAcceptDhtBootstrap (bool $acceptDhtBootstrap = TRUE) {
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NODE: Enabling DHT bootstrap requests ...');
-               $this->acceptDhtBootstrap = $acceptDhtBootstrap;
-       }
-
        /**
         * Checks wether this node is accepting node-list requests
         *
@@ -908,42 +1042,4 @@ abstract class BaseHubNode extends BaseHubSystem implements Updateable, AddableC
                return $nodeData;
        }
 
-       /**
-        * 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 search instance
-        *
-        * @param       $searchInstance         Searchable criteria instance
-        * @return      void
-        */
-       public final function setSearchInstance (LocalSearchCriteria $searchInstance) {
-               $this->searchInstance = $searchInstance;
-       }
-
-       /**
-        * Getter for search instance
-        *
-        * @return      $searchInstance         Searchable criteria instance
-        */
-       public final function getSearchInstance () {
-               return $this->searchInstance;
-       }
-
 }
index 8bcdfceb6d1c11b19f22649fc9758863198daf7b..14704afd0928bbac3648020eb6aab50eb7938dfd 100644 (file)
@@ -440,4 +440,28 @@ class PackageAssembler extends BaseHubSystem implements Assembler, Registerable,
                /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-ASSEMBLER: EXIT!');
        }
 
+       /**
+        * Checks whether start/end marker are set
+        *
+        * @param       $data   Data to be checked
+        * @return      $isset  Whether start/end marker are set
+        */
+       private function ifStartEndMarkersSet (string $data) {
+               // Trace message
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('PACKAGE-ASSEMBLER: data()=%d - CALLED!', strlen($data)));
+
+               // Determine it
+               $isset = (
+                       (
+                               substr($data, 0, strlen(HandleableRawData::STREAM_START_MARKER)) == HandleableRawData::STREAM_START_MARKER
+                       ) && (
+                               substr($data, -1 * strlen(HandleableRawData::STREAM_END_MARKER), strlen(HandleableRawData::STREAM_END_MARKER)) == HandleableRawData::STREAM_END_MARKER
+                       )
+               );
+
+               // ... and return it
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('PACKAGE-ASSEMBLER: isset=%d - EXIT!', intval($isset)));
+               return $isset;
+       }
+
 }
index 1108b6425c316b4e0fe9d4dc34b0222c74047401..e4f8546de0afb72654a195edce7002fddd31bc8d 100644 (file)
@@ -71,7 +71,7 @@ class RawDataInputStream extends BaseStream implements InputStream {
         * @throws      Base64EncodingBadException              If the data contains characters which are not in the "alphabet" of BASE64 messages.
         * @throws      MultipleMessageSentException    If the sender has sent two messages and both end up here
         */
-       public function streamData ($data) {
+       public function streamData (string $data) {
                // Debug message
                /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('RAW-INPUT-STREAM: data(' . strlen($data) . ')=' . $data . ' - CALLED!');
 
@@ -109,4 +109,28 @@ class RawDataInputStream extends BaseStream implements InputStream {
                return $data;
        }
 
+       /**
+        * Checks whether start/end marker are set
+        *
+        * @param       $data   Data to be checked
+        * @return      $isset  Whether start/end marker are set
+        */
+       private function ifStartEndMarkersSet (string $data) {
+               // Trace message
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('RAW-DATA-INPUT-STREAM: data()=%d - CALLED!', strlen($data)));
+
+               // Determine it
+               $isset = (
+                       (
+                               substr($data, 0, strlen(HandleableRawData::STREAM_START_MARKER)) == HandleableRawData::STREAM_START_MARKER
+                       ) && (
+                               substr($data, -1 * strlen(HandleableRawData::STREAM_END_MARKER), strlen(HandleableRawData::STREAM_END_MARKER)) == HandleableRawData::STREAM_END_MARKER
+                       )
+               );
+
+               // ... and return it
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('RAW-DATA-INPUT-STREAM: isset=%d - EXIT!', intval($isset)));
+               return $isset;
+       }
+
 }
index 8ea061fa4a1a017f7006df6b996e1889d9e6a1c9..68a4243c9afd0d912b8e27427ea067dec2bef2a0 100644 (file)
@@ -61,7 +61,7 @@ class RawDataOutputStream extends BaseStream implements OutputStream {
         * @param       $data   The data (string mostly) to "stream"
         * @return      $data   The data (string mostly) to "stream"
         */
-       public function streamData ($data) {
+       public function streamData (string $data) {
                // Trace message
                /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('RAW-OUTPUT-STREAM: data()=%d - CALLED!', strlen($data)));
 
index 0e856696b4e50bb5d15f31f1dc7da92bace821b9..e18dde28a8e749d6a839e9260f2eb62b674a30b9 100644 (file)
@@ -33,55 +33,4 @@ use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
  */
 interface HubInterface extends FrameworkInterface {
 
-       /**
-        * Checks whether start/end marker are set
-        *
-        * @param       $data   Data to be checked
-        * @return      $isset  Whether start/end marker are set
-        */
-       function ifStartEndMarkersSet ($data);
-
-       /**
-        * Getter for node id
-        *
-        * @return      $nodeId         Current node id
-        */
-       function getNodeId ();
-
-       /**
-        * Getter for private key
-        *
-        * @return      $privateKey             Current private key
-        */
-       function getPrivateKey ();
-
-       /**
-        * Getter for private key hash
-        *
-        * @return      $privateKeyHash         Current private key hash
-        */
-       function getNodePrivateKeyHash ();
-
-       /**
-        * Getter for session id
-        *
-        * @return      $sessionId      Current session id
-        */
-       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 fe65e72e6590345a687e4303899d9760a4742373..e343631c59cf4ab20ba8693844015bac1a121279 100644 (file)
@@ -56,4 +56,19 @@ interface ConnectionHelper extends HubHelper {
         */
        function isShuttedDown ();
 
+       /**
+        * 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 7ec1368ca5e038f0bced6d963b2ef1540f3ea3a1..bb475d7e591dfbb7675f341efb6dfb545b2da1a6 100644 (file)
@@ -3,6 +3,7 @@
 namespace Org\Shipsimu\Hub\Listener;
 
 // Import application-specific stuff
+use Org\Shipsimu\Hub\Container\Socket\StorableSocket;
 use Org\Shipsimu\Hub\Generic\HubInterface;
 use Org\Shipsimu\Hub\Network\Package\DeliverablePackage;
 
@@ -80,4 +81,19 @@ 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 ae1a1210c0cc6b8edc3fdff9fa0323e99adbb0d2..b736abbf9a000891b3841710ee9c4190a6c77500 100644 (file)
@@ -218,4 +218,32 @@ interface Node extends FrameworkInterface {
         */
        function getSearchInstance ();
 
+       /**
+        * Getter for node id
+        *
+        * @return      $nodeId         Current node id
+        */
+       function getNodeId ();
+
+       /**
+        * Getter for private key
+        *
+        * @return      $privateKey             Current private key
+        */
+       function getPrivateKey ();
+
+       /**
+        * Getter for private key hash
+        *
+        * @return      $privateKeyHash         Current private key hash
+        */
+       function getNodePrivateKeyHash ();
+
+       /**
+        * Getter for session id
+        *
+        * @return      $sessionId      Current session id
+        */
+       function getSessionId ();
+
 }
index b48d8f2dc478eabdd910a8f11b631046cca7d0ab..314ac9d30428f77a629b10db47cc2e18a02b218c 100644 (file)
@@ -66,4 +66,19 @@ interface ShareableInfo extends HubInterface {
         */
        function getConnectionType ();
 
+       /**
+        * 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 ();
+
 }
diff --git a/application/hub/traits/container/socket/class_StorableSocketTrait.php b/application/hub/traits/container/socket/class_StorableSocketTrait.php
new file mode 100644 (file)
index 0000000..146673b
--- /dev/null
@@ -0,0 +1,55 @@
+<?php
+// Own namespace
+namespace Org\Shipsimu\Hub\Traits\Container\Socket;
+
+// Load application-specific stuff
+use Org\Shipsimu\Hub\Container\Socket\StorableSocket;
+
+/**
+ * A trait for a storable socket
+ *
+ * @author             Roland Haeder <webmaster@shipsimu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2018 Hub Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.shipsimu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+trait StorableSocketTrait {
+       /**
+        * A StorableSocket instance
+        */
+       private $socketInstance = NULL;
+
+       /**
+        * 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;
+       }
+
+}
diff --git a/core b/core
index 0ab475e77c70b60e323a87b97a73c39a695c6c13..8b3d5574973066ee9e99759f283005ca0c8d519b 160000 (submodule)
--- a/core
+++ b/core
@@ -1 +1 @@
-Subproject commit 0ab475e77c70b60e323a87b97a73c39a695c6c13
+Subproject commit 8b3d5574973066ee9e99759f283005ca0c8d519b