]> git.mxchange.org Git - hub.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Tue, 10 May 2022 19:31:18 +0000 (21:31 +0200)
committerRoland Häder <roland@mxchange.org>
Tue, 10 May 2022 22:52:25 +0000 (00:52 +0200)
- added more debug lines
- $encodedData was a one-usage local variable and can be avoided for more
  compact and hopefully easier code

Signed-off-by: Roland Häder <roland@mxchange.org>
application/hub/classes/container/socket/class_SocketContainer.php
application/hub/classes/helper/connection/class_BaseConnectionHelper.php
application/hub/classes/info/connection/class_ConnectionInfo.php
application/hub/classes/listener/class_BaseListener.php

index e65cb7b2b17d21fd5f4102cce5d10bde86a40935..fca7dd3a782db159326e734a10f70d9230de41d7 100644 (file)
@@ -914,7 +914,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita
                $listenerInstance = $infoInstance->getListenerInstance();
                $helperInstance = $infoInstance->getHelperInstance();
 
-               // Is there a listener instance set?
+               // Is there a listener or a connection helper instance set?
                /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: listenerInstance[]=%s,helperInstance[]=%s', strtoupper($this->getSocketProtocol()), gettype($listenerInstance), gettype($helperInstance)));
                if ($listenerInstance instanceof Listenable) {
                        // Set it here for later usage
index d78d6ec0b0fb4953fb4d095ccbb04cde85af8116..6350345a22f5b1e528a94d6aaccbdaf857a6f556 100644 (file)
@@ -327,6 +327,7 @@ abstract class BaseConnectionHelper extends BaseHubSystemHelper implements Visit
                }
 
                // Reset serial number
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-CONNECTION-HELPER: Resetting serial number for this->currentFinalHash=%s ...', $this->currentFinalHash));
                $this->getFragmenterInstance()->resetSerialNumber($this->currentFinalHash);
 
                // Init variables
@@ -334,6 +335,7 @@ abstract class BaseConnectionHelper extends BaseHubSystemHelper implements Visit
                $dataStream     = ' ';
 
                // Fill sending buffer with data
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-CONNECTION-HELPER: while(true) loop - START!');
                while (TRUE) {
                        // Convert the package data array to a raw data stream
                        /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-CONNECTION-HELPER: dataStream()=%d - BEFORE!', strlen($dataStream)));
@@ -363,14 +365,10 @@ abstract class BaseConnectionHelper extends BaseHubSystemHelper implements Visit
                $bufferSize = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry($this->getProtocolName() . '_buffer_length');
 
                // Encode the raw data with our output-stream
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-CONNECTION-HELPER: bufferSize=%d', $bufferSize));
-               $encodedData = $this->getOutputStreamInstance()->streamData($rawData);
-
-               // Init array
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-CONNECTION-HELPER: socketResource[%s]=%s', gettype($this->getSocketInstance()->getSocketResource()), $this->getSocketInstance()->getSocketResource()));
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-CONNECTION-HELPER: bufferSize=%d, socketResource[%s]=%s', $bufferSize, gettype($this->getSocketInstance()->getSocketResource()), $this->getSocketInstance()->getSocketResource()));
                $encodedDataArray = [
                        NetworkPackageHandler::RAW_INDEX_FINAL_HASH      => $this->currentFinalHash,
-                       NetworkPackageHandler::RAW_INDEX_ENCODED_DATA    => $encodedData,
+                       NetworkPackageHandler::RAW_INDEX_ENCODED_DATA    => $this->getOutputStreamInstance()->streamData($rawData),
                        NetworkPackageHandler::RAW_INDEX_SENT_BYTES      => 0,
                        NetworkPackageHandler::RAW_INDEX_SOCKET_INSTANCE => $this->getSocketInstance(),
                        NetworkPackageHandler::RAW_INDEX_BUFFER_SIZE     => $bufferSize,
@@ -378,6 +376,7 @@ abstract class BaseConnectionHelper extends BaseHubSystemHelper implements Visit
                ];
 
                // Push raw data to the package's outgoing stack
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-CONNECTION-HELPER: Pushing %d large array on stack %s ...', count($encodedDataArray), NetworkPackageHandler::STACKER_NAME_OUTGOING_STREAM));
                $this->getPackageHandlerInstance()->getStackInstance()->pushNamed(NetworkPackageHandler::STACKER_NAME_OUTGOING_STREAM, $encodedDataArray);
 
                // Trace message
index 533185861776096b16227b14caff3402e58e057c..4b6557bfb91808f5e56f9cc6bbf77e721aa39fbc 100644 (file)
@@ -205,13 +205,14 @@ class ConnectionInfo extends BaseInfo implements ShareableInfo, Registerable {
                $socketPort    = 0;
 
                // Get peer name
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('CONNECTION-INFO: Calling socketInstance->determineSocketPeerName(%s,%d) ...', $socketAddress, $socketPort));
                if (!$socketInstance->determineSocketPeerName($socketAddress, $socketPort)) {
                        // Did not work
                        throw new InvalidSocketException(array($this, $socketInstance->getSocketResource()), self::EXCEPTION_INVALID_SOCKET);
                }
 
                // Fill the generic array with several data from the listener:
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('CONNECTION-INFO: socketAddress=%s,socketPort=%d', $socketAddress, $socketPort));
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('CONNECTION-INFO: Setting socketInstance->socketProtocol=%s,socketAddress=%s,socketPort=%d', $socketInstance->getSocketProtocol(), $socketAddress, $socketPort));
                $this->setProtocolName($socketInstance->getSocketProtocol());
                $this->setGenericArrayElement('connection', 'dummy', 'dummy', LocateableNode::UNL_PART_ADDRESS , $socketAddress);
                $this->setGenericArrayElement('connection', 'dummy', 'dummy', LocateableNode::UNL_PART_PORT    , $socketPort);
index 3a7ffd8a51d905f5fe9c04171ded53b7abf21348..d7358883746f323710ecad202215c8ad59ab5d0b 100644 (file)
@@ -248,7 +248,7 @@ abstract class BaseListener extends BaseHubSystem implements Visitable {
                $infoInstance->fillWithListenerInformation($this);
 
                // Register the socket
-               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-LISTENER: Registering socketInstance->socketResource=%s,socketType=%s', strtoupper($this->getProtocolName()), $socketInstance->getSocketResource(), $socketInstance->getSocketType()));
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-LISTENER: Registering socketInstance->socketResource=%s,socketType=%s ...', strtoupper($this->getProtocolName()), $socketInstance->getSocketResource(), $socketInstance->getSocketType()));
                $this->getRegistryInstance()->registerSocketInstance($infoInstance, $socketInstance);
 
                // And set it here
@@ -402,6 +402,7 @@ abstract class BaseListener extends BaseHubSystem implements Visitable {
                }
 
                // Get a connection info instance
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-LISTENER: Creating infoInstance for connection type %s ...', strtoupper($this->getProtocolName()), StorableSocket::CONNECTION_TYPE_INCOMING));
                $infoInstance = ConnectionInfoFactory::createConnectionInfoInstance($this->getProtocolName(), StorableSocket::CONNECTION_TYPE_INCOMING);
 
                // Is the instance set?
@@ -412,6 +413,7 @@ abstract class BaseListener extends BaseHubSystem implements Visitable {
                }
 
                // Will the info instance with listener data
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-LISTENER: Calling infoInstance->fillWithSocketPeerInformation(%s) ...', strtoupper($this->getProtocolName()), $socketInstance->__toString()));
                $infoInstance->fillWithSocketPeerInformation($socketInstance);
 
                // Init peer address/port
@@ -426,13 +428,16 @@ abstract class BaseListener extends BaseHubSystem implements Visitable {
 
                // Set all required data
                //* DEBUG-DIE: */ $infoInstance->debugInstance();
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-LISTENER: peerAddress=%s,peerPort=%d', strtoupper($this->getProtocolName()), $peerAddress, $peerPort));
                $socketInstance->setSenderAddress($peerAddress);
                $socketInstance->setSenderPort($peerPort);
 
                // Register the socket with the registry and with the faked array
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-LISTENER: Registering socketInstance->socketResource=%s,socketType=%s ...', strtoupper($this->getProtocolName()), $socketInstance->getSocketResource(), $socketInstance->getSocketType()));
                $this->getRegistryInstance()->registerSocketInstance($infoInstance, $socketInstance);
 
                // Invoke private method
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-LISTENER: Calling this->handleIncomingSocket(%s) ...', strtoupper($this->getProtocolName()), $socketInstance->__toString()));
                $this->handleIncomingSocket($socketInstance);
 
                // Trace message