]> git.mxchange.org Git - hub.git/commitdiff
Continued: rewrites/message-array-to-instance
authorRoland Häder <roland@mxchange.org>
Sun, 26 Jan 2025 18:36:42 +0000 (19:36 +0100)
committerRoland Häder <roland@mxchange.org>
Sun, 26 Jan 2025 18:36:42 +0000 (19:36 +0100)
- private and final is not needed
- invoke getPrintableName() instead of raw "resource" class Socket (doesn't work)
- update 'core' framework

application/hub/classes/compressor/decorator/class_NetworkPackageCompressorDecorator.php
application/hub/classes/handler/package/class_NetworkPackageHandler.php
application/hub/classes/helper/connection/class_BaseConnectionHelper.php
application/hub/classes/helper/connection/ipv4/class_BaseIpV4ConnectionHelper.php
application/hub/classes/listener/class_BaseListener.php
application/hub/classes/pools/peer/class_DefaultPeerPool.php
application/hub/classes/producer/class_BaseProducer.php
application/hub/classes/template/xml/objects/class_XmlObjectRegistryTemplateEngine.php
application/hub/templates/xml/object_registry/object_registry.xml
core

index 68984a121ffee787b0fc7765ef9d551a79956b8c..e3e445efc94a01e1f0672a778fcdc1ba46df1ec3 100644 (file)
@@ -79,7 +79,7 @@ class NetworkPackageCompressorDecorator extends BaseHubSystem implements Compres
         *
         * @return      $compressorInstance             An instance of a Compressor class
         */
-       private final function getCompressorInstance () {
+       private function getCompressorInstance () {
                return $this->compressorInstance;
        }
 
index 1d3998479a73a56833994478301dd6c1a4f7c4d9..1dd2aee6688959698e8745ff911d9e82455cb77a 100644 (file)
@@ -421,7 +421,7 @@ class NetworkPackageHandler extends BaseHubHandler implements Deliverable, Recei
         *
         * @return      $compressorInstance             An instance of a Compressor class
         */
-       private final function getCompressorInstance () {
+       private function getCompressorInstance () {
                return $this->compressorInstance;
        }
 
index ef09ecf880d771e1cf6e5a3f82fe9a879ebd7dc3..69b7b68042ac104ef810885a6c013d8619e867b7 100644 (file)
@@ -175,7 +175,7 @@ abstract class BaseConnectionHelper extends BaseHubSystemHelper implements Visit
         * @param       $packageHandlerInstance The network package instance we shall set
         * @return      void
         */
-       private final function setPackageHandlerInstance (Deliverable $packageHandlerInstance) {
+       private function setPackageHandlerInstance (Deliverable $packageHandlerInstance) {
                $this->packageHandlerInstance = $packageHandlerInstance;
        }
 
@@ -368,7 +368,7 @@ abstract class BaseConnectionHelper extends BaseHubSystemHelper implements Visit
                $encodedData = $this->getOutputStreamInstance()->streamData($rawData);
 
                // Create data array
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-CONNECTION-HELPER: bufferSize=%d,rawData()=%d, this->socketResource[%s]=%s', $bufferSize, strlen($rawData), gettype($this->getSocketInstance()->getSocketResource()), $this->getSocketInstance()->getSocketResource()));
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-CONNECTION-HELPER: bufferSize=%d,rawData()=%d, this->socketResource[%s]=%s', $bufferSize, strlen($rawData), gettype($this->getSocketInstance()->getSocketResource()), $this->getSocketInstance()->getPrintableName()));
                $encodedDataArray = [
                        NetworkPackageHandler::RAW_INDEX_FINAL_HASH      => $this->currentFinalHash,
                        NetworkPackageHandler::RAW_INDEX_ENCODED_DATA    => $encodedData,
index 1daf7581ad0331ade5ad4b7cd57fa3cdee7e2a75..d27cacf5ae80b930ba1cc4855ad28670eb48081a 100644 (file)
@@ -107,24 +107,24 @@ abstract class BaseIpV4ConnectionHelper extends BaseConnectionHelper {
                $time = time();
 
                // This won't loop forever ...
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-IPV4-CONNECTION-HELPER: Trying to connect to %s with socketResource[%s]=%s ...', $this->getSocketInstance()->getSocketRecipientUnl(), gettype($this->getSocketInstance()->getSocketResource()), $this->getSocketInstance()->getSocketResource()));
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-IPV4-CONNECTION-HELPER: Trying to connect to %s with socketResource[%s]=%s ...', $this->getSocketInstance()->getSocketRecipientUnl(), gettype($this->getSocketInstance()->getSocketResource()), $this->getSocketInstance()->getPrintableName()));
                while (true) {
                        // Try to connect until it is connected
                        $isConnected = $this->getSocketInstance()->connectToSocketRecipient();
                        $socketError = $this->getSocketInstance()->getLastSocketErrorCode();
 
                        // Skip any errors which may happen on non-blocking connections
-                       /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-IPV4-CONNECTION-HELPER: socketResource=%s,socketError=%d (%s),isConnected=%s', $this->getSocketInstance()->getSocketResource(), $socketError, $this->getSocketInstance()->getLastSocketErrorMessage(), intval($isConnected)));
+                       /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-IPV4-CONNECTION-HELPER: socketResource=%s,socketError=%d (%s),isConnected=%s', $this->getSocketInstance()->getPrintableName(), $socketError, $this->getSocketInstance()->getLastSocketErrorMessage(), intval($isConnected)));
                        if ($socketError == SOCKET_EINPROGRESS) {
                                // "Operation in progress" is common for non-blocking I/O
-                               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-IPV4-CONNECTION-HELPER: socketResource=%s - BREAK!', $this->getSocketInstance()->getSocketResource()));
+                               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-IPV4-CONNECTION-HELPER: socketResource=%s - BREAK!', $this->getSocketInstance()->getPrintableName()));
                                break;
                        } elseif ($socketError == SOCKET_EALREADY) {
                                // Calculate passed time
                                $reached = (time() - $time);
 
                                // Now, is that attempt within parameters?
-                               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-IPV4-CONNECTION-HELPER: socketResource=%s,reached=%d,timeout=%d', $this->getSocketInstance()->getSocketResource(), $reached, $timeout));
+                               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-IPV4-CONNECTION-HELPER: socketResource=%s,reached=%d,timeout=%d', $this->getSocketInstance()->getPrintableName(), $reached, $timeout));
                                if ($reached >= $timeout) {
                                        // Didn't work within timeout
                                        /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-IPV4-CONNECTION-HELPER: timeout=%d reached, connection attempt failed. - BREAK!', $timeout));
@@ -137,7 +137,7 @@ abstract class BaseIpV4ConnectionHelper extends BaseConnectionHelper {
                                $this->idle(1000);
                        } elseif ($socketError != 0) {
                                // Stop on everything else pronto
-                               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-IPV4-CONNECTION-HELPER: socketResource=%s,socketError=%d detected, setting isConnected=FALSE - BREAK!', $this->getSocketInstance()->getSocketResource(), $socketError));
+                               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-IPV4-CONNECTION-HELPER: socketResource=%s,socketError=%d detected, setting isConnected=FALSE - BREAK!', $this->getSocketInstance()->getPrintableName(), $socketError));
                                $isConnected = FALSE;
                                break;
                        }
@@ -149,7 +149,7 @@ abstract class BaseIpV4ConnectionHelper extends BaseConnectionHelper {
                 * what is wanted here. This means, that all connections will end with
                 * isConnected=FALSE here.
                 */
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-IPV4-CONNECTION-HELPER: socketResource=%s,socketError=%d,isConnected=%d,hasTimedOut=%d after while() loop.', $this->getSocketInstance()->getSocketResource(), $socketError, intval($isConnected), intval($hasTimedOut)));
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-IPV4-CONNECTION-HELPER: socketResource=%s,socketError=%d,isConnected=%d,hasTimedOut=%d after while() loop.', $this->getSocketInstance()->getPrintableName(), $socketError, intval($isConnected), intval($hasTimedOut)));
                if (($hasTimedOut === FALSE) && ($socketError == SOCKET_EINPROGRESS)) {
                        // A "connection in progress" has not timed out. All fine.
                        /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-IPV4-CONNECTION-HELPER: Clearing "operation in progress" as this is for 99.999% chance a non-blocking I/O operation.');
@@ -160,7 +160,7 @@ abstract class BaseIpV4ConnectionHelper extends BaseConnectionHelper {
                }
 
                // Is the peer connected?
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-IPV4-CONNECTION-HELPER: socketResource=%s,socketError=%d,isConnected=%d,hasTimedOut=%d after while() loop.', $this->getSocketInstance()->getSocketResource(), $socketError, intval($isConnected), intval($hasTimedOut)));
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-IPV4-CONNECTION-HELPER: socketResource=%s,socketError=%d,isConnected=%d,hasTimedOut=%d after while() loop.', $this->getSocketInstance()->getPrintableName(), $socketError, intval($isConnected), intval($hasTimedOut)));
                if ($isConnected === TRUE) {
                        // Connection is fully established here, so change the state.
                        PeerStateFactory::createPeerStateInstanceByName('connected', $this);
index 162818462253eb0acb3648d7a5b33de533a90b96..b9228eb040fd71f00405009c6fcf6cde8c31a2c8 100644 (file)
@@ -395,7 +395,7 @@ abstract class BaseListener extends BaseHubSystem implements Visitable {
                /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('%s-LISTENER: CALLED!', strtoupper($this->getProtocolName())));
                if(!$this->getSocketInstance()->isValidSocket()) {
                        // Invalid socket
-                       throw new LogicException(sprintf('this->socketInstance->socketResource=%s is not valid', $this->getSocketInstance()->getSocketResource()));
+                       throw new LogicException(sprintf('this->socketInstance->socketResource=%s is not valid', $this->getSocketInstance()->getPrintableName()));
                }
 
                // Get next socket instance from pool over the factory
index c196735ca40b7dfc5e20abc1f700671a425f6671..af5d18ac756152236177a6c84f76fec9cee8f1f0 100644 (file)
@@ -273,7 +273,7 @@ class DefaultPeerPool extends BasePool implements PoolablePeer {
                                throw new InvalidConnectionTypeException(array($this, $connectionType), self::EXCEPTION_INVALID_CONNECTION_TYPE);
                        } elseif ((!empty($connectionType)) && ($socketArray[Poolable::SOCKET_ARRAY_CONN_TYPE] !== $connectionType)) {
                                // Skip unwanted sockets
-                               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('DEFAULT-PEER-POOL: Skipping unwanted socket %s of type %s/%s ...', $socketArray[Poolable::SOCKET_ARRAY_INSTANCE]->getSocketResource(), $socketArray[Poolable::SOCKET_ARRAY_CONN_TYPE], $connectionType));
+                               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('DEFAULT-PEER-POOL: Skipping unwanted socket %s of type %s/%s ...', $socketArray[Poolable::SOCKET_ARRAY_INSTANCE]->getPrintableName(), $socketArray[Poolable::SOCKET_ARRAY_CONN_TYPE], $connectionType));
                                continue;
                        }
 
@@ -282,7 +282,7 @@ class DefaultPeerPool extends BasePool implements PoolablePeer {
                        $peerPort    = 0;
 
                        // Try to get the "peer"'s name
-                       /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('DEFAULT-PEER-POOL: socketInstance->socketResource=%s,socketInstance->socketProtocol=%s,socketArray[%s]=%s', $socketArray[Poolable::SOCKET_ARRAY_INSTANCE]->getSocketResource(), $socketArray[Poolable::SOCKET_ARRAY_INSTANCE]->getSocketProtocol(), Poolable::SOCKET_ARRAY_CONN_TYPE, $socketArray[Poolable::SOCKET_ARRAY_CONN_TYPE]));
+                       /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('DEFAULT-PEER-POOL: socketInstance->socketResource=%s,socketInstance->socketProtocol=%s,socketArray[%s]=%s', $socketArray[Poolable::SOCKET_ARRAY_INSTANCE]->getPrintableName(), $socketArray[Poolable::SOCKET_ARRAY_INSTANCE]->getSocketProtocol(), Poolable::SOCKET_ARRAY_CONN_TYPE, $socketArray[Poolable::SOCKET_ARRAY_CONN_TYPE]));
                        if (!$socketArray[Poolable::SOCKET_ARRAY_INSTANCE]->determineSocketPeerName($peerAddress, $peerPort)) {
                                // Handle the socket error with given package data
                                $socketArray[Poolable::SOCKET_ARRAY_INSTANCE]->handleSocketError(__METHOD__, __LINE__);
@@ -295,7 +295,7 @@ class DefaultPeerPool extends BasePool implements PoolablePeer {
                                $socketInstance = $socketArray[Poolable::SOCKET_ARRAY_INSTANCE];
 
                                // Debug message
-                               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('DEFAULT-PEER-POOL: peerAddress=%s matches with recipient IP address. Taking socketResource=%s,type=%s', $peerAddress, $socketArray[Poolable::SOCKET_ARRAY_INSTANCE]->getSocketResource(), $socketArray[Poolable::SOCKET_ARRAY_CONN_TYPE]));
+                               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('DEFAULT-PEER-POOL: peerAddress=%s matches with recipient IP address. Taking socketResource=%s,type=%s', $peerAddress, $socketArray[Poolable::SOCKET_ARRAY_INSTANCE]->getPrintableName(), $socketArray[Poolable::SOCKET_ARRAY_CONN_TYPE]));
                                break;
                        }
                }
index 3ab0b0b4fc7faa4a1189c8245204984ff4168932..a034c78098769985930a3abb9431842d21e7119c 100644 (file)
@@ -85,7 +85,7 @@ abstract class BaseProducer extends BaseHubSystem {
         * @param       $outgoingQueueInstance  The outgoing work queue instance
         * @return      void
         */
-       private final function setOutgoingQueueInstance (Stackable $outgoingQueueInstance) {
+       private function setOutgoingQueueInstance (Stackable $outgoingQueueInstance) {
                $this->outgoingQueueInstance = $outgoingQueueInstance;
        }
 
@@ -104,7 +104,7 @@ abstract class BaseProducer extends BaseHubSystem {
         * @param       $incomingQueueInstance  The incoming raw data/items queue instance
         * @return      void
         */
-       private final function setIncomingQueueInstance (Stackable $incomingQueueInstance) {
+       private function setIncomingQueueInstance (Stackable $incomingQueueInstance) {
                $this->incomingQueueInstance = $incomingQueueInstance;
        }
 
index 077e751aabfca59323c1b787981255fde1b3b40a..7e7744b73c59533964183aad8efc8ba5032f3ffd 100644 (file)
@@ -149,11 +149,9 @@ class XmlObjectRegistryTemplateEngine extends BaseXmlTemplateEngine implements C
        /**
         * Starts the object-list
         *
-        * @param       $objectCount    Count of all objects
         * @return      void
-        * @todo        Handle $objectCount
         */
-       protected function startObjectList ($objectCount) {
+       protected function startObjectList () {
                // Push the node name on the stacker
                $this->getStackInstance()->pushNamed('node_object_registry', 'object-list');
        }
index 339ccc74367fc42ab199a87442ce2c97438e976a..e4c744e888e8338a590d9de6e1da9730da6da7b4 100644 (file)
@@ -31,7 +31,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
        If you don't do so, you may be banned because of unknown object types your
        node tries to advertise/share.
        //-->
-       <object-list object-count="{?object_count?}">
+       <object-list>
                <!-- A single object type we want to share. //-->
                <object-list-entry>
                        <!-- The actual name, this must be the same as tag names are. //-->
diff --git a/core b/core
index b0d8c80500e1b796f2398c44f20b36173bfc4d6c..5ec2948a189cd111b497146270034c9740aa6be5 160000 (submodule)
--- a/core
+++ b/core
@@ -1 +1 @@
-Subproject commit b0d8c80500e1b796f2398c44f20b36173bfc4d6c
+Subproject commit 5ec2948a189cd111b497146270034c9740aa6be5