// 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;
*/
const BOOTSTRAP_NODES_SEPARATOR = ';';
- /**
- * A StorableSocket instance
- */
- private $socketInstance = NULL;
-
/**
* Protected 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) {
- // 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;
- }
-
}
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;
*/
private $listenerPoolInstance = NULL;
- /**
- * A StorableSocket instance
- */
- private $socketInstance = NULL;
-
/**
* Protected 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
- /* 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
*
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
*
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;
*/
private $listenerPoolInstance = NULL;
- /**
- * A StorableSocket instance
- */
- private $socketInstance = NULL;
-
/**
* Node instance
*/
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
*
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
*
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;
*/
private $nodeInstance = NULL;
- /**
- * A StorableSocket instance
- */
- private $socketInstance = NULL;
-
/**
* An instance of a LocateableNode class
*/
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
*
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
*
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
*
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;
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.');
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;
* 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
*/
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;
* 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
*/
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;
abstract class BaseListener extends BaseHubSystem implements Visitable {
// Load traits
use IteratorTrait;
+ use StorableSocketTrait;
// Exception code constants
const EXCEPTION_SOCKET_ALREADY_REGISTERED = 0xa01;
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
*
*/
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
*
$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
*
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
*
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;
- }
-
}
/* 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;
+ }
+
}
* @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!');
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;
+ }
+
}
* @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)));
*/
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 ();
-
}
*/
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 ();
+
}
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;
*/
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 ();
+
}
*/
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 ();
+
}
*/
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 ();
+
}
--- /dev/null
+<?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;
+ }
+
+}
-Subproject commit 0ab475e77c70b60e323a87b97a73c39a695c6c13
+Subproject commit 8b3d5574973066ee9e99759f283005ca0c8d519b