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;
$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);
);
// 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()) {
// 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;
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;
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;
$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
*/
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)));
*/
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)));
$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
<?php
// Own namespace
-namespace Org\Shipsimu\Hub\Network\Package\Assembler;
+namespace Org\Shipsimu\Hub\Network\Package\Receiver\Assembler;
// Import application-specific stuff
use Org\Shipsimu\Hub\Container\Socket\StorableSocket;
use Org\Shipsimu\Hub\Generic\BaseHubSystem;
use Org\Shipsimu\Hub\Handler\Network\RawData\HandleableRawData;
use Org\Shipsimu\Hub\Handler\Package\NetworkPackageHandler;
-use Org\Shipsimu\Hub\Network\Package\Fragment\PackageFragmenter;
+use Org\Shipsimu\Hub\Network\Package\Delivery\Fragment\PackageFragmenter;
use Org\Shipsimu\Hub\Network\Receive\Receivable;
// Import framework stuff
// Import framework stuff
use Org\Mxchange\CoreFramework\Registry\Registerable;
+// Import SPL stuff
+use \SplFileInfo;
+
/**
* A DeliverablePackage class for raw package data
*
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
class PackageData extends BaseHubSystem implements DeliverablePackage, Registerable {
+
+ /**
+ * An instance of a SplFileInfo class
+ */
+ private $socketFile;
+
+ /**
+ * Socket type
+ */
+ private $socketType;
+
/**
* Protected constructor
*
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;
+ }
+
}
<?php
// Own namespace
-namespace Org\Shipsimu\Hub\Network\Package\Fragment;
+namespace Org\Shipsimu\Hub\Network\Package\Delivery\Fragment;
// Import application-specific stuff
use Org\Shipsimu\Hub\Generic\BaseHubSystem;
// Import application-specific stuff
use Org\Shipsimu\Hub\Factory\Network\NetworkPackageFactory;
use Org\Shipsimu\Hub\Helper\Connection\ConnectionHelper;
-use Org\Shipsimu\Hub\Network\Deliver\Deliverable;
+use Org\Shipsimu\Hub\Network\Delivery\Deliverable;
// Import framework stuff
use Org\Mxchange\CoreFramework\Visitor\BaseVisitor;
use Org\Shipsimu\Hub\Container\Socket\StorableSocket;
use Org\Shipsimu\Hub\Factory\Network\NetworkPackageFactory;
use Org\Shipsimu\Hub\Helper\Connection\ConnectionHelper;
-use Org\Shipsimu\Hub\Network\Deliver\Deliverable;
+use Org\Shipsimu\Hub\Network\Delivery\Deliverable;
// Import framework stuff
use Org\Mxchange\CoreFramework\Visitor\BaseVisitor;
$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);
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;
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+// Own namespace
+namespace Org\Shipsimu\Hub\Network\Delivery;
+
+// Import application-specific stuff
+use Org\Shipsimu\Hub\Generic\HubInterface;
+use Org\Shipsimu\Hub\Helper\HubHelper;
+
+/**
+ * An interface for package delivery boys... ;-)
+ *
+ * @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/>.
+ */
+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 ();
+
+}
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+// Own namespace
+namespace Org\Shipsimu\Hub\Network\Package\Delivery\Fragment;
+
+// Import application-specific stuff
+use Org\Shipsimu\Hub\Helper\Connection\ConnectionHelper;
+
+// Import application-specific stuff
+use Org\Shipsimu\Hub\Generic\HubInterface;
+use Org\Shipsimu\Hub\Network\Package\DeliverablePackage;
+
+/**
+ * An interface for a package fragmenter
+ *
+ * @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/>.
+ */
+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);
+
+}
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+// Own namespace
+namespace Org\Shipsimu\Hub\Network\Package;
+
+// Import application-specific stuff
+use Org\Shipsimu\Hub\Generic\HubInterface;
+
+// Import PHP stuff
+use \SplFileInfo;
+
+/**
+ * An interface for package delivery boys... ;-)
+ *
+ * @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/>.
+ */
+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);
+
+}
+++ /dev/null
-Deny from all
+++ /dev/null
-Deny from all
+++ /dev/null
-<?php
-// Own namespace
-namespace Org\Shipsimu\Hub\Network\Package\Assembler;
-
-// Import application-specific stuff
-use Org\Shipsimu\Hub\Generic\HubInterface;
-
-/**
- * An interface for a package assembler
- *
- * @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/>.
- */
-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 ();
-
-}
+++ /dev/null
-<?php
-// Own namespace
-namespace Org\Shipsimu\Hub\Network\Deliver;
-
-// Import application-specific stuff
-use Org\Shipsimu\Hub\Generic\HubInterface;
-use Org\Shipsimu\Hub\Helper\HubHelper;
-
-/**
- * An interface for package delivery boys... ;-)
- *
- * @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/>.
- */
-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 ();
-
-}
+++ /dev/null
-<?php
-// Own namespace
-namespace Org\Shipsimu\Hub\Network\Receive;
-
-// Import application-specific stuff
-use Org\Shipsimu\Hub\Network\Networkable;
-
-// Import application-specific stuff
-use Org\Shipsimu\Hub\Generic\HubInterface;
-
-/**
- * An interface for package receivers
- *
- * @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/>.
- */
-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]
-?>
+++ /dev/null
-Deny from all
+++ /dev/null
-<?php
-// Own namespace
-namespace Org\Shipsimu\Hub\Network\Package\Fragment;
-
-// Import application-specific stuff
-use Org\Shipsimu\Hub\Helper\Connection\ConnectionHelper;
-
-// Import application-specific stuff
-use Org\Shipsimu\Hub\Generic\HubInterface;
-use Org\Shipsimu\Hub\Network\Package\DeliverablePackage;
-
-/**
- * An interface for a package fragmenter
- *
- * @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/>.
- */
-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);
-
-}
+++ /dev/null
-Deny from all
+++ /dev/null
-<?php
-// Own namespace
-namespace Org\Shipsimu\Hub\Network\Package;
-
-// Import application-specific stuff
-use Org\Shipsimu\Hub\Generic\HubInterface;
-
-/**
- * An interface for package delivery boys... ;-)
- *
- * @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/>.
- */
-interface DeliverablePackage extends HubInterface {
-
-}
--- /dev/null
+Deny from all
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+// Own namespace
+namespace Org\Shipsimu\Hub\Network\Package\Receiver\Assembler;
+
+// Import application-specific stuff
+use Org\Shipsimu\Hub\Generic\HubInterface;
+
+/**
+ * An interface for a package assembler
+ *
+ * @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/>.
+ */
+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 ();
+
+}
--- /dev/null
+<?php
+// Own namespace
+namespace Org\Shipsimu\Hub\Network\Receive;
+
+// Import application-specific stuff
+use Org\Shipsimu\Hub\Network\Networkable;
+
+// Import application-specific stuff
+use Org\Shipsimu\Hub\Generic\HubInterface;
+
+/**
+ * An interface for package receivers
+ *
+ * @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/>.
+ */
+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]
+?>