From: Roland Häder Date: Fri, 21 Aug 2020 16:48:39 +0000 (+0200) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=6ee059cc5885e372c1a5860449fe969f47553f21;p=hub.git Continued: - Added $socketFile and $socketType properties to PackageData class - moved delivery/receiving classes/interfaces to proper packages Signed-off-by: Roland Häder --- diff --git a/application/hub/classes/class_BaseHubSystem.php b/application/hub/classes/class_BaseHubSystem.php index 89c498073..92e0ac5ba 100644 --- a/application/hub/classes/class_BaseHubSystem.php +++ b/application/hub/classes/class_BaseHubSystem.php @@ -12,10 +12,10 @@ use Org\Shipsimu\Hub\Information\ShareableInfo; use Org\Shipsimu\Hub\Listener\BaseListener; use Org\Shipsimu\Hub\Listener\Listenable; use Org\Shipsimu\Hub\Locator\Node\LocateableNode; -use Org\Shipsimu\Hub\Network\Deliver\Deliverable; -use Org\Shipsimu\Hub\Network\Package\Assembler\Assembler; +use Org\Shipsimu\Hub\Network\Delivery\Deliverable; +use Org\Shipsimu\Hub\Network\Package\Receiver\Assembler\Assembler; use Org\Shipsimu\Hub\Network\Package\DeliverablePackage; -use Org\Shipsimu\Hub\Network\Package\Fragment\Fragmentable; +use Org\Shipsimu\Hub\Network\Package\Delivery\Fragment\Fragmentable; use Org\Shipsimu\Hub\Network\Receive\Receivable; use Org\Shipsimu\Hub\Pool\Poolable; diff --git a/application/hub/classes/container/socket/class_SocketContainer.php b/application/hub/classes/container/socket/class_SocketContainer.php index fc57d7338..266af0e0e 100644 --- a/application/hub/classes/container/socket/class_SocketContainer.php +++ b/application/hub/classes/container/socket/class_SocketContainer.php @@ -115,8 +115,8 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita $socketInstance->setSocketProtocol($socketProtocol); // Set content/hash to null - $packageInstance->setContent(NULL); - $packageInstance->setHash(NULL); + $packageInstance->setPackageContent(NULL); + $packageInstance->setContentHash(NULL); // Set the resource ... $socketInstance->setSocketResource($socketResource); diff --git a/application/hub/classes/factories/socket/class_SocketFactory.php b/application/hub/classes/factories/socket/class_SocketFactory.php index ac6a9d1c2..46f99b17f 100644 --- a/application/hub/classes/factories/socket/class_SocketFactory.php +++ b/application/hub/classes/factories/socket/class_SocketFactory.php @@ -282,7 +282,12 @@ class SocketFactory extends ObjectFactory { ); // Create socket instance - $socketInstance = self::createObjectByConfiguredName('socket_container_class', array($socketResource, StorableSocket::SOCKET_PROTOCOL_TCP, $packageData, NULL)); + $socketInstance = self::createObjectByConfiguredName('socket_container_class', array( + $socketResource, + StorableSocket::SOCKET_PROTOCOL_TCP, + $packageData, + NULL + )); // Is the socket resource valid? if (!$socketInstance->isValidSocket()) { diff --git a/application/hub/classes/handler/chunks/class_ChunkHandler.php b/application/hub/classes/handler/chunks/class_ChunkHandler.php index 3a5eb5fde..f3c508a23 100644 --- a/application/hub/classes/handler/chunks/class_ChunkHandler.php +++ b/application/hub/classes/handler/chunks/class_ChunkHandler.php @@ -5,7 +5,7 @@ namespace Org\Shipsimu\Hub\Handler\Network\RawData\Chunks; // Import application-specific stuff use Org\Shipsimu\Hub\Factory\Fragmenter\FragmenterFactory; use Org\Shipsimu\Hub\Handler\BaseHubHandler; -use Org\Shipsimu\Hub\Network\Package\Fragment\PackageFragmenter; +use Org\Shipsimu\Hub\Network\Package\Delivery\Fragment\PackageFragmenter; // Import framework stuff use Org\Mxchange\CoreFramework\Assertion\AssertionException; diff --git a/application/hub/classes/handler/data/class_BaseDataHandler.php b/application/hub/classes/handler/data/class_BaseDataHandler.php index b93588508..59a939740 100644 --- a/application/hub/classes/handler/data/class_BaseDataHandler.php +++ b/application/hub/classes/handler/data/class_BaseDataHandler.php @@ -6,7 +6,7 @@ namespace Org\Shipsimu\Hub\Handler\Data; use Org\Shipsimu\Hub\Factory\Node\NodeObjectFactory; use Org\Shipsimu\Hub\Generic\HubInterface; use Org\Shipsimu\Hub\Handler\BaseHubHandler; -use Org\Shipsimu\Hub\Network\Deliver\Deliverable; +use Org\Shipsimu\Hub\Network\Delivery\Deliverable; // Import framework stuff use Org\Mxchange\CoreFramework\Factory\ObjectFactory; diff --git a/application/hub/classes/handler/package/class_NetworkPackageHandler.php b/application/hub/classes/handler/package/class_NetworkPackageHandler.php index 84aa1d584..92259970b 100644 --- a/application/hub/classes/handler/package/class_NetworkPackageHandler.php +++ b/application/hub/classes/handler/package/class_NetworkPackageHandler.php @@ -18,10 +18,10 @@ 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; -use Org\Shipsimu\Hub\Network\Deliver\Deliverable; +use Org\Shipsimu\Hub\Network\Delivery\Deliverable; use Org\Shipsimu\Hub\Network\Networkable; use Org\Shipsimu\Hub\Network\Package\DeliverablePackage; -use Org\Shipsimu\Hub\Network\Package\Fragment\PackageFragmenter; +use Org\Shipsimu\Hub\Network\Package\Delivery\Fragment\PackageFragmenter; use Org\Shipsimu\Hub\Network\Receive\Receivable; use Org\Shipsimu\Hub\Node\Generic\InvalidPrivateKeyHashException; use Org\Shipsimu\Hub\Tag\Tagable; @@ -837,9 +837,9 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei $packageInstance->setSenderAddress($this->getSessionId()); $packageInstance->setSenderPort('0'); $packageInstance->setRecipientType($helperInstance->getRecipientType()); - $packageInstance->setContent($packageContent); + $packageInstance->setPackageContent($packageContent); $packageInstance->setStatus(self::PACKAGE_STATUS_NEW); - $packageInstance->setHash($this->generatePackageHash($content, $this->getSessionId())); + $packageInstance->setContentHash($this->generatePackageHash($content, $this->getSessionId())); $packageInstance->setPrivateKeyHash($this->getPrivateKeyHash()); // Now prepare the temporary array and push it on the 'undeclared' stack @@ -856,7 +856,10 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei */ public function isPackageEnqueued () { // Check whether the stacker is not empty - $isEnqueued = (($this->getStackInstance()->isStackInitialized(self::STACKER_NAME_UNDECLARED)) && (!$this->getStackInstance()->isStackEmpty(self::STACKER_NAME_UNDECLARED))); + $isEnqueued = ( + ($this->getStackInstance()->isStackInitialized(self::STACKER_NAME_UNDECLARED)) && + (!$this->getStackInstance()->isStackEmpty(self::STACKER_NAME_UNDECLARED)) + ); // Trace message //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE: isEnqueued=%d - EXIT!', intval($isEnqueued))); @@ -872,7 +875,10 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei */ public function isPackageDeclared () { // Check whether the stacker is not empty - $isDeclared = (($this->getStackInstance()->isStackInitialized(self::STACKER_NAME_DECLARED)) && (!$this->getStackInstance()->isStackEmpty(self::STACKER_NAME_DECLARED))); + $isDeclared = ( + ($this->getStackInstance()->isStackInitialized(self::STACKER_NAME_DECLARED)) && + (!$this->getStackInstance()->isStackEmpty(self::STACKER_NAME_DECLARED)) + ); // Trace message //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE: isDeclared=%d - EXIT!', intval($isDeclared))); @@ -1368,9 +1374,9 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei $packageInstance->setSenderAddress($decodedArray[self::INDEX_PACKAGE_SENDER_ADDRESS]); $packageInstance->setSenderPort($decodedArray[self::INDEX_PACKAGE_SENDER_PORT]); $packageInstance->setRecipient($decodedArray[self::INDEX_PACKAGE_RECIPIENT]); - $packageInstance->setContent($decodedArray[self::INDEX_PACKAGE_CONTENT]); + $packageInstance->setPackageContent($decodedArray[self::INDEX_PACKAGE_CONTENT]); $packageInstance->setStatus(self::PACKAGE_STATUS_DECODED); - $packageInstance->setHash($decodedArray[self::INDEX_PACKAGE_HASH]); + $packageInstance->setContentHash($decodedArray[self::INDEX_PACKAGE_HASH]); $packageInstance->setPrivateKeyHash($decodedArray[self::INDEX_PACKAGE_PRIVATE_KEY_HASH]); // And return it diff --git a/application/hub/classes/package/assembler/class_PackageAssembler.php b/application/hub/classes/package/assembler/class_PackageAssembler.php index 836ac7605..b14d0095b 100644 --- a/application/hub/classes/package/assembler/class_PackageAssembler.php +++ b/application/hub/classes/package/assembler/class_PackageAssembler.php @@ -1,6 +1,6 @@ . */ class PackageData extends BaseHubSystem implements DeliverablePackage, Registerable { + + /** + * An instance of a SplFileInfo class + */ + private $socketFile; + + /** + * Socket type + */ + private $socketType; + /** * Protected constructor * @@ -54,4 +68,42 @@ class PackageData extends BaseHubSystem implements DeliverablePackage, Registera return $packageInstance; } + /** + * Getter for socket file instance + * + * @return $socketFile An instance of a SplFileInfo class + */ + public function getSocketFile () { + return $this->socketFile; + } + + /** + * Setter for socket file instance + * + * @param $socketFile An instance of a SplFileInfo class + * @return void + */ + public function setSocketFile (SplFileInfo $socketFile) { + $this->socketFile = $socketFile; + } + + /** + * Getter for socket type + * + * @return $socketFile Stocket type + */ + public function getSocketType () { + return $this->socketType; + } + + /** + * Setter for socket type + * + * @param $socketType Socket type + * @return void + */ + public function setSocketType ($socketType) { + $this->socketType = $socketType; + } + } diff --git a/application/hub/classes/package/fragmenter/class_PackageFragmenter.php b/application/hub/classes/package/fragmenter/class_PackageFragmenter.php index 7869833a9..5e10f3fc1 100644 --- a/application/hub/classes/package/fragmenter/class_PackageFragmenter.php +++ b/application/hub/classes/package/fragmenter/class_PackageFragmenter.php @@ -1,6 +1,6 @@ setConfigEntry('allow_publish_internal_address', 'N'); $cfg->setConfigEntry('node_status', 'invalid'); // CFG: PACKAGE-FRAGMENTER-CLASS -$cfg->setConfigEntry('package_fragmenter_class', 'Org\Shipsimu\Hub\Network\Package\Fragment\PackageFragmenter'); +$cfg->setConfigEntry('package_fragmenter_class', 'Org\Shipsimu\Hub\Network\Package\Delivery\Fragment\PackageFragmenter'); // CFG: PACKAGE-ASSEMBLER-CLASS -$cfg->setConfigEntry('package_assembler_class', 'Org\Shipsimu\Hub\Network\Package\Assembler\PackageAssembler'); +$cfg->setConfigEntry('package_assembler_class', 'Org\Shipsimu\Hub\Network\Package\Receiver\Assembler\PackageAssembler'); // CFG: PACKAGE-CHUNK-SIZE $cfg->setConfigEntry('package_chunk_size', 256*8); diff --git a/application/hub/exceptions/package/class_FinalChunkVerificationException.php b/application/hub/exceptions/package/class_FinalChunkVerificationException.php index 94fa3e745..ae04a1699 100644 --- a/application/hub/exceptions/package/class_FinalChunkVerificationException.php +++ b/application/hub/exceptions/package/class_FinalChunkVerificationException.php @@ -3,7 +3,7 @@ namespace Org\Shipsimu\Hub\Node\Network\Chunk; // Import application-specific stuff -use Org\Shipsimu\Hub\Network\Package\Fragment\PackageFragmenter; +use Org\Shipsimu\Hub\Network\Package\Delivery\Fragment\PackageFragmenter; // Import framework stuff use Org\Mxchange\CoreFramework\Generic\FrameworkException; diff --git a/application/hub/interfaces/delivery/.htaccess b/application/hub/interfaces/delivery/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/interfaces/delivery/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/interfaces/delivery/class_Deliverable.php b/application/hub/interfaces/delivery/class_Deliverable.php new file mode 100644 index 000000000..966db5559 --- /dev/null +++ b/application/hub/interfaces/delivery/class_Deliverable.php @@ -0,0 +1,112 @@ + + * @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 . + */ +interface Deliverable extends HubInterface { + /** + * "Enqueues" raw content into this delivery class by reading the raw content + * from given helper's template instance and pushing it on the 'undeclared' + * stack. + * + * @param $helperInstance An instance of a HubHelper class + * @return void + */ + function enqueueRawDataFromTemplate (HubHelper $helperInstance); + + /** + * Checks whether a package has been enqueued for delivery. + * + * @return $isEnqueued Whether a package is enqueued + */ + function isPackageEnqueued (); + + /** + * Checks whether a package has been declared + * + * @return $isDeclared Whether a package is declared + */ + function isPackageDeclared (); + + /** + * Checks whether a package should be sent out + * + * @return $isWaitingDelivery Whether a package is waiting for delivery + */ + function isPackageWaitingForDelivery (); + + /** + * Checks whether encoded (raw) data is pending + * + * @return $isPending Whether encoded data is pending + */ + function isEncodedDataPending (); + + /** + * Delivers an enqueued package to the stated destination. If a non-session + * id is provided, recipient resolver is being asked (and instanced once). + * This allows that a single package is being delivered to multiple targets + * without enqueueing it for every target. If no target is provided or it + * can't be determined a NoTargetException is being thrown. + * + * @return void + * @throws NoTargetException If no target can't be determined + */ + function declareEnqueuedPackage (); + + /** + * Processes the next declared package. Only one package per time will be + * processed because this may take time and slows down the whole delivery + * infrastructure. + * + * @return void + */ + function processDeclaredPackage (); + + /** + * Sends waiting packages out for delivery + * + * @return void + */ + function sendWaitingPackage (); + + /** + * Sends pending encoded (raw) data + * + * @return void + */ + function sendEncodedData (); + + /** + * Clears all stacks + * + * @return void + */ + function clearAllStacks (); + +} diff --git a/application/hub/interfaces/delivery/fragmenter/.htaccess b/application/hub/interfaces/delivery/fragmenter/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/interfaces/delivery/fragmenter/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/interfaces/delivery/fragmenter/class_Fragmentable.php b/application/hub/interfaces/delivery/fragmenter/class_Fragmentable.php new file mode 100644 index 000000000..941343807 --- /dev/null +++ b/application/hub/interfaces/delivery/fragmenter/class_Fragmentable.php @@ -0,0 +1,57 @@ + + * @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 . + */ +interface Fragmentable extends HubInterface { + /** + * This method does "implode" the given package data array into one long + * string, splits it into small chunks, adds a serial number and checksum + * to all chunks and prepends a final hashsum chunk. It will return the + * final hash for faster processing of packages. + * + * @param $packageInstance An instance of a DeliverablePackage instance + * @param $helperInstance An instance of a ConnectionHelper class + * @return $finalHash Final hash for faster processing + */ + function fragmentPackageArray (DeliverablePackage $packageInstance, ConnectionHelper $helperInstance); + + /** + * This method gets the next chunk from the internal FIFO which should be + * sent to the given recipient. It will return an associative array where + * the key is the chunk hash and value the raw chunk data. + * + * @param $finalHash Final hash for faster lookup + * @return $rawDataChunk An instance of a DeliverablePackage class chunk + */ + function getNextRawDataChunk ($finalHash); + +} diff --git a/application/hub/interfaces/delivery/package/.htaccess b/application/hub/interfaces/delivery/package/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/interfaces/delivery/package/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/interfaces/delivery/package/class_DeliverablePackage.php b/application/hub/interfaces/delivery/package/class_DeliverablePackage.php new file mode 100644 index 000000000..41a7402c6 --- /dev/null +++ b/application/hub/interfaces/delivery/package/class_DeliverablePackage.php @@ -0,0 +1,65 @@ + + * @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 . + */ +interface DeliverablePackage extends HubInterface { + + /** + * Getter for socket file instance + * + * @return $socketFile An instance of a SplFileInfo class + */ + public function getSocketFile (); + + /** + * Setter for socket file instance + * + * @param $socketFile An instance of a SplFileInfo class + * @return void + */ + public function setSocketFile (SplFileInfo $socketFile); + + /** + * Getter for socket type + * + * @return $socketFile Stocket type + */ + public function getSocketType (); + + /** + * Setter for socket type + * + * @param $socketType Socket type + * @return void + */ + public function setSocketType ($socketType); + +} diff --git a/application/hub/interfaces/package/.htaccess b/application/hub/interfaces/package/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/interfaces/package/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/interfaces/package/assembler/.htaccess b/application/hub/interfaces/package/assembler/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/interfaces/package/assembler/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/interfaces/package/assembler/class_Assembler.php b/application/hub/interfaces/package/assembler/class_Assembler.php deleted file mode 100644 index b22f4b92d..000000000 --- a/application/hub/interfaces/package/assembler/class_Assembler.php +++ /dev/null @@ -1,69 +0,0 @@ - - * @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 . - */ -interface Assembler extends HubInterface { - /** - * Chunks the content from $packageContent and feeds it into another queue - * for verification and possible re-requesting. - * - * @param $packageContent An array with two elements: 'raw_data' and 'error_code' - * @return void - */ - function chunkPackageContent (array $packageContent); - - /** - * Checks whether the assembler's pending data is empty which means it has - * no pending data left for handling ... ;-) - * - * @return $ifPendingDataIsEmpty Whether pending data is empty - */ - function isPendingDataEmpty (); - - /** - * Handles the assembler's pending data - * - * @return void - */ - function handlePendingData (); - - /** - * Checks whether the assembler has multiple messages pending - * - * @return $isPending Whether the assembler has multiple messages pending - */ - function ifMultipleMessagesPending (); - - /** - * Handles multiple messages. - * - * @return void - */ - function handleMultipleMessages (); - -} diff --git a/application/hub/interfaces/package/class_Deliverable.php b/application/hub/interfaces/package/class_Deliverable.php deleted file mode 100644 index 53b7906d3..000000000 --- a/application/hub/interfaces/package/class_Deliverable.php +++ /dev/null @@ -1,112 +0,0 @@ - - * @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 . - */ -interface Deliverable extends HubInterface { - /** - * "Enqueues" raw content into this delivery class by reading the raw content - * from given helper's template instance and pushing it on the 'undeclared' - * stack. - * - * @param $helperInstance An instance of a HubHelper class - * @return void - */ - function enqueueRawDataFromTemplate (HubHelper $helperInstance); - - /** - * Checks whether a package has been enqueued for delivery. - * - * @return $isEnqueued Whether a package is enqueued - */ - function isPackageEnqueued (); - - /** - * Checks whether a package has been declared - * - * @return $isDeclared Whether a package is declared - */ - function isPackageDeclared (); - - /** - * Checks whether a package should be sent out - * - * @return $isWaitingDelivery Whether a package is waiting for delivery - */ - function isPackageWaitingForDelivery (); - - /** - * Checks whether encoded (raw) data is pending - * - * @return $isPending Whether encoded data is pending - */ - function isEncodedDataPending (); - - /** - * Delivers an enqueued package to the stated destination. If a non-session - * id is provided, recipient resolver is being asked (and instanced once). - * This allows that a single package is being delivered to multiple targets - * without enqueueing it for every target. If no target is provided or it - * can't be determined a NoTargetException is being thrown. - * - * @return void - * @throws NoTargetException If no target can't be determined - */ - function declareEnqueuedPackage (); - - /** - * Processes the next declared package. Only one package per time will be - * processed because this may take time and slows down the whole delivery - * infrastructure. - * - * @return void - */ - function processDeclaredPackage (); - - /** - * Sends waiting packages out for delivery - * - * @return void - */ - function sendWaitingPackage (); - - /** - * Sends pending encoded (raw) data - * - * @return void - */ - function sendEncodedData (); - - /** - * Clears all stacks - * - * @return void - */ - function clearAllStacks (); - -} diff --git a/application/hub/interfaces/package/class_Receivable.php b/application/hub/interfaces/package/class_Receivable.php deleted file mode 100644 index 7b0281080..000000000 --- a/application/hub/interfaces/package/class_Receivable.php +++ /dev/null @@ -1,160 +0,0 @@ - - * @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 . - */ -interface Receivable extends HubInterface { - /** - * Checks whether new raw data from the socket has arrived - * - * @return $hasArrived Whether raw package data has arrived at a socket - */ - function isNewRawDataPending (); - - /** - * Handles the incoming decoded raw data. This method does not "convert" the - * decoded data back into a package array, it just "handles" it and pushs it - * on the next stack. - * - * @return void - */ - function handleIncomingDecodedData (); - - /** - * Checks whether incoming decoded data is handled. - * - * @return $isHandled Whether incoming decoded data is handled - */ - function isIncomingRawDataHandled (); - - /** - * Assembles incoming decoded data so it will become an abstract network - * package again. - * - * @return void - */ - function assembleDecodedDataToPackage (); - - /** - * Checks whether a new message has arrived - * - * @return $hasArrived Whether a new message has arrived for processing - */ - function isNewMessageArrived (); - - /** - * Handle newly arrived message - * - * @return void - */ - function handleNewlyArrivedMessage (); - - /** - * Checks whether a processed message is pending for "interpretation" - * - * @return $isPending Whether a processed message is pending - */ - function isProcessedMessagePending (); - - /** - * Handle processed messages by "interpreting" the 'message_type' element - * - * @return void - */ - function handleProcessedMessage (); - - /** - * Adds raw decoded data from the given handler instance to this receiver - * - * @param $handlerInstance An instance of a Networkable class - * @return void - */ - function addRawDataToIncomingStack (Networkable $handlerInstance); - - /** - * "Decode" the package content. This method does also verify the attached hash - * against the real raw package data (that what the sender has sent). - * - * @param $rawPackageContent The raw package content to be "decoded" - * @return $packageInstance An instance of a DeliverablePackage class - */ - function decodeRawContent ($rawPackageContent); - - /** - * Checks whether the assembler has pending data left - * - * @return $isHandled Whether the assembler has pending data left - */ - function ifAssemblerHasPendingDataLeft (); - - /** - * Handles the attached assemler's pending data queue to be finally - * assembled to the raw package data back. - * - * @return void - */ - function handleAssemblerPendingData (); - - /** - * Handles decoded data for this node - * - * @param $packageInstance An instance of a DeliverablePackage class - * @return void - */ - function handleRawData (DeliverablePackage $packageInstance); - - /** - * Checks whether the assembler has multiple messages pending - * - * @return $isPending Whether the assembler has multiple messages pending - */ - function ifMultipleMessagesPending (); - - /** - * Handles multiple messages. - * - * @return void - */ - function handleMultipleMessages (); - - /** - * Feeds the hash and sender (as recipient for the 'sender' reward) to the - * miner's queue, unless the message is not a "reward claim" message as this - * leads to an endless loop. You may wish to run the miner to get some - * reward ("Hubcoins") for "mining" this hash. - * - * @param $messageData Array with message data - * @return void - */ - function feedHashToMiner (array $messageData); -} - -// [EOF] -?> diff --git a/application/hub/interfaces/package/fragmenter/.htaccess b/application/hub/interfaces/package/fragmenter/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/interfaces/package/fragmenter/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/interfaces/package/fragmenter/class_Fragmentable.php b/application/hub/interfaces/package/fragmenter/class_Fragmentable.php deleted file mode 100644 index 6ed4880a1..000000000 --- a/application/hub/interfaces/package/fragmenter/class_Fragmentable.php +++ /dev/null @@ -1,57 +0,0 @@ - - * @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 . - */ -interface Fragmentable extends HubInterface { - /** - * This method does "implode" the given package data array into one long - * string, splits it into small chunks, adds a serial number and checksum - * to all chunks and prepends a final hashsum chunk. It will return the - * final hash for faster processing of packages. - * - * @param $packageInstance An instance of a DeliverablePackage instance - * @param $helperInstance An instance of a ConnectionHelper class - * @return $finalHash Final hash for faster processing - */ - function fragmentPackageArray (DeliverablePackage $packageInstance, ConnectionHelper $helperInstance); - - /** - * This method gets the next chunk from the internal FIFO which should be - * sent to the given recipient. It will return an associative array where - * the key is the chunk hash and value the raw chunk data. - * - * @param $finalHash Final hash for faster lookup - * @return $rawDataChunk An instance of a DeliverablePackage class chunk - */ - function getNextRawDataChunk ($finalHash); - -} diff --git a/application/hub/interfaces/package/package/.htaccess b/application/hub/interfaces/package/package/.htaccess deleted file mode 100644 index 3a4288278..000000000 --- a/application/hub/interfaces/package/package/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/application/hub/interfaces/package/package/class_DeliverablePackage.php b/application/hub/interfaces/package/package/class_DeliverablePackage.php deleted file mode 100644 index 16df801be..000000000 --- a/application/hub/interfaces/package/package/class_DeliverablePackage.php +++ /dev/null @@ -1,32 +0,0 @@ - - * @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 . - */ -interface DeliverablePackage extends HubInterface { - -} diff --git a/application/hub/interfaces/receiver/.htaccess b/application/hub/interfaces/receiver/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/interfaces/receiver/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/interfaces/receiver/assembler/.htaccess b/application/hub/interfaces/receiver/assembler/.htaccess new file mode 100644 index 000000000..3a4288278 --- /dev/null +++ b/application/hub/interfaces/receiver/assembler/.htaccess @@ -0,0 +1 @@ +Deny from all diff --git a/application/hub/interfaces/receiver/assembler/class_Assembler.php b/application/hub/interfaces/receiver/assembler/class_Assembler.php new file mode 100644 index 000000000..3fe218326 --- /dev/null +++ b/application/hub/interfaces/receiver/assembler/class_Assembler.php @@ -0,0 +1,69 @@ + + * @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 . + */ +interface Assembler extends HubInterface { + /** + * Chunks the content from $packageContent and feeds it into another queue + * for verification and possible re-requesting. + * + * @param $packageContent An array with two elements: 'raw_data' and 'error_code' + * @return void + */ + function chunkPackageContent (array $packageContent); + + /** + * Checks whether the assembler's pending data is empty which means it has + * no pending data left for handling ... ;-) + * + * @return $ifPendingDataIsEmpty Whether pending data is empty + */ + function isPendingDataEmpty (); + + /** + * Handles the assembler's pending data + * + * @return void + */ + function handlePendingData (); + + /** + * Checks whether the assembler has multiple messages pending + * + * @return $isPending Whether the assembler has multiple messages pending + */ + function ifMultipleMessagesPending (); + + /** + * Handles multiple messages. + * + * @return void + */ + function handleMultipleMessages (); + +} diff --git a/application/hub/interfaces/receiver/class_Receivable.php b/application/hub/interfaces/receiver/class_Receivable.php new file mode 100644 index 000000000..7b0281080 --- /dev/null +++ b/application/hub/interfaces/receiver/class_Receivable.php @@ -0,0 +1,160 @@ + + * @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 . + */ +interface Receivable extends HubInterface { + /** + * Checks whether new raw data from the socket has arrived + * + * @return $hasArrived Whether raw package data has arrived at a socket + */ + function isNewRawDataPending (); + + /** + * Handles the incoming decoded raw data. This method does not "convert" the + * decoded data back into a package array, it just "handles" it and pushs it + * on the next stack. + * + * @return void + */ + function handleIncomingDecodedData (); + + /** + * Checks whether incoming decoded data is handled. + * + * @return $isHandled Whether incoming decoded data is handled + */ + function isIncomingRawDataHandled (); + + /** + * Assembles incoming decoded data so it will become an abstract network + * package again. + * + * @return void + */ + function assembleDecodedDataToPackage (); + + /** + * Checks whether a new message has arrived + * + * @return $hasArrived Whether a new message has arrived for processing + */ + function isNewMessageArrived (); + + /** + * Handle newly arrived message + * + * @return void + */ + function handleNewlyArrivedMessage (); + + /** + * Checks whether a processed message is pending for "interpretation" + * + * @return $isPending Whether a processed message is pending + */ + function isProcessedMessagePending (); + + /** + * Handle processed messages by "interpreting" the 'message_type' element + * + * @return void + */ + function handleProcessedMessage (); + + /** + * Adds raw decoded data from the given handler instance to this receiver + * + * @param $handlerInstance An instance of a Networkable class + * @return void + */ + function addRawDataToIncomingStack (Networkable $handlerInstance); + + /** + * "Decode" the package content. This method does also verify the attached hash + * against the real raw package data (that what the sender has sent). + * + * @param $rawPackageContent The raw package content to be "decoded" + * @return $packageInstance An instance of a DeliverablePackage class + */ + function decodeRawContent ($rawPackageContent); + + /** + * Checks whether the assembler has pending data left + * + * @return $isHandled Whether the assembler has pending data left + */ + function ifAssemblerHasPendingDataLeft (); + + /** + * Handles the attached assemler's pending data queue to be finally + * assembled to the raw package data back. + * + * @return void + */ + function handleAssemblerPendingData (); + + /** + * Handles decoded data for this node + * + * @param $packageInstance An instance of a DeliverablePackage class + * @return void + */ + function handleRawData (DeliverablePackage $packageInstance); + + /** + * Checks whether the assembler has multiple messages pending + * + * @return $isPending Whether the assembler has multiple messages pending + */ + function ifMultipleMessagesPending (); + + /** + * Handles multiple messages. + * + * @return void + */ + function handleMultipleMessages (); + + /** + * Feeds the hash and sender (as recipient for the 'sender' reward) to the + * miner's queue, unless the message is not a "reward claim" message as this + * leads to an endless loop. You may wish to run the miner to get some + * reward ("Hubcoins") for "mining" this hash. + * + * @param $messageData Array with message data + * @return void + */ + function feedHashToMiner (array $messageData); +} + +// [EOF] +?>