* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
abstract class BaseHubSystem extends BaseFrameworkSystem implements HubInterface {
- // Exception codes
- const EXCEPTION_CHUNK_ALREADY_ASSEMBLED = 0x900;
- const EXCEPTION_ANNOUNCEMENT_NOT_ACCEPTED = 0x901;
- const EXCEPTION_INVALID_CONNECTION_TYPE = 0x902;
- const EXCEPTION_ANNOUNCEMENT_NOT_ATTEMPTED = 0x903;
- const EXCEPTION_BASE64_ENCODING_NOT_MODULO_4 = 0x904;
- const EXCEPTION_NODE_SESSION_ID_NOT_VERIFYING = 0x905;
- const EXCEPTION_REQUEST_NOT_ACCEPTED = 0x906;
- const EXCEPTION_DHT_BOOTSTRAP_NOT_ACCEPTED = 0x907;
- const EXCEPTION_MULTIPLE_MESSAGE_SENT = 0x908;
- const EXCEPTION_DHT_BOOTSTRAP_NOT_ATTEMPTED = 0x909;
- const EXCEPTION_INVALID_UNL = 0x90a;
- const EXCEPTION_INVALID_PRIVATE_KEY_HASH = 0x90b;
-
- // Message status codes
- const MESSAGE_STATUS_CODE_OKAY = 'OKAY';
-
/**
* Protected constructor
*
* Do not register non-existent nodes here. This is maybe fatal,
* caused by "stolen" session id and/or not matching address.
*/
- throw new NodeSessionIdVerficationException(array($this, $messageInstance), BaseHubSystem::EXCEPTION_NODE_SESSION_ID_NOT_VERIFYING);
+ throw new NodeSessionIdVerficationException(array($this, $messageInstance), DistributableNode::EXCEPTION_NODE_SESSION_ID_NOT_VERIFYING);
}
// Save last exception
use Org\Mxchange\CoreFramework\Generic\NullPointerException;
use Org\Mxchange\CoreFramework\Registry\Registerable;
+// Import SPL stuff
+use \InvalidArgumentException;
+
/**
* A UniversalNodeLocator discovery class
*
public function discoverUniversalNodeLocatorByConfiguredAddress ($configKey) {
// Debug message
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('UNL-DISCOVERY:configKey=' . $configKey . ' - CALLED!');
+ // Validate parameter
+ if (empty($configKey)) {
+ // Throw IAE
+ throw new InvalidArgumentException('Parameter "configKey" is empty');
+ } else if (($configKey != DiscoverableUniversalNodeLocator::UNL_TYPE_INTERNAL) && ($configKey != DiscoverableUniversalNodeLocator::UNL_TYPE_EXTERNAL)) {
+ // Can only be 'internal' or 'external'
+ throw new InvalidArgumentException(sprintf('configKey=%s is not expected.', $configKey));
+ }
// Is there cache?
if (!isset($GLOBALS[__METHOD__][$configKey])) {
- // Validate config key
- assert(($configKey == 'internal') || ($configKey == 'external'));
-
/*
* First get an instance from the configured hub communication protocol
* type (which is mostly TCP, so you get a TcpProtocolResolver here).
// Import application-specific stuff
use Org\Shipsimu\Hub\Container\Socket\StorableSocket;
-use Org\Shipsimu\Hub\Discovery\Recipient\BaseRecipientDiscovery;
+use Org\Shipsimu\Hub\Discovery\Locator\DiscoverableUniversalNodeLocator;
use Org\Shipsimu\Hub\Discovery\Protocol\ProtocolDiscovery;
+use Org\Shipsimu\Hub\Discovery\Recipient\BaseRecipientDiscovery;
use Org\Shipsimu\Hub\Discovery\Socket\DiscoverableSocket;
use Org\Shipsimu\Hub\Factory\Node\NodeObjectFactory;
use Org\Shipsimu\Hub\Factory\Socket\SocketFactory;
// Does the UNL validate?
if (!$protocolInstance->isValidUniversalNodeLocatorByPackageInstance($packageInstance)) {
// Not valid, throw exception
- throw new InvalidUnlException(array($this, $protocolInstance, $packageInstance), BaseHubSystem::EXCEPTION_INVALID_UNL);
+ throw new InvalidUnlException(array($this, $protocolInstance, $packageInstance), DiscoverableUniversalNodeLocator::EXCEPTION_INVALID_UNL);
}
// Get the listener instance
/* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('CHUNK-HANDLER: chunkSplits()=%d - CALLED!', count($chunkSplits)));
if (isset($this->finalPackageChunks[$chunkSplits[self::CHUNK_SPLITS_INDEX_SERIAL]])) {
// Then throw an exception
- throw new ChunkAlreadyAssembledException(array($this, $chunkSplits), self::EXCEPTION_CHUNK_ALREADY_ASSEMBLED);
+ throw new ChunkAlreadyAssembledException(array($this, $chunkSplits), HandleableChunks::EXCEPTION_CHUNK_ALREADY_ASSEMBLED);
}
// Add the chunk data (index 2) to the final array and use the serial number as index
// Import application-specific stuff
use Org\Shipsimu\Hub\Database\Frontend\Node\Dht\NodeDistributedHashTableDatabaseFrontend;
use Org\Shipsimu\Hub\Factory\Node\NodeObjectFactory;
-use Org\Shipsimu\Hub\Generic\BaseHubSystem;
use Org\Shipsimu\Hub\Handler\Message\BaseMessageHandler;
use Org\Shipsimu\Hub\Handler\Message\HandleableMessage;
use Org\Shipsimu\Hub\Network\Message\DeliverableMessage;
// Init array
$this->searchData = [
- XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS
+ XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_EXTERNAL_ADDRESS,
XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_INTERNAL_ADDRESS,
XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_NODE_STATUS,
XmlAnnouncementTemplateEngine::ANNOUNCEMENT_DATA_SESSION_ID,
* This node is not accepting announcements, then someone wants to
* announce his node to a non-bootstrap and non-master node.
*/
- throw new AnnouncementNotAcceptedException(array($this, $nodeInstance, $messageInstance), BaseHubSystem::EXCEPTION_ANNOUNCEMENT_NOT_ACCEPTED);
+ throw new AnnouncementNotAcceptedException(array($this, $nodeInstance, $messageInstance), HandleableMessage::EXCEPTION_ANNOUNCEMENT_NOT_ACCEPTED);
}
// Register the announcing node with this node
* This node has never announced itself, so it doesn't expect
* announcement answer messages.
*/
- throw new NoAnnouncementAttemptedException(array($this, $nodeInstance, $messageInstance), self::EXCEPTION_ANNOUNCEMENT_NOT_ATTEMPTED);
+ throw new NoAnnouncementAttemptedException(array($this, $nodeInstance, $messageInstance), HandleableMessage::EXCEPTION_ANNOUNCEMENT_NOT_ATTEMPTED);
}
// Register the announcing node with this node
* This DHT has never bootstrapped, so it doesn't expect
* announcement answer messages.
*/
- throw new NoDhtBootstrapAttemptedException(array($this, $dhtInstance, $messageInstance), self::EXCEPTION_DHT_BOOTSTRAP_NOT_ATTEMPTED);
+ throw new NoDhtBootstrapAttemptedException(array($this, $dhtInstance, $messageInstance), HandleableMessage::EXCEPTION_DHT_BOOTSTRAP_NOT_ATTEMPTED);
}
// Unfinished
* This node has never announced itself, so it doesn't expect
* request-node-list answer messages.
*/
- throw new NoRequestNodeListAttemptedException(array($this, $nodeInstance, $messageInstance), self::EXCEPTION_ANNOUNCEMENT_NOT_ATTEMPTED);
+ throw new NoRequestNodeListAttemptedException(array($this, $nodeInstance, $messageInstance), HandleableMessage::EXCEPTION_ANNOUNCEMENT_NOT_ATTEMPTED);
}
// Register the announcing node with this node
use Org\Shipsimu\Hub\Factory\Dht\DhtObjectFactory;
use Org\Shipsimu\Hub\Generic\BaseHubSystem;
use Org\Shipsimu\Hub\Handler\Data\BaseDataHandler;
+use Org\Shipsimu\Hub\Handler\Message\HandleableMessage;
use Org\Shipsimu\Hub\Network\Message\DeliverableMessage;
use Org\Shipsimu\Hub\Network\Receive\Receivable;
*/
protected function getTranslatedStatusFromLastException () {
// Default is all fine
- $statusCode = BaseHubSystem::MESSAGE_STATUS_CODE_OKAY;
+ $statusCode = HandleableMessage::MESSAGE_STATUS_CODE_OKAY;
// Is the last exception not NULL?
if ($this->getLastException() instanceof FrameworkException) {
/*
* This node is not accepting DHT bootstrap requests.
*/
- throw new DhtBootstrapNotAcceptedException(array($this, $messageInstance), self::EXCEPTION_DHT_BOOTSTRAP_NOT_ACCEPTED);
+ throw new DhtBootstrapNotAcceptedException(array($this, $messageInstance), HandleableMessage::EXCEPTION_DHT_BOOTSTRAP_NOT_ACCEPTED);
}
// Register the DHT bootstrap requesting node with this node
* This node is not accepting node list requests. Throw an
* exception to abort any further processing.
*/
- throw new RequestNotAcceptedException(array($this, $nodeInstance, $messageInstance), self::EXCEPTION_REQUEST_NOT_ACCEPTED);
+ throw new RequestNotAcceptedException(array($this, $nodeInstance, $messageInstance), HandleableMessage::EXCEPTION_REQUEST_NOT_ACCEPTED);
}
// Register the announcing node with this node
// Import application-specific stuff
use Org\Shipsimu\Hub\Container\Socket\StorableSocket;
use Org\Shipsimu\Hub\Database\Frontend\Node\Dht\NodeDistributedHashTableDatabaseFrontend;
+use Org\Shipsimu\Hub\Disovery\Locator\DiscoverableUniversalNodeLocator;
use Org\Shipsimu\Hub\Factory\Assembler\Package\PackageAssemblerFactory;
use Org\Shipsimu\Hub\Factory\Dht\DhtObjectFactory;
use Org\Shipsimu\Hub\Factory\Discovery\Package\PackageDiscoveryFactory;
throw new InvalidArgumentException('messageInstance does not contain senderId');
} elseif (empty($messageInstance->getSenderPrivateKeyHash())) {
// This needs fixing
- throw new InvalidPrivateKeyHashException(array($this, $senderData, 'empty hash in decodedData'), BaseHubSystem::EXCEPTION_INVALID_PRIVATE_KEY_HASH);
+ throw new InvalidPrivateKeyHashException(array($this, $senderData, 'empty hash in decodedData'), DiscoverableUniversalNodeLocator::EXCEPTION_INVALID_PRIVATE_KEY_HASH);
} elseif (!$this->isMessageContentHashValid($messageInstance)) {
// Is not valid, so throw an exception here
ApplicationEntryPoint::exitApplication(__METHOD__ . ':INVALID HASH! UNDER CONSTRUCTION!' . PHP_EOL);
throw new InvalidArgumentException('packageInstance does not contain senderId');
} elseif (empty($packageInstance->getSenderPrivateKeyHash())) {
// This needs fixing
- throw new InvalidPrivateKeyHashException(array($this, $senderData, 'empty hash in decodedData'), BaseHubSystem::EXCEPTION_INVALID_PRIVATE_KEY_HASH);
+ throw new InvalidPrivateKeyHashException(array($this, $senderData, 'empty hash in decodedData'), DiscoverableUniversalNodeLocator::EXCEPTION_INVALID_PRIVATE_KEY_HASH);
} elseif (!$this->isPackageContentHashValid($packageInstance)) {
// Is not valid, so throw an exception here
ApplicationEntryPoint::exitApplication(__METHOD__ . ':INVALID HASH! UNDER CONSTRUCTION!' . PHP_EOL);
use StorableSocketTrait;
// Exception codes
- const EXCEPTION_UNSUPPORTED_ERROR_HANDLER = 0x9100;
+ const EXCEPTION_UNSUPPORTED_ERROR_HANDLER = 0xf00;
/**
* Sent data in bytes
// Is the connection type valid?
if (!$socketInstance->isValidConnectionType($connectionType)) {
// Is not a valid connection type!
- throw new InvalidConnectionTypeException(array($this, $connectionType), self::EXCEPTION_INVALID_CONNECTION_TYPE);
+ throw new InvalidConnectionTypeException(array($this, $connectionType), StorableSocket::EXCEPTION_INVALID_CONNECTION_TYPE);
}
// Default is this peer's IP
// Import application-specific stuff
use Org\Shipsimu\Hub\Container\Socket\StorableSocket;
use Org\Shipsimu\Hub\Database\Frontend\Node\Information\NodeInformationDatabaseFrontend;
+use Org\Shipsimu\Hub\Discovery\Locator\DiscoverableUniversalNodeLocator;
use Org\Shipsimu\Hub\Factory\Network\Locator\UniversalNodeLocatorFactory;
use Org\Shipsimu\Hub\Node\Node;
use Org\Shipsimu\Hub\Resolver\Protocol\BaseProtocolResolver;
if (empty($address)) {
// Okay, then find it
switch ($configKey) {
- case 'external': // External IP
+ case DiscoverableUniversalNodeLocator::UNL_TYPE_EXTERNAL: // External IP
$address = ConsoleTools::determineExternalAddress();
break;
- case 'internal': // Internal IP
+ case DiscoverableUniversalNodeLocator::UNL_TYPE_INTERNAL: // Internal IP
$address = ConsoleTools::acquireSelfIPAddress();
break;
}
// Import application-specific stuff
use Org\Shipsimu\Hub\Generic\BaseHubSystem;
+use Org\Shipsimu\Hub\Handler\Message\HandleableMessage;
use Org\Shipsimu\Hub\Handler\Network\RawData\HandleableRawData;
// Import framework stuff
throw new InvalidArgumentException(sprintf('data=%s has different count of start/end markers set', $data));
} elseif (substr_count($data, HandleableRawData::STREAM_START_MARKER) > 1) {
// Please do it outside this method
- throw new MultipleMessageSentException(array($this, $data), BaseHubSystem::EXCEPTION_MULTIPLE_MESSAGE_SENT);
+ throw new MultipleMessageSentException(array($this, $data), HandleableMessage::EXCEPTION_MULTIPLE_MESSAGE_SENT);
}
// Remove both
// Can it be validated?
if ((strlen($data) % 4) != 0) {
// Length modulo 4 must be zero, else it is an invalid Base64 message
- throw new Base64EncodingModuloException(array($this, $data), BaseHubSystem::EXCEPTION_BASE64_ENCODING_NOT_MODULO_4);
+ throw new Base64EncodingModuloException(array($this, $data), HubInterface::EXCEPTION_BASE64_ENCODING_NOT_MODULO_4);
} elseif (!$this->isBase64Encoded($data)) {
// Is not a valid Base64-encoded message
- throw new Base64EncodingBadException(array($this, $data), BaseHubSystem::EXCEPTION_BASE64_BAD_ENCODING);
+ throw new Base64EncodingBadException(array($this, $data), HubInterface::EXCEPTION_BASE64_BAD_ENCODING);
} else {
// Decode the data with BASE64-encoding
$data = base64_decode($data);
// Import application-specific stuff
use Org\Shipsimu\Hub\Database\Frontend\Node\Dht\NodeDistributedHashTableDatabaseFrontend;
+use Org\Shipsimu\Hub\Discovery\Locator\DiscoverableUniversalNodeLocator;
use Org\Shipsimu\Hub\Factory\Dht\DhtObjectFactory;
use Org\Shipsimu\Hub\Factory\Node\NodeObjectFactory;
use Org\Shipsimu\Hub\Generic\BaseHubSystem;
public static function determineOwnExternalAddress () {
// Is the external_address config entry set?
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('HUB-TOOLS: CALLED!');
- if (isset(self::$cachedAddresses['external'])) {
+ if (isset(self::$cachedAddresses[DiscoverableUniversalNodeLocator::UNL_TYPE_EXTERNAL])) {
// Get entry from cache
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('HUB-TOOLS: Getting external address from cache ...');
- $unl = self::$cachedAddresses['external'];
+ $unl = self::$cachedAddresses[DiscoverableUniversalNodeLocator::UNL_TYPE_EXTERNAL];
} elseif (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('external_address') != '') {
// Use it as external address
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('HUB-TOOLS: Getting config entry external_address ...');
$unl = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('external_address');
- self::$cachedAddresses['external'] = $unl;
+ self::$cachedAddresses[DiscoverableUniversalNodeLocator::UNL_TYPE_EXTERNAL] = $unl;
} else {
// Determine own external address by connecting to home server at 188.138.90.169
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('HUB-TOOLS: Invoking self::determineExternalUniversalNodeLocator() ...');
$unl = self::determineExternalUniversalNodeLocator();
- self::$cachedAddresses['external'] = $unl;
+ self::$cachedAddresses[DiscoverableUniversalNodeLocator::UNL_TYPE_EXTERNAL] = $unl;
}
// Return it
public static function determineOwnInternalAddress () {
// Is the internal_address config entry set?
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('HUB-TOOLS: CALLED!');
- if (isset(self::$cachedAddresses['internal'])) {
+ if (isset(self::$cachedAddresses[DiscoverableUniversalNodeLocator::UNL_TYPE_INTERNAL])) {
// Get entry from cache
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('HUB-TOOLS: Getting internal address from cache ...');
- $unl = self::$cachedAddresses['internal'];
+ $unl = self::$cachedAddresses[DiscoverableUniversalNodeLocator::UNL_TYPE_INTERNAL];
} elseif (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('allow_publish_internal_address') == 'N') {
// Not allowed to publish internal address, so use external
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('HUB-TOOLS: Invoking self::determineOwnExternalAddress() as allow_publish_internal_address=N is set ...');
$unl = self::determineOwnExternalAddress();
- self::$cachedAddresses['internal'] = $unl;
+ self::$cachedAddresses[DiscoverableUniversalNodeLocator::UNL_TYPE_INTERNAL] = $unl;
} elseif (FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('internal_address') != '') {
// Use it as internal address
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('HUB-TOOLS: Getting config entry internal_address ...');
$unl = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('internal_address');
- self::$cachedAddresses['internal'] = $unl;
+ self::$cachedAddresses[DiscoverableUniversalNodeLocator::UNL_TYPE_INTERNAL] = $unl;
} else {
// Determine own internal address
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('HUB-TOOLS: Invoking self::determineInternalUniversalNodeLocator() ...');
$unl = self::determineInternalUniversalNodeLocator();
- self::$cachedAddresses['internal'] = $unl;
+ self::$cachedAddresses[DiscoverableUniversalNodeLocator::UNL_TYPE_INTERNAL] = $unl;
}
// Return it
$discoveryInstance = ObjectFactory::createObjectByConfiguredName('unl_discovery_class');
// 2) "Determine" it
- $unl = $discoveryInstance->discoverUniversalNodeLocatorByConfiguredAddress('internal');
+ $unl = $discoveryInstance->discoverUniversalNodeLocatorByConfiguredAddress(DiscoverableUniversalNodeLocator::UNL_TYPE_INTERNAL);
// Return it
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('HUB-TOOLS: unl=' . $unl . ' - EXIT!');
$discoveryInstance = ObjectFactory::createObjectByConfiguredName('unl_discovery_class');
// 2) "Determine" it
- $unl = $discoveryInstance->discoverUniversalNodeLocatorByConfiguredAddress('external');
+ $unl = $discoveryInstance->discoverUniversalNodeLocatorByConfiguredAddress(DiscoverableUniversalNodeLocator::UNL_TYPE_EXTERNAL);
// Return it
//* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('HUB-TOOLS: unl=' . $unl . ' - EXIT!');
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
interface HubInterface extends FrameworkInterface {
+ // Exception codes
+ const EXCEPTION_BASE64_ENCODING_NOT_MODULO_4 = 0x910;
+ const EXCEPTION_BASE64_BAD_ENCODING = 0x911;
}
*/
const CONNECTION_TYPE_SERVER = 'server';
+ // Exception codes
+ const EXCEPTION_INVALID_CONNECTION_TYPE = 0xd00;
+
/**
* Tries to bind to attached socket file
*
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
interface DiscoverableUniversalNodeLocator extends Discoverable {
+ // Exception constants
+ const EXCEPTION_INVALID_UNL = 0x920;
+ const EXCEPTION_INVALID_PRIVATE_KEY_HASH = 0x921;
+
+ // UNL address types
+ const UNL_TYPE_INTERNAL = 'internal';
+ const UNL_TYPE_EXTERNAL = 'external';
+
/**
* "Discovers" an instance of a LocateableNode class for given Node class
*
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
interface DistributableNode extends Distributable {
+ // Exception constants
+ const EXCEPTION_NODE_SESSION_ID_NOT_VERIFYING = 0xb00;
+
/**
* Finds a node locally by given session id
*
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
interface HandleableChunks extends Handleable, HubInterface {
+ // Exception codes
+ const EXCEPTION_CHUNK_ALREADY_ASSEMBLED = 0x900;
+
/**
* Adds all chunks if the last one verifies as a 'final chunk'.
*
+++ /dev/null
-<?php
-// Own namespace
-namespace Org\Shipsimu\Hub\Handler\Message;
-
-// Import application-specific stuff
-use Org\Shipsimu\Hub\Generic\HubInterface;
-use Org\Shipsimu\Hub\Network\Message\DeliverableMessage;
-use Org\Shipsimu\Hub\Network\Receive\Receivable;
-
-// Import framework stuff
-use Org\Mxchange\CoreFramework\Handler\DataSet\HandleableDataSet;
-
-/**
- * An interface for message handlers
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 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/>.
- */
-interface HandleableMessage extends HandleableDataSet, HubInterface {
- /**
- * Handles data array of the message
- *
- * @param $messageData An instance of a DeliverableMessage class
- * @param $handlerInstance An instance of a Receivable class
- * @return void
- */
- function handleMessageData (DeliverableMessage $messageInstance, Receivable $handlerInstance);
-
- /**
- * Posty-handles data array of the message
- *
- * @param $messageData An instance of a DeliverableMessage class
- * @param $handlerInstance An instance of a Receivable class
- * @return void
- */
- function postHandleMessageData (DeliverableMessage $messageInstance, Receivable $handlerInstance);
-
-}
--- /dev/null
+<?php
+// Own namespace
+namespace Org\Shipsimu\Hub\Handler\Message;
+
+// Import application-specific stuff
+use Org\Shipsimu\Hub\Generic\HubInterface;
+use Org\Shipsimu\Hub\Network\Message\DeliverableMessage;
+use Org\Shipsimu\Hub\Network\Receive\Receivable;
+
+// Import framework stuff
+use Org\Mxchange\CoreFramework\Handler\DataSet\HandleableDataSet;
+
+/**
+ * An interface for message handlers
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2022 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/>.
+ */
+interface HandleableMessage extends HandleableDataSet, HubInterface {
+ // Exception constants
+ const EXCEPTION_ANNOUNCEMENT_NOT_ACCEPTED = 0xa00;
+ const EXCEPTION_REQUEST_NOT_ACCEPTED = 0xa01;
+ const EXCEPTION_ANNOUNCEMENT_NOT_ATTEMPTED = 0xa02;
+ const EXCEPTION_DHT_BOOTSTRAP_NOT_ACCEPTED = 0xa03;
+ const EXCEPTION_MULTIPLE_MESSAGE_SENT = 0xa04;
+ const EXCEPTION_DHT_BOOTSTRAP_NOT_ATTEMPTED = 0xa05;
+
+ // Message status codes
+ const MESSAGE_STATUS_CODE_OKAY = 'OKAY';
+
+ /**
+ * Handles data array of the message
+ *
+ * @param $messageData An instance of a DeliverableMessage class
+ * @param $handlerInstance An instance of a Receivable class
+ * @return void
+ */
+ function handleMessageData (DeliverableMessage $messageInstance, Receivable $handlerInstance);
+
+ /**
+ * Posty-handles data array of the message
+ *
+ * @param $messageData An instance of a DeliverableMessage class
+ * @param $handlerInstance An instance of a Receivable class
+ * @return void
+ */
+ function postHandleMessageData (DeliverableMessage $messageInstance, Receivable $handlerInstance);
+
+}