From: Roland Häder Date: Mon, 22 May 2017 16:32:00 +0000 (+0200) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=691962e3733546383c21b5aa7368e18342032bcf;p=hub.git Continued: - imported FrameworkException - imported InvalidConnectionTypeException - need to call StorableSocket's method - raw-data is always network-related Signed-off-by: Roland Häder --- diff --git a/application/hub/classes/class_BaseHubSystem.php b/application/hub/classes/class_BaseHubSystem.php index f4faee74d..338059c14 100644 --- a/application/hub/classes/class_BaseHubSystem.php +++ b/application/hub/classes/class_BaseHubSystem.php @@ -4,7 +4,7 @@ namespace Hub\Generic; // Import application-specific stuff use Hub\Handler\Protocol\HandleableProtocol; -use Hub\Handler\RawData\BaseRawDataHandler; +use Hub\Handler\Network\RawData\BaseRawDataHandler; use Hub\Information\ShareableInfo; use Hub\Listener\BaseListener; use Hub\Listener\Listenable; diff --git a/application/hub/classes/container/socket/class_SocketContainer.php b/application/hub/classes/container/socket/class_SocketContainer.php index a146286cb..04c7b89e2 100644 --- a/application/hub/classes/container/socket/class_SocketContainer.php +++ b/application/hub/classes/container/socket/class_SocketContainer.php @@ -3,7 +3,7 @@ namespace Hub\Container\Socket; // Import application-specific stuff -use Hub\Handler\RawData\BaseRawDataHandler; +use Hub\Handler\Network\RawData\BaseRawDataHandler; use Hub\Helper\Connection\BaseConnectionHelper; use Hub\Information\ShareableInfo; use Hub\Listener\BaseListener; @@ -849,7 +849,7 @@ class SocketContainer extends BaseContainer implements StorableSocket, Visitable * @param $connectionType Type of connection, can be 'incoming', 'outgoing' or 'server' * @return $isValid Whether the provided connection type is valid */ - private function isValidConnectionType ($connectionType) { + public function isValidConnectionType ($connectionType) { // Is it valid? $isValid = in_array($connectionType, $this->connectionTypes, TRUE); diff --git a/application/hub/classes/discovery/recipient/package/class_PackageRecipientDiscovery.php b/application/hub/classes/discovery/recipient/package/class_PackageRecipientDiscovery.php index d6e498398..54b1983e6 100644 --- a/application/hub/classes/discovery/recipient/package/class_PackageRecipientDiscovery.php +++ b/application/hub/classes/discovery/recipient/package/class_PackageRecipientDiscovery.php @@ -125,7 +125,5 @@ class PackageRecipientDiscovery extends BaseRecipientDiscovery implements Discov // @TODO Unfinished: $this->getListInstance()->addEntry('unl', $decodedData[NetworkPackage::PACKAGE_DATA_RECIPIENT]); } } -} -// [EOF] -?> +} diff --git a/application/hub/classes/handler/message-types/class_BaseMessageHandler.php b/application/hub/classes/handler/message-types/class_BaseMessageHandler.php index 1dc664893..e502920a4 100644 --- a/application/hub/classes/handler/message-types/class_BaseMessageHandler.php +++ b/application/hub/classes/handler/message-types/class_BaseMessageHandler.php @@ -6,6 +6,9 @@ namespace Hub\Handler\Message; use Hub\Generic\BaseHubSystem; use Hub\Network\Receive\Receivable; +// Import framework stuff +use CoreFramework\Generic\FrameworkException; + /** * A general message handler, this class must be abstract to make the template * method pattern working. @@ -93,7 +96,5 @@ abstract class BaseMessageHandler extends BaseDataHandler { */ $packageInstance->feedHashToMiner($messageData); } -} -// [EOF] -?> +} diff --git a/application/hub/classes/handler/network/socket/class_SocketRawDataHandler.php b/application/hub/classes/handler/network/socket/class_SocketRawDataHandler.php index f60eba73e..e02f2f10f 100644 --- a/application/hub/classes/handler/network/socket/class_SocketRawDataHandler.php +++ b/application/hub/classes/handler/network/socket/class_SocketRawDataHandler.php @@ -3,7 +3,7 @@ namespace Hub\Handler\Network\Socket\RawData; // Import application-specific stuff -use Hub\Handler\RawData\BaseRawDataHandler; +use Hub\Handler\Network\RawData\BaseRawDataHandler; use Hub\Network\Networkable; /** diff --git a/application/hub/classes/handler/network/tcp/class_TcpRawDataHandler.php b/application/hub/classes/handler/network/tcp/class_TcpRawDataHandler.php index ee1f41f52..3832dc37b 100644 --- a/application/hub/classes/handler/network/tcp/class_TcpRawDataHandler.php +++ b/application/hub/classes/handler/network/tcp/class_TcpRawDataHandler.php @@ -3,7 +3,7 @@ namespace Hub\Handler\Network\RawData\Tcp; // Import application-specific stuff -use Hub\Handler\RawData\BaseRawDataHandler; +use Hub\Handler\Network\RawData\BaseRawDataHandler; use Hub\Network\Networkable; use Hub\Pool\Poolable; diff --git a/application/hub/classes/handler/network/udp/class_UdpRawDataHandler.php b/application/hub/classes/handler/network/udp/class_UdpRawDataHandler.php index 2c3e0a911..f1aaa667f 100644 --- a/application/hub/classes/handler/network/udp/class_UdpRawDataHandler.php +++ b/application/hub/classes/handler/network/udp/class_UdpRawDataHandler.php @@ -1,9 +1,9 @@ validateSocket($socketInstance); // Is the connection type valid? - if (!$this->isValidConnectionType($connectionType)) { + if (!$socketInstance->isValidConnectionType($connectionType)) { // Is not a valid connection type! throw new InvalidConnectionTypeException(array($this, $connectionType), self::EXCEPTION_INVALID_CONNECTION_TYPE); } // END - if @@ -181,15 +182,9 @@ class DefaultPeerPool extends BasePool implements PoolablePeer { * * @param $connectionType Type of connection, can only be 'incoming', 'outgoing' or 'server' * @return $sockets An array with sockets of given type - * @throws InvalidConnectionTypeException If the provided connection type is not valid + * @throws InvalidConnectionTypeException If the found connection type is not valid */ public function getSocketsByConnectionType ($connectionType) { - // Is the connection type valid? - if (!$this->isValidConnectionType($connectionType)) { - // Is not a valid connection type! - throw new InvalidConnectionTypeException(array($this, $connectionType), self::EXCEPTION_INVALID_CONNECTION_TYPE); - } // END - if - // Get the array list $socketArrays = $this->getArrayFromList('pool'); @@ -200,6 +195,12 @@ class DefaultPeerPool extends BasePool implements PoolablePeer { foreach ($socketArrays as $socketArray) { // Does it match? if ($socketArray[Poolable::SOCKET_ARRAY_CONN_TYPE] === $connectionType) { + // Is the connection type valid? + if (!$socketArray[Poolable::SOCKET_ARRAY_INSTANCE]->isValidConnectionType($connectionType)) { + // Is not a valid connection type! + throw new InvalidConnectionTypeException(array($this, $connectionType), self::EXCEPTION_INVALID_CONNECTION_TYPE); + } // END - if + // Add the socket array_push($sockets, $socketArray[Poolable::SOCKET_ARRAY_INSTANCE]); } // END - if diff --git a/application/hub/classes/recipient/dht/class_DhtRecipient.php b/application/hub/classes/recipient/dht/class_DhtRecipient.php index f6c527143..2d4511fed 100644 --- a/application/hub/classes/recipient/dht/class_DhtRecipient.php +++ b/application/hub/classes/recipient/dht/class_DhtRecipient.php @@ -98,7 +98,5 @@ class DhtRecipient extends BaseRecipient implements Recipient { // Debug message //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-RECIPIENT: recipient=' . $recipient . ' - EXIT!'); } -} -// [EOF] -?> +} diff --git a/application/hub/classes/recipient/direct/class_DirectRecipient.php b/application/hub/classes/recipient/direct/class_DirectRecipient.php index 18b48dc1b..69c53ed4d 100644 --- a/application/hub/classes/recipient/direct/class_DirectRecipient.php +++ b/application/hub/classes/recipient/direct/class_DirectRecipient.php @@ -84,7 +84,5 @@ class DirectRecipient extends BaseRecipient implements Recipient { $listInstance->addEntry('unl', $unlData); } // END - foreach } -} -// [EOF] -?> +} diff --git a/application/hub/classes/recipient/self/class_SelfRecipient.php b/application/hub/classes/recipient/self/class_SelfRecipient.php index e942b4dd1..5202ff1c1 100644 --- a/application/hub/classes/recipient/self/class_SelfRecipient.php +++ b/application/hub/classes/recipient/self/class_SelfRecipient.php @@ -80,7 +80,5 @@ class SelfRecipient extends BaseRecipient implements Recipient { $listInstance->addEntry('unl', $unl); } // END - if } -} -// [EOF] -?> +} diff --git a/application/hub/classes/recipient/upper/class_UpperRecipient.php b/application/hub/classes/recipient/upper/class_UpperRecipient.php index 0047f3704..77b717c2c 100644 --- a/application/hub/classes/recipient/upper/class_UpperRecipient.php +++ b/application/hub/classes/recipient/upper/class_UpperRecipient.php @@ -88,7 +88,5 @@ class UpperRecipient extends BaseRecipient implements Recipient { $listInstance->addEntry('unl', $unlData); } // END - foreach } -} -// [EOF] -?> +} diff --git a/application/hub/classes/streams/raw_data/output/class_RawDataOutputStream.php b/application/hub/classes/streams/raw_data/output/class_RawDataOutputStream.php index 19e67abe1..c7ff58ebb 100644 --- a/application/hub/classes/streams/raw_data/output/class_RawDataOutputStream.php +++ b/application/hub/classes/streams/raw_data/output/class_RawDataOutputStream.php @@ -3,7 +3,7 @@ namespace Hub\Stream\Output\RawData; // Import application-specific stuff -use Hub\Handler\RawData\BaseRawDataHandler; +use Hub\Handler\Network\RawData\BaseRawDataHandler; /** * A RawDataOutputStream class diff --git a/application/hub/exceptions/announcement/class_AnnouncementNotAcceptedException.php b/application/hub/exceptions/announcement/class_AnnouncementNotAcceptedException.php index 5d212353e..c510f7321 100644 --- a/application/hub/exceptions/announcement/class_AnnouncementNotAcceptedException.php +++ b/application/hub/exceptions/announcement/class_AnnouncementNotAcceptedException.php @@ -1,4 +1,10 @@ +} diff --git a/application/hub/exceptions/ids/class_InvalidSessionIdException.php b/application/hub/exceptions/ids/class_InvalidSessionIdException.php index af68f6bd4..d77a2f2df 100644 --- a/application/hub/exceptions/ids/class_InvalidSessionIdException.php +++ b/application/hub/exceptions/ids/class_InvalidSessionIdException.php @@ -1,4 +1,10 @@ +} diff --git a/application/hub/exceptions/lists/class_InvalidListHashException.php b/application/hub/exceptions/lists/class_InvalidListHashException.php index c3247cb3d..baa53ff34 100644 --- a/application/hub/exceptions/lists/class_InvalidListHashException.php +++ b/application/hub/exceptions/lists/class_InvalidListHashException.php @@ -41,7 +41,5 @@ class InvalidListHashException extends FrameworkException { // Call parent exception constructor parent::__construct($message, $code); } -} -// [EOF] -?> +} diff --git a/application/hub/exceptions/lists/class_ListGroupAlreadyAddedException.php b/application/hub/exceptions/lists/class_ListGroupAlreadyAddedException.php index 62a61f736..c8bddc404 100644 --- a/application/hub/exceptions/lists/class_ListGroupAlreadyAddedException.php +++ b/application/hub/exceptions/lists/class_ListGroupAlreadyAddedException.php @@ -40,7 +40,5 @@ class ListGroupAlreadyAddedException extends FrameworkException { // Call parent exception constructor parent::__construct($message, $code); } -} -// [EOF] -?> +} diff --git a/application/hub/exceptions/lists/class_NoListGroupException.php b/application/hub/exceptions/lists/class_NoListGroupException.php index c18eb72cf..10ba8e102 100644 --- a/application/hub/exceptions/lists/class_NoListGroupException.php +++ b/application/hub/exceptions/lists/class_NoListGroupException.php @@ -40,7 +40,5 @@ class NoListGroupException extends FrameworkException { // Call parent exception constructor parent::__construct($message, $code); } -} -// [EOF] -?> +} diff --git a/application/hub/exceptions/node/class_NodeAlreadyAnnouncedException.php b/application/hub/exceptions/node/class_NodeAlreadyAnnouncedException.php index e65b5c9ca..7812bfd8d 100644 --- a/application/hub/exceptions/node/class_NodeAlreadyAnnouncedException.php +++ b/application/hub/exceptions/node/class_NodeAlreadyAnnouncedException.php @@ -1,4 +1,10 @@ +} diff --git a/application/hub/exceptions/package/class_InvalidDataChecksumException.php b/application/hub/exceptions/package/class_InvalidDataChecksumException.php index b0b691b63..4eab57e8f 100644 --- a/application/hub/exceptions/package/class_InvalidDataChecksumException.php +++ b/application/hub/exceptions/package/class_InvalidDataChecksumException.php @@ -5,6 +5,9 @@ namespace Hub\RawData; // Import application-specific stuff use Hub\Network\Package\NetworkPackage; +// Import framework stuff +use CoreFramework\Generic\FrameworkException; + /** * This exception is thrown when the checksum (sometimes called "hash") of the * package data (aka "message" emcoded with BASE64) is not valid. @@ -48,7 +51,5 @@ class InvalidDataChecksumException extends FrameworkException { // Call parent exception constructor parent::__construct($message, $code); } -} -// [EOF] -?> +} diff --git a/application/hub/exceptions/package/class_InvalidPrivateKeyHashException.php b/application/hub/exceptions/package/class_InvalidPrivateKeyHashException.php index 5a51d828b..6a3abca8a 100644 --- a/application/hub/exceptions/package/class_InvalidPrivateKeyHashException.php +++ b/application/hub/exceptions/package/class_InvalidPrivateKeyHashException.php @@ -1,4 +1,10 @@ +} diff --git a/application/hub/exceptions/package/class_UnexpectedPackageStatusException.php b/application/hub/exceptions/package/class_UnexpectedPackageStatusException.php index d63d92e8f..f5f7eeba6 100644 --- a/application/hub/exceptions/package/class_UnexpectedPackageStatusException.php +++ b/application/hub/exceptions/package/class_UnexpectedPackageStatusException.php @@ -5,6 +5,9 @@ namespace Hub\Status\Package; // Import application-specific stuff use Hub\Network\Package\NetworkPackage; +// Import framework stuff +use CoreFramework\Generic\FrameworkException; + /** * This exception is thrown when an unexpected package status was detected. * @@ -50,7 +53,5 @@ class UnexpectedPackageStatusException extends FrameworkException { // Call parent exception constructor parent::__construct($message, $code); } -} -// [EOF] -?> +} diff --git a/application/hub/exceptions/package/class_UnsupportedPackageCodeHandlerException.php b/application/hub/exceptions/package/class_UnsupportedPackageCodeHandlerException.php index 03008573e..93ce11b9b 100644 --- a/application/hub/exceptions/package/class_UnsupportedPackageCodeHandlerException.php +++ b/application/hub/exceptions/package/class_UnsupportedPackageCodeHandlerException.php @@ -3,7 +3,10 @@ namespace Hub\Handler\Network\PackageCode; // Import application-specific stuff -use Hub\Handler\RawData\BaseRawDataHandler; +use Hub\Handler\Network\RawData\BaseRawDataHandler; + +// Import framework stuff +use CoreFramework\Generic\FrameworkException; /** * This exception is thrown when an unexpected package status was detected. @@ -47,7 +50,5 @@ class UnsupportedPackageCodeHandlerException extends FrameworkException { // Call parent exception constructor parent::__construct($message, $code); } -} -// [EOF] -?> +} diff --git a/application/hub/exceptions/peer/class_PeerAlreadyRegisteredException.php b/application/hub/exceptions/peer/class_PeerAlreadyRegisteredException.php index 61c5c62e0..47ce2e0ce 100644 --- a/application/hub/exceptions/peer/class_PeerAlreadyRegisteredException.php +++ b/application/hub/exceptions/peer/class_PeerAlreadyRegisteredException.php @@ -5,6 +5,9 @@ namespace Hub\Peer; // Import application-specific stuff use Hub\Network\Package\NetworkPackage; +// Import framework stuff +use CoreFramework\Generic\FrameworkException; + /** * This exception is thrown when a peer is already registered * diff --git a/application/hub/exceptions/requests/class_NoRequestNodeListAttemptedException.php b/application/hub/exceptions/requests/class_NoRequestNodeListAttemptedException.php index 197a507da..13723c56d 100644 --- a/application/hub/exceptions/requests/class_NoRequestNodeListAttemptedException.php +++ b/application/hub/exceptions/requests/class_NoRequestNodeListAttemptedException.php @@ -1,4 +1,10 @@ +} diff --git a/application/hub/exceptions/resolver/class_NoValidHostnameException.php b/application/hub/exceptions/resolver/class_NoValidHostnameException.php index c4252e5f0..24a5ea7d8 100644 --- a/application/hub/exceptions/resolver/class_NoValidHostnameException.php +++ b/application/hub/exceptions/resolver/class_NoValidHostnameException.php @@ -39,7 +39,5 @@ class NoValidHostnameException extends FrameworkException { // Call parent exception constructor parent::__construct($message, $code); } -} -// [EOF] -?> +} diff --git a/application/hub/exceptions/stream/class_MultipleMessageSentException.php b/application/hub/exceptions/stream/class_MultipleMessageSentException.php index c42b4c324..f6ff77d76 100644 --- a/application/hub/exceptions/stream/class_MultipleMessageSentException.php +++ b/application/hub/exceptions/stream/class_MultipleMessageSentException.php @@ -1,4 +1,10 @@ +} diff --git a/application/hub/exceptions/tags/class_InvalidTagException.php b/application/hub/exceptions/tags/class_InvalidTagException.php index 719972a0e..24077c650 100644 --- a/application/hub/exceptions/tags/class_InvalidTagException.php +++ b/application/hub/exceptions/tags/class_InvalidTagException.php @@ -1,4 +1,10 @@ +} diff --git a/application/hub/exceptions/tasks/class_InvalidTaskException.php b/application/hub/exceptions/tasks/class_InvalidTaskException.php index d43d69d65..f2b57e650 100644 --- a/application/hub/exceptions/tasks/class_InvalidTaskException.php +++ b/application/hub/exceptions/tasks/class_InvalidTaskException.php @@ -39,7 +39,5 @@ class InvalidTaskException extends FrameworkException { // Call parent exception constructor parent::__construct($message, $code); } -} -// [EOF] -?> +} diff --git a/application/hub/exceptions/unl/class_InvalidUnlException.php b/application/hub/exceptions/unl/class_InvalidUnlException.php index fa43107c9..5187bf5c5 100644 --- a/application/hub/exceptions/unl/class_InvalidUnlException.php +++ b/application/hub/exceptions/unl/class_InvalidUnlException.php @@ -5,6 +5,9 @@ namespace Hub\Unl; // Import application-specific stuff use Hub\Network\Package\NetworkPackage; +// Import framework stuff +use CoreFramework\Generic\FrameworkException; + /** * This exception is thrown when a protocol handler cannot validate given package data's recipient (UNL). * @@ -47,7 +50,5 @@ class InvalidUnlException extends FrameworkException { // Call parent exception constructor parent::__construct($message, $code); } -} -// [EOF] -?> +} diff --git a/application/hub/exceptions/wrapper/class_NodeAlreadyRegisteredException.php b/application/hub/exceptions/wrapper/class_NodeAlreadyRegisteredException.php index d86dac21e..6d7baf54b 100644 --- a/application/hub/exceptions/wrapper/class_NodeAlreadyRegisteredException.php +++ b/application/hub/exceptions/wrapper/class_NodeAlreadyRegisteredException.php @@ -1,4 +1,10 @@