From 2416ca956db4d3903bd1e8a5794620c304311eef Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Sat, 17 Jun 2017 22:39:55 +0200 Subject: [PATCH] Continued a bit: - implemented info-filler method with data from socket peer - implemented enableSocketOutOfBandData() - commented out many noisy debug lines - made some debug lines to noisy, as they are really noisy under PHP 7 - some small fixes (e.g. tpzo in method name) - updated 'core' framework to latest commit MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- .../socket/class_SocketContainer.php | 169 +++++++++--------- ...odeDistributedHashTableDatabaseWrapper.php | 68 +++---- .../class_NodeInformationDatabaseWrapper.php | 6 +- .../class_PeerStateLookupDatabaseWrapper.php | 18 +- .../decoder/package/class_PackageDecoder.php | 10 +- .../socket/class_PackageSocketDiscovery.php | 32 ++-- .../class_UniversalNodeLocatorFactory.php | 2 +- .../factories/socket/class_SocketFactory.php | 38 ++-- .../class_CommunicatorStateFactory.php | 4 +- .../crawler/class_CrawlerStateFactory.php | 4 +- .../cruncher/class_CruncherStateFactory.php | 4 +- .../states/miner/class_MinerStateFactory.php | 4 +- .../states/node/class_NodeStateFactory.php | 4 +- .../states/peer/class_PeerStateFactory.php | 12 +- .../handler/chunks/class_ChunkHandler.php | 36 ++-- .../handler/data/class_BaseDataHandler.php | 8 +- .../protocol/class_BaseProtocolHandler.php | 8 +- .../ipv4/class_BaseIpV4ProtocolHandler.php | 6 +- .../raw_data/class_BaseRawDataHandler.php | 16 +- .../connection/class_BaseConnectionHelper.php | 38 ++-- .../helper/dht/class_DhtBootstrapHelper.php | 6 +- .../info/connection/class_ConnectionInfo.php | 51 +++++- .../classes/listener/class_BaseListener.php | 36 ++-- .../listener/class_BaseListenerDecorator.php | 18 +- .../socket/class_SocketFileListener.php | 10 +- .../listener/tcp/class_TcpListener.php | 4 +- .../listener/udp/class_UdpListener.php | 4 +- .../locator/class_UniversalNodeLocator.php | 10 +- .../hub/classes/nodes/class_BaseHubNode.php | 14 +- .../assembler/class_PackageAssembler.php | 18 +- .../classes/package/class_NetworkPackage.php | 116 ++++++------ .../fragmenter/class_PackageFragmenter.php | 32 ++-- .../hub/classes/pools/class_BasePool.php | 55 +++--- .../listener/class_DefaultListenerPool.php | 15 +- .../pools/peer/class_DefaultPeerPool.php | 24 +-- .../registry/socket/class_SocketRegistry.php | 45 ++--- .../output/class_RawDataOutputStream.php | 10 +- .../class_NetworkPackageReaderTask.php | 22 +-- .../class_NetworkPackageWriterTask.php | 16 +- .../listener/class_NodeSocketListenerTask.php | 2 +- .../hub/classes/tools/class_HubTools.php | 20 +-- .../class_RawDataPoolMonitorVisitor.php | 8 +- .../class_ShutdownListenerPoolVisitor.php | 16 +- .../visitor/tasks/class_ActiveTaskVisitor.php | 23 +-- .../shareable/info/class_ShareableInfo.php | 9 + core | 2 +- 46 files changed, 565 insertions(+), 508 deletions(-) diff --git a/application/hub/classes/container/socket/class_SocketContainer.php b/application/hub/classes/container/socket/class_SocketContainer.php index 851041b06..2d7a90160 100644 --- a/application/hub/classes/container/socket/class_SocketContainer.php +++ b/application/hub/classes/container/socket/class_SocketContainer.php @@ -132,19 +132,19 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita */ public function ifAddressMatches ($unl) { // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: unl=%s - CALLED!', strtoupper($this->getSocketProtocol()), $unl)); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: unl=%s - CALLED!', strtoupper($this->getSocketProtocol()), $unl)); // Get current package data $packageData = $this->getPackageData(); // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($this->getSocketProtocol()) . '-SOCKET: unl=' . $unl . ',packageData=' . print_r($packageData, true)); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($this->getSocketProtocol()) . '-SOCKET: unl=' . $unl . ',packageData=' . print_r($packageData, true)); // So, does both match? $matches = ((isset($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT])) && ($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT] === $unl)); // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: matches=%d - EXIT!', strtoupper($this->getSocketProtocol()), intval($matches))); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: matches=%d - EXIT!', strtoupper($this->getSocketProtocol()), intval($matches))); // Return result return $matches; @@ -158,13 +158,13 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita */ public function ifSocketResourceMatches ($socketResource) { // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($this->getSocketProtocol()) . '-SOCKET: socketResource[' . gettype($socketResource) . ']=' .$socketResource . ',storedResource[' . gettype($this->getSocketResource()) . ']=' . $this->getSocketResource()); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($this->getSocketProtocol()) . '-SOCKET: socketResource[' . gettype($socketResource) . ']=' .$socketResource . ',storedResource[' . gettype($this->getSocketResource()) . ']=' . $this->getSocketResource()); // So, does both match? $matches = ((is_resource($socketResource)) && ($socketResource === $this->getSocketResource())); // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: matches=%d - EXIT!', strtoupper($this->getSocketProtocol()), intval($matches))); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: matches=%d - EXIT!', strtoupper($this->getSocketProtocol()), intval($matches))); // Return result return $matches; @@ -190,7 +190,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita $this->accept($visitorInstance); // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($this->getSocketProtocol()) . '-SOCKET: EXIT!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($this->getSocketProtocol()) . '-SOCKET: EXIT!'); } /** @@ -213,7 +213,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita $this->accept($visitorInstance); // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($this->getSocketProtocol()) . '-SOCKET: EXIT!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($this->getSocketProtocol()) . '-SOCKET: EXIT!'); } /** @@ -243,7 +243,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita */ public function getSocketPeerName (&$peerAddress, &$peerPort) { // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: peerAddress=%s,peerPort=%d - CALLED!', strtoupper($this->getSocketProtocol()), $peerAddress, $peerPort)); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: peerAddress=%s,peerPort=%d - CALLED!', strtoupper($this->getSocketProtocol()), $peerAddress, $peerPort)); // Should be valid socket if (!$this->isValidSocket()) { @@ -268,7 +268,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita } // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: peerAddress=%s,peerPort=%d,result[%s]=%d - EXIT!', strtoupper($this->getSocketProtocol()), $peerAddress, $peerPort, gettype($result), intval($result))); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: peerAddress=%s,peerPort=%d,result[%s]=%d - EXIT!', strtoupper($this->getSocketProtocol()), $peerAddress, $peerPort, gettype($result), intval($result))); // Return result return $result; @@ -293,7 +293,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita */ public function getSocketRecipient () { // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: CALLED!', strtoupper($this->getSocketProtocol()))); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: CALLED!', strtoupper($this->getSocketProtocol()))); // Should be valid socket if (!$this->isValidSocket()) { @@ -311,7 +311,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita } // END - if // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: packageData[%s]=%s - EXIT!', strtoupper($this->getSocketProtocol()), NetworkPackage::PACKAGE_DATA_RECIPIENT, $packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT])); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: packageData[%s]=%s - EXIT!', strtoupper($this->getSocketProtocol()), NetworkPackage::PACKAGE_DATA_RECIPIENT, $packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT])); // Return it return $packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT]; @@ -325,7 +325,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita */ public function getSocketRecipientAddress () { // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: CALLED!', strtoupper($this->getSocketProtocol()))); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: CALLED!', strtoupper($this->getSocketProtocol()))); // Should be valid socket if (!$this->isValidSocket()) { @@ -343,7 +343,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita $recipientAddress = $unlInstance->getUnlAddress(); // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: recipientAddress=%s - EXIT!', strtoupper($this->getSocketProtocol()), $recipientAddress)); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: recipientAddress=%s - EXIT!', strtoupper($this->getSocketProtocol()), $recipientAddress)); // Return it return $recipientAddress; @@ -357,7 +357,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita */ public function getSocketRecipientPort () { // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: CALLED!', strtoupper($this->getSocketProtocol()))); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: CALLED!', strtoupper($this->getSocketProtocol()))); // Should be valid socket if (!$this->isValidSocket()) { @@ -375,7 +375,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita $recipientPort = $unlInstance->getUnlPort(); // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: recipientPort=%d - EXIT!', strtoupper($this->getSocketProtocol()), intval($recipientPort))); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: recipientPort=%d - EXIT!', strtoupper($this->getSocketProtocol()), intval($recipientPort))); // Return it return $recipientPort; @@ -389,7 +389,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita */ public function isValidSocket () { // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: CALLED!', strtoupper($this->getSocketProtocol()))); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: CALLED!', strtoupper($this->getSocketProtocol()))); // Get socket resource $socketResource = $this->getSocketResource(); @@ -399,7 +399,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita $isValidSocket = (is_resource($socketResource)); // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: isValidSocket=%d - EXIT!', strtoupper($this->getSocketProtocol()), intval($isValidSocket))); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: isValidSocket=%d - EXIT!', strtoupper($this->getSocketProtocol()), intval($isValidSocket))); // Return status return $isValidSocket; @@ -413,7 +413,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita */ public function getLastSocketErrorCode () { // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: CALLED!', strtoupper($this->getSocketProtocol()))); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: CALLED!', strtoupper($this->getSocketProtocol()))); // Should be valid socket if (!$this->isValidSocket()) { @@ -428,7 +428,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita $errorCode = socket_last_error($socketResource); // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: errorCode=%d - EXIT!', strtoupper($this->getSocketProtocol()), intval($errorCode))); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: errorCode=%d - EXIT!', strtoupper($this->getSocketProtocol()), intval($errorCode))); // Return it return $errorCode; @@ -442,7 +442,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita */ public function getLastSocketErrorMessage () { // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: CALLED!', strtoupper($this->getSocketProtocol()))); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: CALLED!', strtoupper($this->getSocketProtocol()))); // Should be valid socket if (!$this->isValidSocket()) { @@ -467,7 +467,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita */ public function translateLastSocketErrorCodeToName () { // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: CALLED!', strtoupper($this->getSocketProtocol()))); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: CALLED!', strtoupper($this->getSocketProtocol()))); // Get last error code $errorCode = $this->getLastSocketErrorCode(); @@ -476,7 +476,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita $codeName = $this->translateSocketErrorCodeToName($errorCode); // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: codeName=%s - EXIT!', strtoupper($this->getSocketProtocol()), $codeName)); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: codeName=%s - EXIT!', strtoupper($this->getSocketProtocol()), $codeName)); // Return it return $codeName; @@ -492,7 +492,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita */ public function bindSocketTo ($bindAddress, $bindPort = 0) { // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: CALLED!', strtoupper($this->getSocketProtocol()))); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: CALLED!', strtoupper($this->getSocketProtocol()))); // Should be valid socket if (!$this->isValidSocket()) { @@ -504,7 +504,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita $result = socket_bind($this->getSocketResource(), $bindAddress, $bindPort); // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: result=%d - EXIT!', strtoupper($this->getSocketProtocol()), intval($result))); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: result=%d - EXIT!', strtoupper($this->getSocketProtocol()), intval($result))); // Return result return $result; @@ -518,7 +518,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita */ public function listenToSocket () { // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: CALLED!', strtoupper($this->getSocketProtocol()))); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: CALLED!', strtoupper($this->getSocketProtocol()))); // Should be valid socket if (!$this->isValidSocket()) { @@ -530,7 +530,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita $result = socket_listen($this->getSocketResource()); // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: result=%d - EXIT!', strtoupper($this->getSocketProtocol()), intval($result))); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: result=%d - EXIT!', strtoupper($this->getSocketProtocol()), intval($result))); // Return result return $result; @@ -544,7 +544,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita */ public function enableSocketNonBlocking () { // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: CALLED!', strtoupper($this->getSocketProtocol()))); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: CALLED!', strtoupper($this->getSocketProtocol()))); // Should be valid socket if (!$this->isValidSocket()) { @@ -556,7 +556,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita $result = socket_set_nonblock($this->getSocketResource()); // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: result=%d - EXIT!', strtoupper($this->getSocketProtocol()), intval($result))); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: result=%d - EXIT!', strtoupper($this->getSocketProtocol()), intval($result))); // Return result return $result; @@ -570,7 +570,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita */ public function enableSocketReuseAddress () { // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: CALLED!', strtoupper($this->getSocketProtocol()))); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: CALLED!', strtoupper($this->getSocketProtocol()))); // Should be valid socket if (!$this->isValidSocket()) { @@ -582,7 +582,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita $result = $this->setSocketOption(SOL_SOCKET, SO_REUSEADDR, 1); // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: result=%d - EXIT!', strtoupper($this->getSocketProtocol()), intval($result))); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: result=%d - EXIT!', strtoupper($this->getSocketProtocol()), intval($result))); // Return result return $result; @@ -596,7 +596,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita */ public function connectToSocketRecipient () { // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: CALLED!', strtoupper($this->getSocketProtocol()))); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: CALLED!', strtoupper($this->getSocketProtocol()))); // Should be valid socket if (!$this->isValidSocket()) { @@ -608,19 +608,19 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita $unlRecipient = $this->getSocketRecipient(); // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: unlRecipient=%s', strtoupper($this->getSocketProtocol()), $unlRecipient)); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: unlRecipient=%s', strtoupper($this->getSocketProtocol()), $unlRecipient)); // Create UNL instance from it. This will validate the connection $unlInstance = UniversalNodeLocatorFactory::createUnlInstanceFromString($unlRecipient); // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: unlAddress=%s,unlPort=%d', strtoupper($this->getSocketProtocol()), $unlInstance->getUnlAddress(), $unlInstance->getUnlPort())); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: unlAddress=%s,unlPort=%d', strtoupper($this->getSocketProtocol()), $unlInstance->getUnlAddress(), $unlInstance->getUnlPort())); // Try to connect to it $result = socket_connect($this->getSocketResource(), $unlInstance->getUnlAddress(), $unlInstance->getUnlPort()); // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: result=%d - EXIT!', strtoupper($this->getSocketProtocol()), intval($result))); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: result=%d - EXIT!', strtoupper($this->getSocketProtocol()), intval($result))); // Return result return $result; @@ -637,7 +637,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita */ public function doShutdown () { // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: CALLED!', strtoupper($this->getSocketProtocol()))); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: CALLED!', strtoupper($this->getSocketProtocol()))); // Should be valid socket if (!$this->isValidSocket()) { @@ -675,7 +675,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita $this->markConnectionShuttedDown(); // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($this->getSocketProtocol()) . '-SOCKET: EXIT!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($this->getSocketProtocol()) . '-SOCKET: EXIT!'); } /** @@ -686,13 +686,13 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita */ public function isValidConnectionType ($connectionType) { // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: connectionType=%d - CALLED!', strtoupper($this->getSocketProtocol()), $connectionType)); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: connectionType=%d - CALLED!', strtoupper($this->getSocketProtocol()), $connectionType)); // Is it valid? $isValid = in_array($connectionType, $this->connectionTypes, TRUE); // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: isValid=%d - EXIT!', strtoupper($this->getSocketProtocol()), intval($isValid))); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: isValid=%d - EXIT!', strtoupper($this->getSocketProtocol()), intval($isValid))); // Return result return $isValid; @@ -706,7 +706,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita */ public function acceptNewIncomingSocket () { // Trace message - /* EXTREME-NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: CALLED!', strtoupper($this->getSocketProtocol()))); + //* EXTREME-NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: CALLED!', strtoupper($this->getSocketProtocol()))); // Should be valid socket if (!$this->isValidSocket()) { @@ -715,7 +715,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita } // END - if // Debug message - /* EXTREME-NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: this->socketResource=%s', strtoupper($this->getSocketProtocol()), $this->getSocketResource())); + //* EXTREME-NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: this->socketResource=%s', strtoupper($this->getSocketProtocol()), $this->getSocketResource())); // Init all arrays, at least readers $readers = array($this->getSocketResource()); @@ -723,7 +723,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita $excepts = array(); // Trace message - /* EXTREME-NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: Calling socket_select(%d,%d,%d,0%d) ...', strtoupper($this->getSocketProtocol()), count($readers), count($writers), count($excepts), $this->socketSelectTimeout)); + //* EXTREME-NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: Calling socket_select(%d,%d,%d,0%d) ...', strtoupper($this->getSocketProtocol()), count($readers), count($writers), count($excepts), $this->socketSelectTimeout)); // Check if we have some peers left $left = socket_select( @@ -735,7 +735,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita ); // Debug message - /* EXTREME-NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: left=%d,readers()=%d,writers()=%d,except()=%d) ...', strtoupper($this->getSocketProtocol()), $left, count($readers), count($writers), count($excepts))); + //* EXTREME-NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: left=%d,readers()=%d,writers()=%d,except()=%d) ...', strtoupper($this->getSocketProtocol()), $left, count($readers), count($writers), count($excepts))); // Some new peers found? if ($left < 1) { @@ -747,7 +747,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita } // END - if // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($this->getSocketProtocol()) . '-SOCKET: serverSocket=' . $this->getSocketResource() . ',readers=' . print_r($readers, true)); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($this->getSocketProtocol()) . '-SOCKET: serverSocket=' . $this->getSocketResource() . ',readers=' . print_r($readers, true)); // Do we have changed peers? if (!in_array($this->getSocketResource(), $readers)) { @@ -765,7 +765,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita $socketResource = socket_accept($this->getSocketResource()); // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($this->getSocketProtocol()) . '-SOCKET: socketResource=' . $socketResource . ',serverSocket=' .$this->getSocketResource()); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($this->getSocketProtocol()) . '-SOCKET: socketResource=' . $socketResource . ',serverSocket=' .$this->getSocketResource()); // Create socket instance from it $socketInstance = SocketFactory::createIncomingSocketInstance($socketResource, $this->getSocketProtocol()); @@ -802,7 +802,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita } // END - if // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: result=%d - EXIT!', strtoupper($this->getSocketProtocol()), intval($result))); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: result=%d - EXIT!', strtoupper($this->getSocketProtocol()), intval($result))); // Return result return $result; @@ -815,7 +815,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita */ public function setSocketTimeoutOptions () { // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: CALLED!', strtoupper($this->getSocketProtocol()))); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: CALLED!', strtoupper($this->getSocketProtocol()))); // Array for timeout settings $options = array( @@ -829,7 +829,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita $result = $this->setSocketOption(SOL_SOCKET, SO_RCVTIMEO, $options); // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: result=%d - EXIT!', strtoupper($this->getSocketProtocol()), intval($result))); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: result=%d - EXIT!', strtoupper($this->getSocketProtocol()), intval($result))); // Return result return $result; @@ -842,9 +842,16 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita */ public function enableSocketOutOfBandData () { // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: CALLED!', strtoupper($this->getSocketProtocol()))); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: CALLED!', strtoupper($this->getSocketProtocol()))); - $this->partialStub('Please implement this method.'); + // Call inner method + $result = $this->setSocketOption(SOL_SOCKET, SO_OOBINLINE, 1); + + // Trace message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: result=%d - EXIT!', strtoupper($this->getSocketProtocol()), intval($result))); + + // Return result + return $result; } /** @@ -856,7 +863,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita */ public function clearLastSocketError () { // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($this->getSocketProtocol()) . '-SOCKET: Clearing socket error - CALLED!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($this->getSocketProtocol()) . '-SOCKET: Clearing socket error - CALLED!'); // Should be valid socket if (!$this->isValidSocket()) { @@ -871,7 +878,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita socket_clear_error($this->getSocketResource()); // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($this->getSocketProtocol()) . '-SOCKET: Error cleared - EXIT!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($this->getSocketProtocol()) . '-SOCKET: Error cleared - EXIT!'); } /** @@ -883,32 +890,32 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita */ public function registerInfoInstance (ShareableInfo $infoInstance) { // Trace message - /* NOSY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: Calling infoInstance->getListenerInstance() - CALLED!', strtoupper($this->getSocketProtocol()))); + //* NOSY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: Calling infoInstance->getListenerInstance() - CALLED!', strtoupper($this->getSocketProtocol()))); // Get listener/helper from info class $listenerInstance = $infoInstance->getListenerInstance(); $helperInstance = $infoInstance->getHelperInstance(); // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($this->getSocketProtocol()) . '-SOCKET: listenerInstance[]=' . gettype($listenerInstance) . ',helperInstance[]=' . gettype($helperInstance)); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($this->getSocketProtocol()) . '-SOCKET: listenerInstance[]=' . gettype($listenerInstance) . ',helperInstance[]=' . gettype($helperInstance)); // Is there a listener instance set? if ($listenerInstance instanceof Listenable) { // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($this->getSocketProtocol()) . '-SOCKET: Setting listenerInstance=' . $listenerInstance->__toString() . ' ...'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($this->getSocketProtocol()) . '-SOCKET: Setting listenerInstance=' . $listenerInstance->__toString() . ' ...'); // Set it here for later usage $this->setListenerInstance($listenerInstance); } elseif ($helperInstance instanceof ConnectionHelper) { // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($this->getSocketProtocol()) . '-SOCKET: Setting helperInstance=' . $helperInstance->__toString() . ' ...'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($this->getSocketProtocol()) . '-SOCKET: Setting helperInstance=' . $helperInstance->__toString() . ' ...'); // Set it here for later usage $this->setHelperInstance($helperInstance); } // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($this->getSocketProtocol()) . '-SOCKET: EXIT!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($this->getSocketProtocol()) . '-SOCKET: EXIT!'); } /** @@ -927,7 +934,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita */ public function writeBufferToSocketByArray (array &$socketBuffer, &$sentBytes) { // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: socketBuffer()=%d,sentBytes=%d - CALLED!', strtoupper($this->getSocketProtocol()), count($socketBuffer), $sentBytes)); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: socketBuffer()=%d,sentBytes=%d - CALLED!', strtoupper($this->getSocketProtocol()), count($socketBuffer), $sentBytes)); // Should be valid socket if (!$this->isValidSocket()) { @@ -948,18 +955,18 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita } // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: Sending out %d bytes,rawBufferSize=%d,diff=%d to socketResource=%s', strtoupper($this->getSocketProtocol()), strlen($socketBuffer[NetworkPackage::RAW_INDEX_ENCODED_DATA]), $socketBuffer[NetworkPackage::RAW_INDEX_BUFFER_SIZE], $socketBuffer[NetworkPackage::RAW_INDEX_DIFF], $this->getSocketResource())); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: Sending out %d bytes,rawBufferSize=%d,diff=%d to socketResource=%s', strtoupper($this->getSocketProtocol()), strlen($socketBuffer[NetworkPackage::RAW_INDEX_ENCODED_DATA]), $socketBuffer[NetworkPackage::RAW_INDEX_BUFFER_SIZE], $socketBuffer[NetworkPackage::RAW_INDEX_DIFF], $this->getSocketResource())); // Is some data still pending or sent all out? if ($socketBuffer[NetworkPackage::RAW_INDEX_DIFF] >= 0) { // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: MD5=%s', strtoupper($this->getSocketProtocol()), md5(substr($socketBuffer[NetworkPackage::RAW_INDEX_ENCODED_DATA], 0, ($socketBuffer[NetworkPackage::RAW_INDEX_BUFFER_SIZE] - $socketBuffer[NetworkPackage::RAW_INDEX_DIFF]))))); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: MD5=%s', strtoupper($this->getSocketProtocol()), md5(substr($socketBuffer[NetworkPackage::RAW_INDEX_ENCODED_DATA], 0, ($socketBuffer[NetworkPackage::RAW_INDEX_BUFFER_SIZE] - $socketBuffer[NetworkPackage::RAW_INDEX_DIFF]))))); // Send all out (encodedData is smaller than or equal buffer size) $sentBytes = socket_write($this->getSocketResource(), $socketBuffer[NetworkPackage::RAW_INDEX_ENCODED_DATA], ($socketBuffer[NetworkPackage::RAW_INDEX_BUFFER_SIZE] - $socketBuffer[NetworkPackage::RAW_INDEX_DIFF])); } else { // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: MD5=%s', strtoupper($this->getSocketProtocol()), md5(substr($socketBuffer[NetworkPackage::RAW_INDEX_ENCODED_DATA], 0, $socketBuffer[NetworkPackage::RAW_INDEX_BUFFER_SIZE])))); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: MD5=%s', strtoupper($this->getSocketProtocol()), md5(substr($socketBuffer[NetworkPackage::RAW_INDEX_ENCODED_DATA], 0, $socketBuffer[NetworkPackage::RAW_INDEX_BUFFER_SIZE])))); // Send buffer size out $sentBytes = socket_write($this->getSocketResource(), $socketBuffer[NetworkPackage::RAW_INDEX_ENCODED_DATA], $socketBuffer[NetworkPackage::RAW_INDEX_BUFFER_SIZE]); @@ -970,18 +977,18 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita $result = ($sentBytes !== FALSE); // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: sentBytes[%s]=%d,result=%d', strtoupper($this->getSocketProtocol()), gettype($sentBytes), $sentBytes, intval($result))); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: sentBytes[%s]=%d,result=%d', strtoupper($this->getSocketProtocol()), gettype($sentBytes), $sentBytes, intval($result))); // If there was an error, don't continue here if ($result === FALSE) { // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: socket_write() failed, please evalutate. - EXIT!', strtoupper($this->getSocketProtocol()))); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: socket_write() failed, please evalutate. - EXIT!', strtoupper($this->getSocketProtocol()))); // Failed delivery! return FALSE; } elseif (($sentBytes === 0) && (strlen($socketBuffer[NetworkPackage::RAW_INDEX_ENCODED_DATA]) > 0)) { // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: All sent, returning TRUE ... - EXIT!', strtoupper($this->getSocketProtocol()))); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: All sent, returning TRUE ... - EXIT!', strtoupper($this->getSocketProtocol()))); // Nothing sent means all data has been sent return TRUE; @@ -993,7 +1000,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita $socketBuffer[NetworkPackage::RAW_INDEX_SENT_BYTES] += $sentBytes; // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: Sent out %d of %d bytes ...', strtoupper($this->getSocketProtocol()), $sentBytes, strlen($socketBuffer[NetworkPackage::RAW_INDEX_ENCODED_DATA]))); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: Sent out %d of %d bytes ...', strtoupper($this->getSocketProtocol()), $sentBytes, strlen($socketBuffer[NetworkPackage::RAW_INDEX_ENCODED_DATA]))); // Cut out the last unsent bytes $socketBuffer[NetworkPackage::RAW_INDEX_ENCODED_DATA] = substr($socketBuffer[NetworkPackage::RAW_INDEX_ENCODED_DATA], $sentBytes); @@ -1003,7 +1010,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita } // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: result=%d - EXIT!', strtoupper($this->getSocketProtocol()), intval($result))); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: result=%d - EXIT!', strtoupper($this->getSocketProtocol()), intval($result))); // Return result return $result; @@ -1024,7 +1031,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita */ public function handleSocketError ($method, $line, array $socketData) { // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('HUB-SYSTEM: Handling socket errorCode=%d - CALLED!', $this->getLastSocketErrorCode())); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('HUB-SYSTEM: Handling socket errorCode=%d - CALLED!', $this->getLastSocketErrorCode())); // This method handles only socket resources if (!$this->isValidSocket()) { @@ -1056,7 +1063,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita $this->clearLastSocketError(); // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($this->getSocketProtocol()) . '-SOCKET: EXIT!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($this->getSocketProtocol()) . '-SOCKET: EXIT!'); } /** @@ -1069,7 +1076,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita */ protected function getSocketErrorHandlerFromCode ($errorCode) { // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: errorCode=%d - CALLED!', strtoupper($this->getSocketProtocol()), $errorCode)); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: errorCode=%d - CALLED!', strtoupper($this->getSocketProtocol()), $errorCode)); // Create a name from translated error code $handlerName = 'handleSocketError' . self::convertToClassName($this->translateSocketErrorCodeToName($errorCode)); @@ -1081,7 +1088,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita } // END - if // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: handlerName=%d - EXIT!', strtoupper($this->getSocketProtocol()), $handlerName)); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: handlerName=%d - EXIT!', strtoupper($this->getSocketProtocol()), $handlerName)); // Return it return $handlerName; @@ -1101,7 +1108,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita */ protected function handleSocketErrorPermissionDenied (array $socketData) { // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: socketData()=%d - CALLED!', strtoupper($this->getSocketProtocol()), count($socketData))); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: socketData()=%d - CALLED!', strtoupper($this->getSocketProtocol()), count($socketData))); // Get socket error code for verification $socketError = $this->getLastSocketErrorCode(); @@ -1126,7 +1133,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita */ protected function handleSocketErrorConnectionTimedOut (array $socketData) { // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: socketData()=%d - CALLED!', strtoupper($this->getSocketProtocol()), count($socketData))); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: socketData()=%d - CALLED!', strtoupper($this->getSocketProtocol()), count($socketData))); // Get socket error code for verification $socketError = $this->getLastSocketErrorCode(); @@ -1151,7 +1158,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita */ protected function handleSocketErrorResourceUnavailable (array $socketData) { // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: socketData()=%d - CALLED!', strtoupper($this->getSocketProtocol()), count($socketData))); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: socketData()=%d - CALLED!', strtoupper($this->getSocketProtocol()), count($socketData))); // Get socket error code for verification $socketError = $this->getLastSocketErrorCode(); @@ -1176,7 +1183,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita */ protected function handleSocketErrorConnectionRefused (array $socketData) { // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: socketData()=%d - CALLED!', strtoupper($this->getSocketProtocol()), count($socketData))); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: socketData()=%d - CALLED!', strtoupper($this->getSocketProtocol()), count($socketData))); // Get socket error code for verification $socketError = $this->getLastSocketErrorCode(); @@ -1201,7 +1208,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita */ protected function handleSocketErrorNoRouteToHost (array $socketData) { // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: socketData()=%d - CALLED!', strtoupper($this->getSocketProtocol()), count($socketData))); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: socketData()=%d - CALLED!', strtoupper($this->getSocketProtocol()), count($socketData))); // Get socket error code for verification $socketError = $this->getLastSocketErrorCode(); @@ -1226,7 +1233,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita */ protected function handleSocketErrorOperationAlreadyProgress (array $socketData) { // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: socketData()=%d - CALLED!', strtoupper($this->getSocketProtocol()), count($socketData))); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: socketData()=%d - CALLED!', strtoupper($this->getSocketProtocol()), count($socketData))); // Get socket error code for verification $socketError = $this->getLastSocketErrorCode(); @@ -1251,7 +1258,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita */ protected function handleSocketErrorConnectionResetByPeer (array $socketData) { // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: socketData()=%d - CALLED!', strtoupper($this->getSocketProtocol()), count($socketData))); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: socketData()=%d - CALLED!', strtoupper($this->getSocketProtocol()), count($socketData))); // Get socket error code for verification $socketError = $this->getLastSocketErrorCode(); @@ -1276,7 +1283,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita */ protected function handleSocketErrorOperationNotSupported (array $socketData) { // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: socketData()=%d - CALLED!', strtoupper($this->getSocketProtocol()), count($socketData))); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: socketData()=%d - CALLED!', strtoupper($this->getSocketProtocol()), count($socketData))); // Get socket error code for verification $socketError = $this->getLastSocketErrorCode(); @@ -1300,7 +1307,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita */ protected function handleSocketErrorOperationInProgress (array $socketData) { // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: socketData()=%d - CALLED!', strtoupper($this->getSocketProtocol()), count($socketData))); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: socketData()=%d - CALLED!', strtoupper($this->getSocketProtocol()), count($socketData))); self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($this->getSocketProtocol()) . '-HELPER: Operation is now in progress, this is usual for non-blocking connections and is no bug.'); } @@ -1318,7 +1325,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita */ private function translateSocketErrorCodeToName ($errorCode) { // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: errorCode=%d - CALLED!', strtoupper($this->getSocketProtocol()), $errorCode)); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: errorCode=%d - CALLED!', strtoupper($this->getSocketProtocol()), $errorCode)); // Nothing bad happened by default $errorName = StorableSocket::SOCKET_CONNECTED; @@ -1384,7 +1391,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita } // END - switch // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: errorName=%d - EXIT!', strtoupper($this->getSocketProtocol()), $errorName)); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: errorName=%d - EXIT!', strtoupper($this->getSocketProtocol()), $errorName)); // Return translated name return $errorName; @@ -1411,7 +1418,7 @@ class SocketContainer extends BaseHubContainer implements StorableSocket, Visita */ private function setSocketOption ($level, $optionName, $optionValue) { // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: level=%s,optionName=%s,optionValue[%s]=%s - CALLED!', strtoupper($this->getSocketProtocol()), $level, $optionName, gettype($optionValue), implode(',', $optionValue))); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('%s-SOCKET: level=%s,optionName=%s,optionValue[%s]=%s - CALLED!', strtoupper($this->getSocketProtocol()), $level, $optionName, gettype($optionValue), implode(',', $optionValue))); // Should be valid socket if (!$this->isValidSocket()) { diff --git a/application/hub/classes/database/frontend/node/class_NodeDistributedHashTableDatabaseWrapper.php b/application/hub/classes/database/frontend/node/class_NodeDistributedHashTableDatabaseWrapper.php index 1b90bde43..f6cac3c04 100644 --- a/application/hub/classes/database/frontend/node/class_NodeDistributedHashTableDatabaseWrapper.php +++ b/application/hub/classes/database/frontend/node/class_NodeDistributedHashTableDatabaseWrapper.php @@ -122,7 +122,7 @@ class NodeDistributedHashTableDatabaseWrapper extends BaseHubDatabaseWrapper imp */ private function prepareSearchInstance (array $nodeData) { // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: CALLED!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: CALLED!'); // Assert on array elements assert(isset($nodeData[self::DB_COLUMN_NODE_ID])); @@ -135,7 +135,7 @@ class NodeDistributedHashTableDatabaseWrapper extends BaseHubDatabaseWrapper imp $searchInstance->setLimit(1); // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: EXIT!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: EXIT!'); // Return it return $searchInstance; @@ -159,7 +159,7 @@ class NodeDistributedHashTableDatabaseWrapper extends BaseHubDatabaseWrapper imp */ private function prepareLocalDataSetInstance () { // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: CALLED!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: CALLED!'); // Get node/request instances $nodeInstance = NodeObjectFactory::createNodeInstance(); @@ -197,7 +197,7 @@ class NodeDistributedHashTableDatabaseWrapper extends BaseHubDatabaseWrapper imp $dataSetInstance->addCriteria(self::DB_COLUMN_ACCEPT_BOOTSTRAP, $this->translateBooleanToYesNo($nodeInstance->isAcceptingDhtBootstrap())); // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: EXIT!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: EXIT!'); // Return it return $dataSetInstance; @@ -211,7 +211,7 @@ class NodeDistributedHashTableDatabaseWrapper extends BaseHubDatabaseWrapper imp */ public function isLocalNodeRegistered () { // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: CALLED!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: CALLED!'); // Get a search criteria instance $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class'); @@ -240,7 +240,7 @@ class NodeDistributedHashTableDatabaseWrapper extends BaseHubDatabaseWrapper imp $isRegistered = $resultInstance->valid(); // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: isRegistered=' . intval($isRegistered) . ' - EXIT!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: isRegistered=' . intval($isRegistered) . ' - EXIT!'); // Return result return $isRegistered; @@ -253,7 +253,7 @@ class NodeDistributedHashTableDatabaseWrapper extends BaseHubDatabaseWrapper imp */ public function registerLocalNode () { // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: CALLED!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: CALLED!'); // Assert to make sure this method is called with no record in DB (the actual backend of the DHT) assert(!$this->isLocalNodeRegistered()); @@ -265,7 +265,7 @@ class NodeDistributedHashTableDatabaseWrapper extends BaseHubDatabaseWrapper imp $this->queryInsertDataSet($dataSetInstance); // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: EXIT!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: EXIT!'); } /** @@ -276,7 +276,7 @@ class NodeDistributedHashTableDatabaseWrapper extends BaseHubDatabaseWrapper imp */ public function updateLocalNode () { // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: CALLED!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: CALLED!'); // Assert to make sure this method is called with one record in DB (the actual backend of the DHT) assert($this->isLocalNodeRegistered()); @@ -301,7 +301,7 @@ class NodeDistributedHashTableDatabaseWrapper extends BaseHubDatabaseWrapper imp $this->queryUpdateDataSet($dataSetInstance); // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: EXIT!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: EXIT!'); } /** @@ -312,7 +312,7 @@ class NodeDistributedHashTableDatabaseWrapper extends BaseHubDatabaseWrapper imp */ public function findNodeLocalBySessionId ($sessionId) { // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: sessionId=' . $sessionId . ' - CALLED!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: sessionId=' . $sessionId . ' - CALLED!'); // Get search criteria $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class'); @@ -325,7 +325,7 @@ class NodeDistributedHashTableDatabaseWrapper extends BaseHubDatabaseWrapper imp $resultInstance = $this->doSelectByCriteria($searchInstance); // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: resultInstance->valid()=' . intval($resultInstance->valid()) . ' - EXIT!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: resultInstance->valid()=' . intval($resultInstance->valid()) . ' - EXIT!'); // Return result instance return $resultInstance; @@ -340,7 +340,7 @@ class NodeDistributedHashTableDatabaseWrapper extends BaseHubDatabaseWrapper imp */ public function registerNodeByMessageData (array $messageData, HandleableDataSet $handlerInstance) { // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: handlerInstance=' . $handlerInstance->__toString() . ' - CALLED!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: handlerInstance=' . $handlerInstance->__toString() . ' - CALLED!'); // Get a data set instance $dataSetInstance = ObjectFactory::createObjectByConfiguredName('dataset_criteria_class', array(self::DB_TABLE_NODE_DHT)); @@ -358,7 +358,7 @@ class NodeDistributedHashTableDatabaseWrapper extends BaseHubDatabaseWrapper imp $this->queryInsertDataSet($dataSetInstance); // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER - EXIT!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER - EXIT!'); } /** @@ -371,7 +371,7 @@ class NodeDistributedHashTableDatabaseWrapper extends BaseHubDatabaseWrapper imp */ public function updateNodeByMessageData (array $messageData, HandleableDataSet $handlerInstance, LocalSearchCriteria $searchInstance) { // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: CALLED!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: CALLED!'); // Get a data set instance $dataSetInstance = ObjectFactory::createObjectByConfiguredName('dataset_criteria_class', array(self::DB_TABLE_NODE_DHT)); @@ -392,7 +392,7 @@ class NodeDistributedHashTableDatabaseWrapper extends BaseHubDatabaseWrapper imp $this->queryUpdateDataSet($dataSetInstance); // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: EXIT!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: EXIT!'); } /** @@ -403,13 +403,13 @@ class NodeDistributedHashTableDatabaseWrapper extends BaseHubDatabaseWrapper imp */ public function isNodeRegistered (array $nodeData) { // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: CALLED!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: CALLED!'); // Assert on array elements assert(isset($nodeData[self::DB_COLUMN_NODE_ID])); // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: node-id=' . $nodeData[self::DB_COLUMN_NODE_ID]); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: node-id=' . $nodeData[self::DB_COLUMN_NODE_ID]); // Get search criteria $searchInstance = $this->prepareSearchInstance($nodeData); @@ -429,7 +429,7 @@ class NodeDistributedHashTableDatabaseWrapper extends BaseHubDatabaseWrapper imp $isRegistered = $resultInstance->valid(); // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: isRegistered=' . intval($isRegistered) . ' - EXIT!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: isRegistered=' . intval($isRegistered) . ' - EXIT!'); // Return registration status return $isRegistered; @@ -445,7 +445,7 @@ class NodeDistributedHashTableDatabaseWrapper extends BaseHubDatabaseWrapper imp */ public function registerNode (array $nodeData) { // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: CALLED!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: CALLED!'); // Assert on array elements assert(isset($nodeData[self::DB_COLUMN_NODE_ID])); @@ -460,7 +460,7 @@ class NodeDistributedHashTableDatabaseWrapper extends BaseHubDatabaseWrapper imp $this->partialStub('nodeData=' . print_r($nodeData, TRUE)); // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: EXIT!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: EXIT!'); } /** @@ -474,13 +474,13 @@ class NodeDistributedHashTableDatabaseWrapper extends BaseHubDatabaseWrapper imp */ public function updateNode (array $nodeData) { // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: CALLED!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: CALLED!'); // Assert on array elements assert(isset($nodeData[self::DB_COLUMN_NODE_ID])); // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: Updating DHT entry for node-id=' . $nodeData[self::DB_COLUMN_NODE_ID] . ' ...'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: Updating DHT entry for node-id=' . $nodeData[self::DB_COLUMN_NODE_ID] . ' ...'); // Is the node registered? if (!$this->isNodeRegistered($nodeData)) { @@ -504,7 +504,7 @@ class NodeDistributedHashTableDatabaseWrapper extends BaseHubDatabaseWrapper imp $nodeInstance = NodeObjectFactory::createNodeInstance(); // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: nodeData=' . print_r($nodeData, TRUE)); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: nodeData=' . print_r($nodeData, TRUE)); // Add all array elements $nodeInstance->addArrayToDataSet($dataSetInstance, $nodeData); @@ -516,7 +516,7 @@ class NodeDistributedHashTableDatabaseWrapper extends BaseHubDatabaseWrapper imp $this->queryUpdateDataSet($dataSetInstance); // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: EXIT!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: EXIT!'); } /** @@ -542,7 +542,7 @@ class NodeDistributedHashTableDatabaseWrapper extends BaseHubDatabaseWrapper imp $hasUnpublished = $this->unpublishedEntriesInstance->valid(); // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: EXIT!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: EXIT!'); // Return it return $hasUnpublished; @@ -558,7 +558,7 @@ class NodeDistributedHashTableDatabaseWrapper extends BaseHubDatabaseWrapper imp */ public function initEntryPublication () { // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: CALLED!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: CALLED!'); /* * Make sure that hasUnpublishedEntries() has been called first by @@ -590,7 +590,7 @@ class NodeDistributedHashTableDatabaseWrapper extends BaseHubDatabaseWrapper imp $this->queryUpdateDataSet($dataSetInstance); // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: EXIT!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: EXIT!'); } /** @@ -601,9 +601,9 @@ class NodeDistributedHashTableDatabaseWrapper extends BaseHubDatabaseWrapper imp */ public function removeNonPublicDataFromArray(array $data) { // Currently call only inner method - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: Calling parent::removeNonPublicDataFromArray(data) ...'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: Calling parent::removeNonPublicDataFromArray(data) ...'); $data = parent::removeNonPublicDataFromArray($data); - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: data[]=' . gettype($data)); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: data[]=' . gettype($data)); // Return cleaned data return $data; @@ -617,7 +617,7 @@ class NodeDistributedHashTableDatabaseWrapper extends BaseHubDatabaseWrapper imp */ public function getResultFromExcludedSender (array $packageData) { // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: CALLED!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: CALLED!'); // Assert on required array field assert(isset($packageData[NetworkPackage::PACKAGE_DATA_SENDER_ADDRESS])); @@ -638,7 +638,7 @@ class NodeDistributedHashTableDatabaseWrapper extends BaseHubDatabaseWrapper imp $resultInstance = $this->doSelectByCriteria($searchInstance); // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: EXIT!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: EXIT!'); // Return result instance return $resultInstance; @@ -654,7 +654,7 @@ class NodeDistributedHashTableDatabaseWrapper extends BaseHubDatabaseWrapper imp */ public function getResultFromKeyValue ($key, $value) { // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: CALLED!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: CALLED!'); // Get max recipients $maxRecipients = $this->getConfigInstance()->getConfigEntry('max_dht_recipients'); @@ -669,7 +669,7 @@ class NodeDistributedHashTableDatabaseWrapper extends BaseHubDatabaseWrapper imp $resultInstance = $this->doSelectByCriteria($searchInstance); // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: EXIT!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-WRAPPER: EXIT!'); // Return result instance return $resultInstance; diff --git a/application/hub/classes/database/frontend/node/class_NodeInformationDatabaseWrapper.php b/application/hub/classes/database/frontend/node/class_NodeInformationDatabaseWrapper.php index a7e40a57c..e7bc717ec 100644 --- a/application/hub/classes/database/frontend/node/class_NodeInformationDatabaseWrapper.php +++ b/application/hub/classes/database/frontend/node/class_NodeInformationDatabaseWrapper.php @@ -190,13 +190,11 @@ class NodeInformationDatabaseWrapper extends BaseHubDatabaseWrapper implements N */ public function removeNonPublicDataFromArray(array $data) { // Currently call only inner method - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NODE-WRAPPER: Calling parent::removeNonPublicDataFromArray(data) ...'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NODE-WRAPPER: Calling parent::removeNonPublicDataFromArray(data) ...'); $data = parent::removeNonPublicDataFromArray($data); // Return cleaned data return $data; } -} -// [EOF] -?> +} diff --git a/application/hub/classes/database/frontend/states/class_PeerStateLookupDatabaseWrapper.php b/application/hub/classes/database/frontend/states/class_PeerStateLookupDatabaseWrapper.php index 3591a81f3..9d015e542 100644 --- a/application/hub/classes/database/frontend/states/class_PeerStateLookupDatabaseWrapper.php +++ b/application/hub/classes/database/frontend/states/class_PeerStateLookupDatabaseWrapper.php @@ -88,7 +88,7 @@ class PeerStateLookupDatabaseWrapper extends BaseHubDatabaseWrapper implements L */ private function getSenderSearchInstanceFromPackageData (array $packageData) { // Get the instance - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DATABASE-WRAPPER: Searching for sender ' . $packageData[NetworkPackage::PACKAGE_DATA_SENDER_ADDRESS]); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PEER-STATE-DATABASE-WRAPPER: Searching for sender ' . $packageData[NetworkPackage::PACKAGE_DATA_SENDER_ADDRESS]); $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class'); // Add 'sender' as the peer's IP address @@ -108,7 +108,7 @@ class PeerStateLookupDatabaseWrapper extends BaseHubDatabaseWrapper implements L */ public function isSenderNewPeer (array $packageData, StoreableCriteria $dataSetInstance = NULL) { // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DATABASE-WRAPPER: ' . __FUNCTION__ . ' called with packageData()=' . count($packageData) . ' - CALLED!'); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PEER-STATE-DATABASE-WRAPPER: packageData()=' . count($packageData) . ' - CALLED!'); // Is the package valid? if (!isset($packageData[NetworkPackage::PACKAGE_DATA_SENDER_ADDRESS])) { @@ -129,11 +129,11 @@ class PeerStateLookupDatabaseWrapper extends BaseHubDatabaseWrapper implements L $entries = $this->doSelectCountByCriteria($searchInstance, array(self::DB_COLUMN_PEER_SESSION_ID => TRUE)); // Is it there? - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DATABASE-WRAPPER: entries=' . $entries); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PEER-STATE-DATABASE-WRAPPER: entries=' . $entries); $isNewPeer = ($entries != 1); // Return the result - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DATABASE-WRAPPER: isNewPeer=' . intval($isNewPeer) . ' - EXIT!'); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PEER-STATE-DATABASE-WRAPPER: isNewPeer=' . intval($isNewPeer) . ' - EXIT!'); return $isNewPeer; } @@ -180,7 +180,7 @@ class PeerStateLookupDatabaseWrapper extends BaseHubDatabaseWrapper implements L $this->queryInsertDataSet($dataSetInstance, array(self::DB_COLUMN_PEER_SESSION_ID => TRUE)); // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DATABASE-WRAPPER: Peer ' . $packageData[NetworkPackage::PACKAGE_DATA_SENDER_ADDRESS] . ' has been registered.'); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PEER-STATE-DATABASE-WRAPPER: Peer ' . $packageData[NetworkPackage::PACKAGE_DATA_SENDER_ADDRESS] . ' has been registered.'); } /** @@ -223,7 +223,7 @@ class PeerStateLookupDatabaseWrapper extends BaseHubDatabaseWrapper implements L } // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DATABASE-WRAPPER: Peer ' . $packageData[NetworkPackage::PACKAGE_DATA_SENDER_ADDRESS] . ' has been registered/updated with state ' . $stateInstance->getStateName()); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PEER-STATE-DATABASE-WRAPPER: Peer ' . $packageData[NetworkPackage::PACKAGE_DATA_SENDER_ADDRESS] . ' has been registered/updated with state ' . $stateInstance->getStateName()); } /** @@ -247,7 +247,7 @@ class PeerStateLookupDatabaseWrapper extends BaseHubDatabaseWrapper implements L */ public function isSamePeerState (ConnectionHelper $helperInstance, array $packageData) { // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DATABASE-WRAPPER: State ' . $helperInstance->getPrintableState() . ' needs to be checked it has changed ...'); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PEER-STATE-DATABASE-WRAPPER: State ' . $helperInstance->getPrintableState() . ' needs to be checked it has changed ...'); // Now get the search instance from given package data $searchInstance = $this->getSenderSearchInstanceFromPackageData($packageData); @@ -262,7 +262,7 @@ class PeerStateLookupDatabaseWrapper extends BaseHubDatabaseWrapper implements L $rowData = $resultInstance->current(); // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DATABASE-WRAPPER: rowData[' . gettype($rowData) . ']=' . print_r($rowData, TRUE)); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PEER-STATE-DATABASE-WRAPPER: rowData[' . gettype($rowData) . ']=' . print_r($rowData, TRUE)); // Assert on important elements assert(isset($rowData[self::DB_COLUMN_PEER_STATE])); @@ -271,7 +271,7 @@ class PeerStateLookupDatabaseWrapper extends BaseHubDatabaseWrapper implements L $isSamePeerState = ($rowData[self::DB_COLUMN_PEER_STATE] == $helperInstance->getPrintableState()); // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DATABASE-WRAPPER: state in database: ' . $rowData[self::DB_COLUMN_PEER_STATE] . ', new state: ' . $helperInstance->getPrintableState() . ',isSamePeerState=' . intval($isSamePeerState)); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PEER-STATE-DATABASE-WRAPPER: state in database: ' . $rowData[self::DB_COLUMN_PEER_STATE] . ', new state: ' . $helperInstance->getPrintableState() . ',isSamePeerState=' . intval($isSamePeerState)); // Return it return $isSamePeerState; diff --git a/application/hub/classes/decoder/package/class_PackageDecoder.php b/application/hub/classes/decoder/package/class_PackageDecoder.php index 32e0ee894..6fce31941 100644 --- a/application/hub/classes/decoder/package/class_PackageDecoder.php +++ b/application/hub/classes/decoder/package/class_PackageDecoder.php @@ -88,7 +88,7 @@ class PackageDecoder extends BaseDecoder implements Decodeable, Registerable { $unhandledDataLeft = (!$this->getHandlerInstance()->getStackInstance()->isStackEmpty(ChunkHandler::STACKER_NAME_ASSEMBLED_RAW_DATA)); // Return it - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-DECODER: unhandledDataLeft=' . intval($unhandledDataLeft)); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-DECODER: unhandledDataLeft=' . intval($unhandledDataLeft)); return $unhandledDataLeft; } @@ -105,7 +105,7 @@ class PackageDecoder extends BaseDecoder implements Decodeable, Registerable { $rawPackageContent = $this->getHandlerInstance()->getStackInstance()->popNamed(ChunkHandler::STACKER_NAME_ASSEMBLED_RAW_DATA); // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-DECODER: Got ' . strlen($rawPackageContent) . ' bytes from stack ' . ChunkHandler::STACKER_NAME_ASSEMBLED_RAW_DATA . ', decoding it ...'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-DECODER: Got ' . strlen($rawPackageContent) . ' bytes from stack ' . ChunkHandler::STACKER_NAME_ASSEMBLED_RAW_DATA . ', decoding it ...'); // "Decode" the raw package content by using the NetworkPackage instance $decodedData = $this->getPackageInstance()->decodeRawContent($rawPackageContent); @@ -121,7 +121,7 @@ class PackageDecoder extends BaseDecoder implements Decodeable, Registerable { ); // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-DECODER: decodedData(' . count($decodedData) . ')=' . print_r($decodedData, TRUE)); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-DECODER: decodedData(' . count($decodedData) . ')=' . print_r($decodedData, TRUE)); // Next get a recipient-discovery instance $discoveryInstance = PackageDiscoveryFactory::createPackageDiscoveryInstance(); @@ -132,7 +132,7 @@ class PackageDecoder extends BaseDecoder implements Decodeable, Registerable { // Check for 'recipient' field (the 'sender' field and others are ignored here) if ($discoveryInstance->isRecipientListEmpty()) { // The recipient is this node so next stack it on 'decoded_package' - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-DECODER: Pushing ' . strlen($decodedData) . ' bytes to stack ' . self::STACKER_NAME_DECODED_PACKAGE . ' ...'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-DECODER: Pushing ' . strlen($decodedData) . ' bytes to stack ' . self::STACKER_NAME_DECODED_PACKAGE . ' ...'); $this->getHandlerInstance()->getStackInstance()->pushNamed(self::STACKER_NAME_DECODED_PACKAGE, $decodedData); } else { // Forward the package to the next node @@ -166,7 +166,7 @@ class PackageDecoder extends BaseDecoder implements Decodeable, Registerable { $decodedData = $this->getHandlerInstance()->getStackInstance()->popNamed(self::STACKER_NAME_DECODED_PACKAGE); // Handle it - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-DECODER: decodedData(' . count($decodedData) . ')=' . print_r($decodedData, TRUE)); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-DECODER: decodedData(' . count($decodedData) . ')=' . print_r($decodedData, TRUE)); $this->getPackageInstance()->handleRawData($decodedData); } diff --git a/application/hub/classes/discovery/recipient/socket/class_PackageSocketDiscovery.php b/application/hub/classes/discovery/recipient/socket/class_PackageSocketDiscovery.php index 64655b1a8..71a808d25 100644 --- a/application/hub/classes/discovery/recipient/socket/class_PackageSocketDiscovery.php +++ b/application/hub/classes/discovery/recipient/socket/class_PackageSocketDiscovery.php @@ -67,7 +67,7 @@ class PackageSocketDiscovery extends BaseRecipientDiscovery implements Discovera $discoveryInstance = new PackageSocketDiscovery(); // Output debug message - self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-DISCOVERY: Initialized.'); + self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-SOCKET-DISCOVERY: Initialized.'); // Return the prepared instance return $discoveryInstance; @@ -82,7 +82,7 @@ class PackageSocketDiscovery extends BaseRecipientDiscovery implements Discovera */ public function discoverListenerInstance (HandleableProtocol $protocolInstance, array $packageData) { // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-DISCOVERY: protocolInstance=' . $protocolInstance->__toString() . ' - CALLED!'); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-SOCKET-DISCOVERY: protocolInstance=' . $protocolInstance->__toString() . ' - CALLED!'); /* * Get the listener pool instance, we need to lookup the matching @@ -97,7 +97,7 @@ class PackageSocketDiscovery extends BaseRecipientDiscovery implements Discovera $protocolName = $protocolInstance->getProtocolName(); // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-DISCOVERY: protocolName=' . $protocolName); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-SOCKET-DISCOVERY: protocolName=' . $protocolName); // Debugging //* DEBUG-DIE: */ die(__METHOD__.':poolInstance='.print_r($poolInstance, TRUE)); @@ -110,27 +110,27 @@ class PackageSocketDiscovery extends BaseRecipientDiscovery implements Discovera */ foreach ($poolInstance->getArrayFromList($protocolName) as $listenerInstance) { // Debug output - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-DISCOVERY: protocolName=' . $protocolName . ',listenerInstance[' . gettype($listenerInstance) . ']=' . $listenerInstance); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-SOCKET-DISCOVERY: protocolName=' . $protocolName . ',listenerInstance[' . gettype($listenerInstance) . ']=' . $listenerInstance); // Make sure the instance is valid assert($listenerInstance instanceof Listenable); // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('SOCKET-DISCOVERY: Calling listenerInstance->ifListenerAcceptsPackageData(%d) ...', count($packageData))); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('PACKAGE-SOCKET-DISCOVERY: Calling listenerInstance->ifListenerAcceptsPackageData(%d) ...', count($packageData))); // Does the listener want that package? if ($listenerInstance->ifListenerAcceptsPackageData($packageData)) { // This listener likes our package data, so abort here - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('SOCKET-DISCOVERY: Listener "%s" is accepting package data.', $listenerInstance->__toString())); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('PACKAGE-SOCKET-DISCOVERY: Listener "%s" is accepting package data.', $listenerInstance->__toString())); break; } // END - if // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-DISCOVERY: Listener is NOT accepting package data.'); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-SOCKET-DISCOVERY: Listener is NOT accepting package data.'); } // END - foreach // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-DISCOVERY: listenerInstance=' . $listenerInstance->__toString()); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-SOCKET-DISCOVERY: listenerInstance=' . $listenerInstance->__toString()); // Return it return $listenerInstance; @@ -175,7 +175,7 @@ class PackageSocketDiscovery extends BaseRecipientDiscovery implements Discovera $listenerInstance = $this->discoverListenerInstance($protocolInstance, $packageData); // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('listenerInstance=' . $listenerInstance . ',packageData=' . print_r($packageData, TRUE)); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-SOCKET-DISCOVERY: listenerInstance=' . $listenerInstance . ',packageData=' . print_r($packageData, TRUE)); // If there is no listener who wants to have that package, we simply drop it here if (is_null($listenerInstance)) { @@ -183,7 +183,7 @@ class PackageSocketDiscovery extends BaseRecipientDiscovery implements Discovera throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER); } elseif (is_null($listenerInstance->getPoolInstance())) { // Opps another one - throw new LogicException(sprintf('listenerInstance=%s has no poolInstance set.', $listenerInstance->__toString()), self::EXCEPTION_IS_NULL_POINTER); + throw new LogicException(sprintf('PACKAGE-SOCKET-DISCOVERY: listenerInstance=%s has no poolInstance set.', $listenerInstance->__toString()), self::EXCEPTION_IS_NULL_POINTER); } /* @@ -195,20 +195,20 @@ class PackageSocketDiscovery extends BaseRecipientDiscovery implements Discovera $socketInstance = $listenerInstance->getPoolInstance()->getSocketFromPackageData($packageData, $connectionType); // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('SOCKET-DISCOVERY: socketInstance[]=%s', gettype($socketInstance))); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('PACKAGE-SOCKET-DISCOVERY: socketInstance[]=%s', gettype($socketInstance))); // Is it FALSE, the recipient isn't known to us and we have no connection to it if (!($socketInstance instanceof StorableSocket) || ($socketInstance->isValidSocket()) || ($socketInstance->getLastSocketErrorCode() > 0)) { // Try to create a new socket resource try { // Possibly noisy debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-DISCOVERY: Trying to establish a ' . strtoupper($listenerInstance->getProtocolName()) . ' connection to ' . $packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT] . ' ...'); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-SOCKET-DISCOVERY: Trying to establish a ' . strtoupper($listenerInstance->getProtocolName()) . ' connection to ' . $packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT] . ' ...'); // Get a socket resource from our factory (if succeeded) $socketInstance = SocketFactory::createSocketFromPackageData($packageData, $protocolInstance); } catch (SocketConnectionException $e) { // The connection fails of being established, so log it away - self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-DISCOVERY: Caught ' . $e->__toString() . ',message=' . $e->getMessage()); + self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-SOCKET-DISCOVERY: Caught ' . $e->__toString() . ',message=' . $e->getMessage()); } } // END - if @@ -218,20 +218,20 @@ class PackageSocketDiscovery extends BaseRecipientDiscovery implements Discovera $helperInstance = Registry::getRegistry()->getInstance('connection'); // Possibly noisy debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-DISCOVERY: Going to resolve socket from peer state and given package data ...'); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-SOCKET-DISCOVERY: Going to resolve socket from peer state and given package data ...'); // Resolve the peer's state (but ignore return value) PeerStateResolver::resolveStateByPackage($helperInstance, $packageData, $socketInstance); } catch (InvalidSocketException $e) { // This cannot be fixed, so log it away - self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-DISCOVERY: Cannot discover socket resource for recipient ' . $packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT] . ': ' . $e->getMessage()); + self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-SOCKET-DISCOVERY: Cannot discover socket resource for recipient ' . $packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT] . ': ' . $e->getMessage()); // Make any failed attempts to 'FALSE' $socketInstance = NULL; } // And return it - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-DISCOVERY: socketResource=' . $socketInstance->getSocketResource() . ',packageData=' . print_r($packageData, TRUE)); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-SOCKET-DISCOVERY: socketResource=' . $socketInstance->getSocketResource() . ',packageData=' . print_r($packageData, TRUE)); return $socketInstance; } diff --git a/application/hub/classes/factories/locator/class_UniversalNodeLocatorFactory.php b/application/hub/classes/factories/locator/class_UniversalNodeLocatorFactory.php index fd70f678d..e4fab052e 100644 --- a/application/hub/classes/factories/locator/class_UniversalNodeLocatorFactory.php +++ b/application/hub/classes/factories/locator/class_UniversalNodeLocatorFactory.php @@ -47,7 +47,7 @@ class UniversalNodeLocatorFactory extends ObjectFactory { */ public static final function createUnlInstanceFromString ($unl) { // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('UNL-FACTORY: unl=%s - CALLED!', $unl)); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('UNL-FACTORY: unl=%s - CALLED!', $unl)); // If there is no handler? if (Registry::getRegistry()->instanceExists('unl_' . $unl)) { diff --git a/application/hub/classes/factories/socket/class_SocketFactory.php b/application/hub/classes/factories/socket/class_SocketFactory.php index 1fcf974b7..c299bee96 100644 --- a/application/hub/classes/factories/socket/class_SocketFactory.php +++ b/application/hub/classes/factories/socket/class_SocketFactory.php @@ -69,7 +69,7 @@ class SocketFactory extends ObjectFactory { $registryKey = 'socket_' . $protocolInstance->getProtocolName() . '_' . $packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT]; // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-FACTORY: Trying to find a socket with registryKey=' . $registryKey); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-FACTORY: Trying to find a socket with registryKey=' . $registryKey); // Is the key there? if (Registry::getRegistry()->instanceExists($registryKey)) { @@ -77,13 +77,13 @@ class SocketFactory extends ObjectFactory { $socketInstance = Registry::getRegistry()->getInstance($registryKey); // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-FACTORY: Using socket ' . $socketInstance->getSocketResource() . '(' . gettype($socketInstance->getSocketResource()) . ') from registry.'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-FACTORY: Using socket ' . $socketInstance->getSocketResource() . '(' . gettype($socketInstance->getSocketResource()) . ') from registry.'); } else { // Construct configuration entry for object factory and get it $className = FrameworkConfiguration::getSelfInstance()->getConfigEntry($protocolInstance->getProtocolName() . '_connection_helper_class'); // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-FACTORY: Going to use class ' . $className . ' for creating a socket resource ...'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-FACTORY: Going to use class ' . $className . ' for creating a socket resource ...'); // And call the static method $socketInstance = call_user_func($className . '::createConnectionFromPackageData', $packageData); @@ -92,11 +92,11 @@ class SocketFactory extends ObjectFactory { Registry::getRegistry()->addInstance($registryKey, $socketInstance); // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-FACTORY: Socket is now registered in registry.'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-FACTORY: Socket is now registered in registry.'); } // Trace message - /* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('SOCKET-FACTORY: socketInstance=%s - EXIT!', $socketInstance->__toString())); + //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('SOCKET-FACTORY: socketInstance=%s - EXIT!', $socketInstance->__toString())); // Return the socket (container) instance return $socketInstance; @@ -132,7 +132,7 @@ class SocketFactory extends ObjectFactory { $socketInstance = self::createObjectByConfiguredName('socket_container_class', array($socketResource, StorableSocket::SOCKET_PROTOCOL_FILE, $packageData)); // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('SOCKET-FACTORY: socketInstance[]=%s', gettype($socketInstance))); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('SOCKET-FACTORY: socketInstance[]=%s', gettype($socketInstance))); // Is the socket resource valid? if (!$socketInstance->isValidSocket()) { @@ -182,7 +182,7 @@ class SocketFactory extends ObjectFactory { } // END - if // Trace message - /* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('SOCKET-FACTORY: socketInstance=%s - EXIT!', $socketInstance->__toString())); + //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('SOCKET-FACTORY: socketInstance=%s - EXIT!', $socketInstance->__toString())); // Return socket instance return $socketInstance; @@ -202,7 +202,7 @@ class SocketFactory extends ObjectFactory { $socketResource = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-FACTORY: Created socket[' . gettype($socketResource) . ']=' . $socketResource . '.'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-FACTORY: Created socket[' . gettype($socketResource) . ']=' . $socketResource . '.'); // Construct container class, this won't be reached if an exception is thrown $socketInstance = ObjectFactory::createObjectByConfiguredName('socket_container_class', array($socketResource, StorableSocket::SOCKET_PROTOCOL_TCP, $packageData)); @@ -242,7 +242,7 @@ class SocketFactory extends ObjectFactory { } // END - if // Trace message - /* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('SOCKET-FACTORY: socketInstance=%s - EXIT!', $socketInstance->__toString())); + //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('SOCKET-FACTORY: socketInstance=%s - EXIT!', $socketInstance->__toString())); // Return it return $socketInstance; @@ -257,7 +257,7 @@ class SocketFactory extends ObjectFactory { */ public static function createListenTcpSocket (Listenable $listenerInstance) { // Trace message - /* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('SOCKET-FACTORY: listenerInstance=%s - CALLED!', $listenerInstance->__toString())); + //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('SOCKET-FACTORY: listenerInstance=%s - CALLED!', $listenerInstance->__toString())); // Create a streaming socket, of type TCP/IP $socketResource = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); @@ -316,7 +316,7 @@ class SocketFactory extends ObjectFactory { } // END - if // Trace message - /* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('SOCKET-FACTORY: socketInstance=%s - EXIT!', $socketInstance->__toString())); + //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('SOCKET-FACTORY: socketInstance=%s - EXIT!', $socketInstance->__toString())); // Return prepepared socket return $socketInstance; @@ -331,7 +331,7 @@ class SocketFactory extends ObjectFactory { */ public static function createListenUdpSocket (Listenable $listenerInstance) { // Trace message - /* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('SOCKET-FACTORY: listenerInstance=%s - CALLED!', $listenerInstance->__toString())); + //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('SOCKET-FACTORY: listenerInstance=%s - CALLED!', $listenerInstance->__toString())); // Create a streaming socket, of type TCP/IP $socketResource = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP); @@ -383,7 +383,7 @@ class SocketFactory extends ObjectFactory { } // END - if // Trace message - /* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('SOCKET-FACTORY: socketInstance=%s - EXIT!', $socketInstance->__toString())); + //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('SOCKET-FACTORY: socketInstance=%s - EXIT!', $socketInstance->__toString())); // Return prepepared socket return $socketInstance; @@ -401,7 +401,7 @@ class SocketFactory extends ObjectFactory { */ public static final function createNextAcceptedSocketFromPool (Poolable $poolInstance, StorableSocket $socketInstance) { // Trace message - /* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('SOCKET-FACTORY: poolInstance=%s,socketInstance.socketResource=%s - CALLED!', $poolInstance->__toString(), $socketInstance->getSocketResource())); + //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('SOCKET-FACTORY: poolInstance=%s,socketInstance.socketResource=%s - CALLED!', $poolInstance->__toString(), $socketInstance->getSocketResource())); // Get socket protocol $socketProtocol = $socketInstance->getSocketProtocol(); @@ -446,7 +446,7 @@ class SocketFactory extends ObjectFactory { $acceptedSocketInstance = $current[Poolable::SOCKET_ARRAY_INSTANCE]->acceptNewIncomingSocket(); // Trace message - /* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('SOCKET-FACTORY: acceptedSocketInstance[]=%s - EXIT!', gettype($acceptedSocketInstance))); + //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('SOCKET-FACTORY: acceptedSocketInstance[]=%s - EXIT!', gettype($acceptedSocketInstance))); // Return found socket instance return $acceptedSocketInstance; @@ -478,19 +478,19 @@ class SocketFactory extends ObjectFactory { // Try to identify socket peer if (!$socketInstance->identifySocketPeer()) { // Handle this socket error with a faked recipientData array - $socketInstance->handleSocketEror(__METHOD__, __LINE__, array('0.0.0.0', '0')); + $socketInstance->handleSocketError(__METHOD__, __LINE__, array('0.0.0.0', '0')); } // END - if // Set timeout to configured seconds if (!$socketInstance->setSocketTimeoutOptions()) { // Handle this socket error with a faked recipientData array - $socketInstance->handleSocketEror(__METHOD__, __LINE__, array('0.0.0.0', '0')); + $socketInstance->handleSocketError(__METHOD__, __LINE__, array('0.0.0.0', '0')); } // END - if // Enable SO_OOBINLINE if (!$socketInstance->enableSocketOutOfBandData()) { // Handle this socket error with a faked recipientData array - $socketInstance->handleSocketEror(__METHOD__, __LINE__, array('0.0.0.0', '0')); + $socketInstance->handleSocketError(__METHOD__, __LINE__, array('0.0.0.0', '0')); } // END - if // Set non-blocking @@ -500,7 +500,7 @@ class SocketFactory extends ObjectFactory { } // END - if // Trace message - /* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('SOCKET-FACTORY: socketInstance=%s - EXIT!', $socketInstance->__toString())); + //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('SOCKET-FACTORY: socketInstance=%s - EXIT!', $socketInstance->__toString())); // Return found socket instance return $socketInstance; diff --git a/application/hub/classes/factories/states/communicator/class_CommunicatorStateFactory.php b/application/hub/classes/factories/states/communicator/class_CommunicatorStateFactory.php index 763e0bdc2..aaa81d48d 100644 --- a/application/hub/classes/factories/states/communicator/class_CommunicatorStateFactory.php +++ b/application/hub/classes/factories/states/communicator/class_CommunicatorStateFactory.php @@ -65,7 +65,5 @@ class CommunicatorStateFactory extends ObjectFactory { // For any purposes, return the state instance return $stateInstance; } -} -// [EOF] -?> +} diff --git a/application/hub/classes/factories/states/crawler/class_CrawlerStateFactory.php b/application/hub/classes/factories/states/crawler/class_CrawlerStateFactory.php index e5e285dc7..4050977ff 100644 --- a/application/hub/classes/factories/states/crawler/class_CrawlerStateFactory.php +++ b/application/hub/classes/factories/states/crawler/class_CrawlerStateFactory.php @@ -68,7 +68,5 @@ class CrawlerStateFactory extends ObjectFactory { // For any purposes, return the state instance return $stateInstance; } -} -// [EOF] -?> +} diff --git a/application/hub/classes/factories/states/cruncher/class_CruncherStateFactory.php b/application/hub/classes/factories/states/cruncher/class_CruncherStateFactory.php index d5c3dd458..fb2d06d3c 100644 --- a/application/hub/classes/factories/states/cruncher/class_CruncherStateFactory.php +++ b/application/hub/classes/factories/states/cruncher/class_CruncherStateFactory.php @@ -66,7 +66,5 @@ class CruncherStateFactory extends ObjectFactory { // For any purposes, return the state instance return $stateInstance; } -} -// [EOF] -?> +} diff --git a/application/hub/classes/factories/states/miner/class_MinerStateFactory.php b/application/hub/classes/factories/states/miner/class_MinerStateFactory.php index add7355f5..f38cc3249 100644 --- a/application/hub/classes/factories/states/miner/class_MinerStateFactory.php +++ b/application/hub/classes/factories/states/miner/class_MinerStateFactory.php @@ -65,7 +65,5 @@ class MinerStateFactory extends ObjectFactory { // For any purposes, return the state instance return $stateInstance; } -} -// [EOF] -?> +} diff --git a/application/hub/classes/factories/states/node/class_NodeStateFactory.php b/application/hub/classes/factories/states/node/class_NodeStateFactory.php index eacbc0dc6..f2343a9bd 100644 --- a/application/hub/classes/factories/states/node/class_NodeStateFactory.php +++ b/application/hub/classes/factories/states/node/class_NodeStateFactory.php @@ -75,7 +75,5 @@ class NodeStateFactory extends ObjectFactory { // For any purposes, return the state instance return $stateInstance; } -} -// [EOF] -?> +} diff --git a/application/hub/classes/factories/states/peer/class_PeerStateFactory.php b/application/hub/classes/factories/states/peer/class_PeerStateFactory.php index ae82acdf5..423d4e5a5 100644 --- a/application/hub/classes/factories/states/peer/class_PeerStateFactory.php +++ b/application/hub/classes/factories/states/peer/class_PeerStateFactory.php @@ -92,13 +92,13 @@ class PeerStateFactory extends ObjectFactory { $tableInstance->purgeOldEntriesBySocketInstance($socketInstance); } catch (InvalidSocketException $e) { // Just log all errors - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PEER-STATE-FACTORY[' . __LINE__ . ':] Purging of old entries failed. Message from exception: ' . $e->getMessage()); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PEER-STATE-FACTORY: Purging of old entries failed. Message from exception: ' . $e->getMessage()); } // Do we have an entry? if ($tableInstance->isSenderNewPeer($packageData)) { // Debug output - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PEER-STATE-FACTORY[' . __LINE__ . ':] errorCode=' . $errorCode); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PEER-STATE-FACTORY: errorCode=' . $errorCode); // Register the new peer with its session id $tableInstance->registerPeerByPackageData($packageData, $socketInstance); @@ -113,7 +113,7 @@ class PeerStateFactory extends ObjectFactory { $tableInstance->registerPeerState($stateInstance, $packageData); } elseif ($tableInstance->isSamePeerState($helperInstance, $packageData)) { // Debug output - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PEER-STATE-FACTORY[' . __LINE__ . ':] Peer state unchanged, re-generating old state ...'); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PEER-STATE-FACTORY: Peer state unchanged, re-generating old state ...'); /* * The peer's state has noot changed, still we have to return a @@ -122,7 +122,7 @@ class PeerStateFactory extends ObjectFactory { $stateInstance = self::createPeerStateInstanceByName($helperInstance->getPrintableState(), $helperInstance); } else { // Debug output - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PEER-STATE-FACTORY[' . __LINE__ . ':] Updating peer state ...'); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PEER-STATE-FACTORY: Updating peer state ...'); /* * It is an already known peer but with a changed state. So first @@ -135,7 +135,7 @@ class PeerStateFactory extends ObjectFactory { } // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PEER-STATE-FACTORY[' . __LINE__ . ':] Peer state has changed from ' . $helperInstance->getPrintableState() . ' to ' . $stateInstance->getStateName() . ' (' . $stateInstance->__toString() . ').'); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PEER-STATE-FACTORY: Peer state has changed from ' . $helperInstance->getPrintableState() . ' to ' . $stateInstance->getStateName() . ' (' . $stateInstance->__toString() . ').'); // Set the state in the helper $helperInstance->setStateInstance($stateInstance); @@ -157,7 +157,7 @@ class PeerStateFactory extends ObjectFactory { $stateInstance = self::createObjectByConfiguredName('peer_' . $stateName . '_state_class', array($helperInstance)); // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PEER-STATE-FACTORY[' . __LINE__ . ':] Peer state has changed from ' . $helperInstance->getPrintableState() . ' to ' . $stateInstance->getStateName() . ' (' . $stateInstance->__toString() . ').'); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PEER-STATE-FACTORY: Peer state has changed from ' . $helperInstance->getPrintableState() . ' to ' . $stateInstance->getStateName() . ' (' . $stateInstance->__toString() . ').'); // Once we have that state, set it in the peer instance $helperInstance->setStateInstance($stateInstance); diff --git a/application/hub/classes/handler/chunks/class_ChunkHandler.php b/application/hub/classes/handler/chunks/class_ChunkHandler.php index b2dbace00..7932d6f57 100644 --- a/application/hub/classes/handler/chunks/class_ChunkHandler.php +++ b/application/hub/classes/handler/chunks/class_ChunkHandler.php @@ -143,7 +143,7 @@ class ChunkHandler extends BaseHubHandler implements HandleableChunks, Registera */ private function initHandler () { // Noisy debug line: - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CHUNK-HANDLER: Initializing handler ...'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CHUNK-HANDLER: Initializing handler ...'); // Init finalPackageChunks $this->finalPackageChunks = array( @@ -175,7 +175,7 @@ class ChunkHandler extends BaseHubHandler implements HandleableChunks, Registera */ private function isChunkHashValid (array $chunkSplits) { // Noisy debug line: - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CHUNK-HANDLER: chunkSplits=' . print_r($chunkSplits, TRUE)); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CHUNK-HANDLER: chunkSplits=' . print_r($chunkSplits, TRUE)); // Assert on some elements assert(isset($chunkSplits[self::CHUNK_SPLITS_INDEX_RAW_DATA])); @@ -188,7 +188,7 @@ class ChunkHandler extends BaseHubHandler implements HandleableChunks, Registera $isValid = ($chunkSplits[self::CHUNK_SPLITS_INDEX_HASH] === $chunkHash); // Debug output - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CHUNK-HANDLER: chunkHash=' . $chunkHash . ',isValid=' . intval($isValid)); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CHUNK-HANDLER: chunkHash=' . $chunkHash . ',isValid=' . intval($isValid)); // ... and return it return $isValid; @@ -227,7 +227,7 @@ class ChunkHandler extends BaseHubHandler implements HandleableChunks, Registera } // END - if // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CHUNK-HANDLER: serialNumber=' . $chunkSplits[self::CHUNK_SPLITS_INDEX_SERIAL] . ',hash=' . $chunkSplits[self::CHUNK_SPLITS_INDEX_HASH]); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CHUNK-HANDLER: serialNumber=' . $chunkSplits[self::CHUNK_SPLITS_INDEX_SERIAL] . ',hash=' . $chunkSplits[self::CHUNK_SPLITS_INDEX_HASH]); // Add the chunk data (index 2) to the final array and use the serial number as index $this->finalPackageChunks['content'][$chunkSplits[self::CHUNK_SPLITS_INDEX_SERIAL]] = $chunkSplits[self::CHUNK_SPLITS_INDEX_RAW_DATA]; @@ -306,7 +306,7 @@ class ChunkHandler extends BaseHubHandler implements HandleableChunks, Registera */ private function verifyChunkSerialNumbers () { // Debug message - /* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CHUNK-HANDLER: finalPackageChunks=' . print_r($this->finalPackageChunks, TRUE)); + //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CHUNK-HANDLER: finalPackageChunks=' . print_r($this->finalPackageChunks, TRUE)); // Get final hash $finalHash = $this->generateFinalHash(implode('', $this->finalPackageChunks['content'])); @@ -320,7 +320,7 @@ class ChunkHandler extends BaseHubHandler implements HandleableChunks, Registera $nextSerial = $this->fragmenterInstance->getNextHexSerialNumber($finalHash); // Debug output - /* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CHUNK-HANDLER: serialNumber=' . $serialNumber . ',nextSerial=' . $nextSerial); + //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CHUNK-HANDLER: serialNumber=' . $serialNumber . ',nextSerial=' . $nextSerial); // Is it not the same? Then re-request it if ($serialNumber != $nextSerial) { @@ -349,14 +349,14 @@ class ChunkHandler extends BaseHubHandler implements HandleableChunks, Registera $this->rawPackageData = ''; // That went well, so start assembling all chunks - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CHUNK-HANDLER: Handling ' . count($this->finalPackageChunks['content']) . ' entries ...'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CHUNK-HANDLER: Handling ' . count($this->finalPackageChunks['content']) . ' entries ...'); foreach ($this->finalPackageChunks['content'] as $serialNumber => $content) { // Assert on 'hash' entry (must always be set) assert(isset($this->finalPackageChunks['hashes'][$serialNumber])); // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CHUNK-HANDLER: serialNumber=' . $serialNumber . ',hashes=' . $this->finalPackageChunks['hashes'][$serialNumber] . ' - validating ...'); - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('finalPackageChunks=' . print_r($this->finalPackageChunks, TRUE) . 'chunkHashes=' . print_r($this->chunkHashes, TRUE)); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CHUNK-HANDLER: serialNumber=' . $serialNumber . ',hashes=' . $this->finalPackageChunks['hashes'][$serialNumber] . ' - validating ...'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('finalPackageChunks=' . print_r($this->finalPackageChunks, TRUE) . 'chunkHashes=' . print_r($this->chunkHashes, TRUE)); // Is this chunk valid? This should be the case assert($this->isChunkHashValid(array( @@ -368,12 +368,12 @@ class ChunkHandler extends BaseHubHandler implements HandleableChunks, Registera assert(in_array($this->finalPackageChunks['hashes'][$serialNumber], $this->chunkHashes)); // Verification okay, add it to the raw data - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CHUNK-HANDLER: Adding ' . strlen($content) . ' bytes as raw package data ...'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CHUNK-HANDLER: Adding ' . strlen($content) . ' bytes as raw package data ...'); $this->rawPackageData .= $content; } // END - foreach // Debug output - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CHUNK-HANDLER: eopChunk[1]=' . $this->eopChunk[1] . ',index=' . (count($this->chunkHashes) - 2) . ',chunkHashes='.print_r($this->chunkHashes, TRUE)); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CHUNK-HANDLER: eopChunk[1]=' . $this->eopChunk[1] . ',index=' . (count($this->chunkHashes) - 2) . ',chunkHashes='.print_r($this->chunkHashes, TRUE)); // The last chunk hash must match with the one from eopChunk[1] assert($this->eopChunk[1] == $this->chunkHashes[count($this->chunkHashes) - 2]); @@ -411,7 +411,7 @@ class ChunkHandler extends BaseHubHandler implements HandleableChunks, Registera $finalHash = $this->generateFinalHash($this->rawPackageData); // Is it the same? - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CHUNK-HANDLER: eopChunk[1]=' . $this->eopChunk[1] . ',finalHash=' . $finalHash); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CHUNK-HANDLER: eopChunk[1]=' . $this->eopChunk[1] . ',finalHash=' . $finalHash); assert($finalHash == $this->eopChunk[0]); } @@ -429,7 +429,7 @@ class ChunkHandler extends BaseHubHandler implements HandleableChunks, Registera $chunkSplits = explode(PackageFragmenter::CHUNK_DATA_HASH_SEPARATOR, $chunks[count($chunks) - 1]); // Make sure chunks with only 3 elements are parsed (for details see ChunkHandler) - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('eopChunk=' . $chunks[count($chunks) - 1] . ',chunkSplits=' . print_r($chunkSplits, TRUE)); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('eopChunk=' . $chunks[count($chunks) - 1] . ',chunkSplits=' . print_r($chunkSplits, TRUE)); assert(count($chunkSplits) == 3); // Validate final chunk @@ -640,11 +640,11 @@ class ChunkHandler extends BaseHubHandler implements HandleableChunks, Registera */ public function ifRawPackageDataIsAvailable () { // Check it - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CHUNK-HANDLER: this->rawPackageData()=' . strlen($this->rawPackageData) . ',ifUnassembledChunksAvailable()=' . intval($this->ifUnassembledChunksAvailable())); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CHUNK-HANDLER: this->rawPackageData()=' . strlen($this->rawPackageData) . ',ifUnassembledChunksAvailable()=' . intval($this->ifUnassembledChunksAvailable())); $isRawPackageDataAvailable = ((!empty($this->rawPackageData)) && (!$this->ifUnassembledChunksAvailable())); // Return it - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CHUNK-HANDLER: isRawPackageDataAvailable=' . intval($isRawPackageDataAvailable)); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CHUNK-HANDLER: isRawPackageDataAvailable=' . intval($isRawPackageDataAvailable)); return $isRawPackageDataAvailable; } @@ -659,13 +659,11 @@ class ChunkHandler extends BaseHubHandler implements HandleableChunks, Registera assert($this->ifRawPackageDataIsAvailable()); // Then feed it into the next stacker - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CHUNK-HANDLER: Pushing ' . strlen($this->rawPackageData) . ' bytes to stack ' . self::STACKER_NAME_ASSEMBLED_RAW_DATA . ' ...'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CHUNK-HANDLER: Pushing ' . strlen($this->rawPackageData) . ' bytes to stack ' . self::STACKER_NAME_ASSEMBLED_RAW_DATA . ' ...'); $this->getStackInstance()->pushNamed(self::STACKER_NAME_ASSEMBLED_RAW_DATA, $this->rawPackageData); // ... and reset it $this->rawPackageData = ''; } -} -// [EOF] -?> +} diff --git a/application/hub/classes/handler/data/class_BaseDataHandler.php b/application/hub/classes/handler/data/class_BaseDataHandler.php index 744a14c9c..e5e2bfb9f 100644 --- a/application/hub/classes/handler/data/class_BaseDataHandler.php +++ b/application/hub/classes/handler/data/class_BaseDataHandler.php @@ -109,7 +109,7 @@ abstract class BaseDataHandler extends BaseHubHandler implements HubInterface { */ protected function prepareAnswerMessage (array $messageData, Deliverable $packageInstance) { // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('MESSAGE-HANDLER: Going to send an answer message for ' . $this->getHandlerName() . ' ...'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DATA-HANDLER:Going to send an answer message for ' . $this->getHandlerName() . ' ...'); // Get a helper instance based on this handler's name $helperInstance = ObjectFactory::createObjectByConfiguredName('node_answer_' . $this->getHandlerName() . '_helper_class', array($messageData)); @@ -138,7 +138,7 @@ abstract class BaseDataHandler extends BaseHubHandler implements HubInterface { $this->removeMessageConfigurationData($messageData); // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('MESSAGE-HANDLER: Answer message has been prepared.'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DATA-HANDLER:Answer message has been prepared.'); } /** @@ -150,7 +150,7 @@ abstract class BaseDataHandler extends BaseHubHandler implements HubInterface { */ protected function prepareNextMessage (array $messageData, Deliverable $packageInstance) { // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('MESSAGE-HANDLER: Going to send next message ...'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DATA-HANDLER:Going to send next message ...'); // Get a helper instance based on this handler's name $helperInstance = ObjectFactory::createObjectByConfiguredName('node_next_' . $this->getHandlerName() . '_helper_class', array($messageData)); @@ -179,7 +179,7 @@ abstract class BaseDataHandler extends BaseHubHandler implements HubInterface { $this->removeMessageConfigurationData($messageData); // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('MESSAGE-HANDLER: Next message has been prepared.'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DATA-HANDLER:Next message has been prepared.'); } /** diff --git a/application/hub/classes/handler/protocol/class_BaseProtocolHandler.php b/application/hub/classes/handler/protocol/class_BaseProtocolHandler.php index 88a7052a2..c1fef8007 100644 --- a/application/hub/classes/handler/protocol/class_BaseProtocolHandler.php +++ b/application/hub/classes/handler/protocol/class_BaseProtocolHandler.php @@ -56,13 +56,13 @@ abstract class BaseProtocolHandler extends BaseHubHandler implements HandleableP */ protected final function isValidUniversalNodeLocator ($unl) { // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PROTOCOL-HANDLER: unl=' . $unl . ' - CALLED!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PROTOCOL-HANDLER: unl=' . $unl . ' - CALLED!'); // Very basic regex check $isValid = (preg_match($this->getRegularExpression(), $unl) === 1); // Return result - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PROTOCOL-HANDLER: isValid=' . intval($isValid) . ' - EXIT!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PROTOCOL-HANDLER: isValid=' . intval($isValid) . ' - EXIT!'); return $isValid; } @@ -111,14 +111,14 @@ abstract class BaseProtocolHandler extends BaseHubHandler implements HandleableP $internalUnl = HubTools::determineOwnInternalAddress(); // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PROTOCOL-HANDLER: unl=' . $unl . ',externalUnl=' . $externalUnl . ',internalUnl=' . $internalUnl); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PROTOCOL-HANDLER: unl=' . $unl . ',externalUnl=' . $externalUnl . ',internalUnl=' . $internalUnl); //* DIE-DEBUG: */ die(__METHOD__.':unl=' . $unl . ',this='.print_r($this, TRUE)); // Is it the same? $ifMatches = (($unl === $externalUnl) || ($unl === $internalUnl)); // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PROTOCOL-HANDLER: ifMatches=' . intval($ifMatches)); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PROTOCOL-HANDLER: ifMatches=' . intval($ifMatches)); // Return result return $ifMatches; diff --git a/application/hub/classes/handler/protocol/ipv4/class_BaseIpV4ProtocolHandler.php b/application/hub/classes/handler/protocol/ipv4/class_BaseIpV4ProtocolHandler.php index be158038b..c76921f97 100644 --- a/application/hub/classes/handler/protocol/ipv4/class_BaseIpV4ProtocolHandler.php +++ b/application/hub/classes/handler/protocol/ipv4/class_BaseIpV4ProtocolHandler.php @@ -80,7 +80,7 @@ abstract class BaseIpV4ProtocolHandler extends BaseProtocolHandler { */ public function isValidUniversalNodeLocatorByPackageData (array $packageData) { // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('IPV4-PROTOCOL-HANDLER: CALLED!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('IPV4-PROTOCOL-HANDLER: CALLED!'); // Is 'recipient' there? assert(isset($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT])); @@ -92,7 +92,7 @@ abstract class BaseIpV4ProtocolHandler extends BaseProtocolHandler { $isValid = $this->isValidUniversalNodeLocator($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT]); // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('IPV4-PROTOCOL-HANDLER: PACKAGE_DATA_RECIPIENT=' . $packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT] . ',isValid[' . gettype($isValid) . ']=' . intval($isValid)); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('IPV4-PROTOCOL-HANDLER: PACKAGE_DATA_RECIPIENT=' . $packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT] . ',isValid[' . gettype($isValid) . ']=' . intval($isValid)); // If this doesn't fail, continue validating the IP:port combination if ($isValid === TRUE) { @@ -108,7 +108,7 @@ abstract class BaseIpV4ProtocolHandler extends BaseProtocolHandler { } // END - if // Return result - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('IPV4-PROTOCOL-HANDLER: isValid=' . intval($isValid) . ' - EXIT!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('IPV4-PROTOCOL-HANDLER: isValid=' . intval($isValid) . ' - EXIT!'); return $isValid; } diff --git a/application/hub/classes/handler/raw_data/class_BaseRawDataHandler.php b/application/hub/classes/handler/raw_data/class_BaseRawDataHandler.php index f58638c2f..4e38ff9c1 100644 --- a/application/hub/classes/handler/raw_data/class_BaseRawDataHandler.php +++ b/application/hub/classes/handler/raw_data/class_BaseRawDataHandler.php @@ -91,13 +91,13 @@ class BaseRawDataHandler extends BaseHubHandler implements HubInterface { */ protected function initStack () { // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('RAW-DATA-HANDLER: CALLED!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('RAW-DATA-HANDLER: CALLED!'); // Init stack(s) $this->getStackInstance()->initStack(self::STACKER_NAME_RAW_DATA); // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('RAW-DATA-HANDLER: EXIT!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('RAW-DATA-HANDLER: EXIT!'); } /** @@ -108,7 +108,7 @@ class BaseRawDataHandler extends BaseHubHandler implements HubInterface { */ protected function addRawDataToStacker ($rawData) { // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('RAW-DATA-HANDLER: rawData()=%d - CALLED!', strlen($rawData))); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('RAW-DATA-HANDLER: rawData()=%d - CALLED!', strlen($rawData))); /* * Add the deocoded data and error code to the stacker so other classes @@ -120,7 +120,7 @@ class BaseRawDataHandler extends BaseHubHandler implements HubInterface { )); // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('RAW-DATA-HANDLER: EXIT!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('RAW-DATA-HANDLER: EXIT!'); } /** @@ -130,13 +130,13 @@ class BaseRawDataHandler extends BaseHubHandler implements HubInterface { */ public function isRawDataPending () { // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('RAW-DATA-HANDLER: CALLED!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('RAW-DATA-HANDLER: CALLED!'); // Does the stacker have some entries (not empty)? $isPending = (!$this->getStackInstance()->isStackEmpty(self::STACKER_NAME_RAW_DATA)); // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('RAW-DATA-HANDLER: isPending=%d - EXIT!', intval($isPending))); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('RAW-DATA-HANDLER: isPending=%d - EXIT!', intval($isPending))); // Return it return $isPending; @@ -165,7 +165,7 @@ class BaseRawDataHandler extends BaseHubHandler implements HubInterface { */ protected function ifRecipientMatchesOwnUniversalNodeLocator (array $packageData) { // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('RAW-DATA-HANDLER: packageData()=%d - CALLED!', strlen($packageData))); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('RAW-DATA-HANDLER: packageData()=%d - CALLED!', strlen($packageData))); // Construct own address first $ownAddress = NodeObjectFactory::createNodeInstance()->determineUniversalNodeLocator(); @@ -174,7 +174,7 @@ class BaseRawDataHandler extends BaseHubHandler implements HubInterface { $matches = ($ownAddress === $packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT]); // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('RAW-DATA-HANDLER: matches=%d - EXIT!', intval($matches))); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('RAW-DATA-HANDLER: matches=%d - EXIT!', intval($matches))); // Return result return $matches; diff --git a/application/hub/classes/helper/connection/class_BaseConnectionHelper.php b/application/hub/classes/helper/connection/class_BaseConnectionHelper.php index 9cc478d70..7d83fec76 100644 --- a/application/hub/classes/helper/connection/class_BaseConnectionHelper.php +++ b/application/hub/classes/helper/connection/class_BaseConnectionHelper.php @@ -180,7 +180,7 @@ class BaseConnectionHelper extends BaseHubSystemHelper implements Visitable, Reg */ private function getRawDataFromPackageArray (array $packageData) { // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CONNECTION-HELPER: currentFinalHash=' . $this->currentFinalHash); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CONNECTION-HELPER: currentFinalHash=' . $this->currentFinalHash); // Make sure the final hash is set assert((is_string($this->currentFinalHash)) && (!empty($this->currentFinalHash))); @@ -189,25 +189,25 @@ class BaseConnectionHelper extends BaseHubSystemHelper implements Visitable, Reg $rawDataChunk = $this->getFragmenterInstance()->getNextRawDataChunk($this->currentFinalHash); // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CONNECTION-HELPER: rawDataChunk=' . print_r($rawDataChunk, TRUE)); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CONNECTION-HELPER: rawDataChunk=' . print_r($rawDataChunk, TRUE)); // Get chunk hashes and chunk data $chunkHashes = array_keys($rawDataChunk); $chunkData = array_values($rawDataChunk); // Is the required data there? - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CONNECTION-HELPER: chunkHashes[]=' . count($chunkHashes) . ',chunkData[]=' . count($chunkData)); - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('chunkData='.print_r($chunkData, TRUE)); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CONNECTION-HELPER: chunkHashes[]=' . count($chunkHashes) . ',chunkData[]=' . count($chunkData)); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('chunkData='.print_r($chunkData, TRUE)); if ((isset($chunkHashes[0])) && (isset($chunkData[0]))) { // Remember this chunk as queued $this->queuedChunks[$chunkHashes[0]] = $chunkData[0]; // Return the raw data - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CONNECTION-HELPER: Returning ' . strlen($chunkData[0]) . ' bytes from ' . __METHOD__ . ' ...'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CONNECTION-HELPER: Returning ' . strlen($chunkData[0]) . ' bytes from ' . __METHOD__ . ' ...'); return $chunkData[0]; } else { // Return zero string - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CONNECTION-HELPER: Returning zero bytes from ' . __METHOD__ . '!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CONNECTION-HELPER: Returning zero bytes from ' . __METHOD__ . '!'); return ''; } } @@ -220,13 +220,13 @@ class BaseConnectionHelper extends BaseHubSystemHelper implements Visitable, Reg */ public function accept (Visitor $visitorInstance) { // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('CONNECTION-HELPER: visitorInstance=%s - CALLED!', $visitorInstance->__toString())); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('CONNECTION-HELPER: visitorInstance=%s - CALLED!', $visitorInstance->__toString())); // Just call the visitor $visitorInstance->visitConnectionHelper($this); // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CONNECTION-HELPER: EXIT!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CONNECTION-HELPER: EXIT!'); } /** @@ -237,7 +237,7 @@ class BaseConnectionHelper extends BaseHubSystemHelper implements Visitable, Reg */ public function sendRawPackageData (array $packageData) { // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('CONNECTION-HELPER: packageData()=%d - CALLED!', count($packageData))); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('CONNECTION-HELPER: packageData()=%d - CALLED!', count($packageData))); // The helper's state must be 'connected' $this->getStateInstance()->validatePeerStateConnected(); @@ -246,12 +246,12 @@ class BaseConnectionHelper extends BaseHubSystemHelper implements Visitable, Reg $finalHash = $this->getFragmenterInstance()->fragmentPackageArray($packageData, $this); // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('CONNECTION-HELPER: finalHash[%s]=%s', gettype($finalHash), $finalHash)); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('CONNECTION-HELPER: finalHash[%s]=%s', gettype($finalHash), $finalHash)); // Is the final hash set? if ($finalHash !== TRUE) { // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CONNECTION-HELPER: Setting finalHash=' . $finalHash . ',currentFinalHash[' . gettype($this->currentFinalHash) . ']=' . $this->currentFinalHash); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CONNECTION-HELPER: Setting finalHash=' . $finalHash . ',currentFinalHash[' . gettype($this->currentFinalHash) . ']=' . $this->currentFinalHash); // Set final hash $this->currentFinalHash = $finalHash; @@ -267,7 +267,7 @@ class BaseConnectionHelper extends BaseHubSystemHelper implements Visitable, Reg // Fill sending buffer with data while (TRUE) { // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('CONNECTION-HELPER: dataStream()=%d', strlen($dataStream))); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('CONNECTION-HELPER: dataStream()=%d', strlen($dataStream))); // Convert the package data array to a raw data stream $dataStream = $this->getRawDataFromPackageArray($packageData); @@ -279,14 +279,14 @@ class BaseConnectionHelper extends BaseHubSystemHelper implements Visitable, Reg } // END - if // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CONNECTION-HELPER: Adding ' . strlen($dataStream) . ' bytes to the sending buffer ...'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CONNECTION-HELPER: Adding ' . strlen($dataStream) . ' bytes to the sending buffer ...'); // Add raw data $rawData .= $dataStream; } // END - while // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('CONNECTION-HELPER: rawData()=%d', strlen($rawData))); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('CONNECTION-HELPER: rawData()=%d', strlen($rawData))); // Nothing to sent is bad news, so assert on it assert(strlen($rawData) > 0); @@ -295,13 +295,13 @@ class BaseConnectionHelper extends BaseHubSystemHelper implements Visitable, Reg $bufferSize = $this->getConfigInstance()->getConfigEntry($this->getProtocolName() . '_buffer_length'); // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('CONNECTION-HELPER: bufferSize=%d', $bufferSize)); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('CONNECTION-HELPER: bufferSize=%d', $bufferSize)); // Encode the raw data with our output-stream $encodedData = $this->getOutputStreamInstance()->streamData($rawData); // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CONNECTION-HELPER: socketResource[]=' . gettype($this->getSocketInstance()->getSocketResource())); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CONNECTION-HELPER: socketResource[]=' . gettype($this->getSocketInstance()->getSocketResource())); // Init array $encodedDataArray = array( @@ -317,13 +317,13 @@ class BaseConnectionHelper extends BaseHubSystemHelper implements Visitable, Reg $diff = $encodedDataArray[NetworkPackage::RAW_INDEX_BUFFER_SIZE] - strlen($encodedDataArray[NetworkPackage::RAW_INDEX_ENCODED_DATA]); // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CONNECTION-HELPER: diff=' . $diff); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CONNECTION-HELPER: diff=' . $diff); // Push raw data to the package's outgoing stack $this->getPackageInstance()->getStackInstance()->pushNamed(NetworkPackage::STACKER_NAME_OUTGOING_STREAM, $encodedDataArray); // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CONNECTION-HELPER: EXIT!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CONNECTION-HELPER: EXIT!'); } /** @@ -332,7 +332,7 @@ class BaseConnectionHelper extends BaseHubSystemHelper implements Visitable, Reg * @return $shuttedDown Whether this connection is shutted down */ public final function isShuttedDown () { - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CONNECTION-HELPER: ' . $this->__toString() . ',shuttedDown=' . intval($this->shuttedDown)); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CONNECTION-HELPER: ' . $this->__toString() . ',shuttedDown=' . intval($this->shuttedDown)); return $this->shuttedDown; } diff --git a/application/hub/classes/helper/dht/class_DhtBootstrapHelper.php b/application/hub/classes/helper/dht/class_DhtBootstrapHelper.php index 6df429e11..436b1add0 100644 --- a/application/hub/classes/helper/dht/class_DhtBootstrapHelper.php +++ b/application/hub/classes/helper/dht/class_DhtBootstrapHelper.php @@ -74,7 +74,7 @@ class DhtBootstrapHelper extends BaseHubSystemHelper implements HelpableDht { */ public function loadDescriptorXml (Distributable $dhtInstance) { // Debug message - self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('HELPER: Starting with DHT boostrap ...'); + self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-BOOTSTRAP-HELPER: Starting with DHT boostrap ...'); // Get a XML template instance $templateInstance = XmlTemplateEngineFactory::createXmlTemplateEngineInstance('dht_bootstrap_template_class'); @@ -97,7 +97,7 @@ class DhtBootstrapHelper extends BaseHubSystemHelper implements HelpableDht { */ public function sendPackage (Distributable $dhtInstance) { // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('HELPER: CALLED!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-BOOTSTRAP-HELPER: CALLED!'); /* * Sanity check: Is the DHT in the approx. state? 'init' for bootstrap @@ -116,7 +116,7 @@ class DhtBootstrapHelper extends BaseHubSystemHelper implements HelpableDht { $packageInstance->enqueueRawDataFromTemplate($this); // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('HELPER: EXIT!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DHT-BOOTSTRAP-HELPER: EXIT!'); } } diff --git a/application/hub/classes/info/connection/class_ConnectionInfo.php b/application/hub/classes/info/connection/class_ConnectionInfo.php index 13510d06e..990f52b12 100644 --- a/application/hub/classes/info/connection/class_ConnectionInfo.php +++ b/application/hub/classes/info/connection/class_ConnectionInfo.php @@ -3,6 +3,7 @@ namespace Hub\Information\Connection; // Import application-specific stuff +use Hub\Container\Socket\StorableSocket; use Hub\Helper\Connection\ConnectionHelper; use Hub\Information\BaseInfo; use Hub\Information\ShareableInfo; @@ -11,6 +12,7 @@ use Hub\Locator\Node\LocateableNode; // Import framework stuff use CoreFramework\Registry\Registerable; +use CoreFramework\Socket\InvalidSocketException; /** * A Connection information class @@ -66,7 +68,7 @@ class ConnectionInfo extends BaseInfo implements ShareableInfo, Registerable { */ public function fillWithListenerInformation (Listenable $listenerInstance) { // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CONNECTION-INFO: protocolName=' . $listenerInstance->getProtocolName() . ',listenerInstance=' . $listenerInstance->__toString() . ' - CALLED!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CONNECTION-INFO: protocolName=' . $listenerInstance->getProtocolName() . ',listenerInstance=' . $listenerInstance->__toString() . ' - CALLED!'); // Fill the generic array with several data from the listener: $this->setProtocolName($listenerInstance->getProtocolName()); @@ -77,7 +79,7 @@ class ConnectionInfo extends BaseInfo implements ShareableInfo, Registerable { $this->setListenerInstance($listenerInstance); // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CONNECTION-INFO: EXIT!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CONNECTION-INFO: EXIT!'); } /** @@ -87,8 +89,8 @@ class ConnectionInfo extends BaseInfo implements ShareableInfo, Registerable { * @return void */ public function fillWithConnectionHelperInformation (ConnectionHelper $helperInstance) { - // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CONNECTION-INFO: protocolName=' . $helperInstance->getProtocolName() . ',helperInstance=' . $helperInstance->__toString() . ',socketResource=' . $helperInstance->getSocketResource() . ' - CALLED!'); + // Trace message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CONNECTION-INFO: protocolName=' . $helperInstance->getProtocolName() . ',helperInstance=' . $helperInstance->__toString() . ',socketResource=' . $helperInstance->getSocketResource() . ' - CALLED!'); // Fill the generic array with several data from the listener: $this->setProtocolName($helperInstance->getSocketInstance()->getSocketProtocol()); @@ -98,8 +100,47 @@ class ConnectionInfo extends BaseInfo implements ShareableInfo, Registerable { // Set helper here $this->setHelperInstance($helperInstance); + // Trace message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CONNECTION-INFO: EXIT!'); + } + + /** + * Fills the information class with peer data from given socket instance + * + * @param $socketInstance An instance of a StorableSocket class + * @return void + * @throws InvalidSocketException If no peer data can be retrived from socket + */ + public function fillWithSocketPeerInformation (StorableSocket $socketInstance) { + // Trace message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('CONNECTION-INFO: socketInstance.socketResource=%s - CALLED!', $socketInstance->getSocketResource())); + + // Init variables + $socketAddress = '0.0.0.0'; + $socketPort = '0'; + + // Get peer name + if (!$socketInstance->getSocketPeerName($socketAddress, $socketPort)) { + // Did not work + throw new InvalidSocketException(array($this, $socketInstance->getSocketResource()), self::EXCEPTION_INVALID_SOCKET); + } // END - if + // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CONNECTION-INFO: EXIT!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('CONNECTION-INFO: socketAddress=%s,socketPort=%d', $socketAddress, $socketPort)); + + // Fill the generic array with several data from the listener: + $this->setProtocolName($socketInstance->getSocketProtocol()); + $this->setGenericArrayElement('connection', 'dummy', 'dummy', LocateableNode::UNL_PART_ADDRESS , $socketAddress); + $this->setGenericArrayElement('connection', 'dummy', 'dummy', LocateableNode::UNL_PART_PORT , $socketPort); + + // Set socket here + $this->setSocketInstance($socketInstance); + + // Debugging: + //* DEBUG-DIE: */ die(sprintf('[%s:%d]: socketInstance=%s', __METHOD__, __LINE__, print_r($socketInstance, TRUE))); + + // Trace message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CONNECTION-INFO: EXIT!'); } /** diff --git a/application/hub/classes/listener/class_BaseListener.php b/application/hub/classes/listener/class_BaseListener.php index d983ad5b9..adc9f9ca9 100644 --- a/application/hub/classes/listener/class_BaseListener.php +++ b/application/hub/classes/listener/class_BaseListener.php @@ -174,7 +174,7 @@ class BaseListener extends BaseHubSystem implements Visitable { */ protected function registerServerSocketInstance (StorableSocket $socketInstance) { // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('LISTENER: socketInstance=%s - CALLED!', $socketInstance->__toString())); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('LISTENER: socketInstance=%s - CALLED!', $socketInstance->__toString())); // First check if it is valid if ($this->isServerSocketRegistered($socketInstance)) { @@ -201,13 +201,13 @@ class BaseListener extends BaseHubSystem implements Visitable { $registryInstance->registerSocketInstance($infoInstance, $socketInstance); // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('LISTENER: Setting socketInstance ... (socketResource=%s)', $socketInstance->getSocketResource())); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('LISTENER: Setting socketInstance ... (socketResource=%s)', $socketInstance->getSocketResource())); // And set it here $this->setSocketInstance($socketInstance); // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('LISTENER: EXIT!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('LISTENER: EXIT!'); } /** @@ -219,7 +219,7 @@ class BaseListener extends BaseHubSystem implements Visitable { */ protected function isServerSocketRegistered (StorableSocket $socketInstance) { // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('LISTENER: socketInstance=%s - CALLED!', $socketInstance->__toString())); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('LISTENER: socketInstance=%s - CALLED!', $socketInstance->__toString())); // Get a socket registry instance (singleton) $registryInstance = SocketRegistryFactory::createSocketRegistryInstance(); @@ -228,7 +228,7 @@ class BaseListener extends BaseHubSystem implements Visitable { $infoInstance = ConnectionInfoFactory::createConnectionInfoInstance($this->getProtocolName(), 'listener'); // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('LISTENER: infoInstance[]=%s', gettype($infoInstance))); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('LISTENER: infoInstance[]=%s', gettype($infoInstance))); // Is the instance set? if (!($infoInstance instanceof ShareableInfo)) { @@ -240,13 +240,13 @@ class BaseListener extends BaseHubSystem implements Visitable { $infoInstance->fillWithListenerInformation($this); // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('LISTENER: Checking socketInstance ... (socketResource=%s)', $socketInstance->getSocketResource())); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('LISTENER: Checking socketInstance ... (socketResource=%s)', $socketInstance->getSocketResource())); // Check it $isRegistered = $registryInstance->isSocketRegistered($infoInstance, $socketInstance); // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('LISTENER: isRegistered=%d - EXIT!', intval($isRegistered))); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('LISTENER: isRegistered=%d - EXIT!', intval($isRegistered))); // Return result return $isRegistered; @@ -260,7 +260,7 @@ class BaseListener extends BaseHubSystem implements Visitable { */ public function accept (Visitor $visitorInstance) { // Debug message - /* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($this->getProtocolName()) . '-LISTENER: ' . $visitorInstance->__toString() . ' has visited ' . $this->__toString() . ' - CALLED!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($this->getProtocolName()) . '-LISTENER: ' . $visitorInstance->__toString() . ' has visited ' . $this->__toString() . ' - CALLED!'); // Visit this listener $visitorInstance->visitListener($this); @@ -271,7 +271,7 @@ class BaseListener extends BaseHubSystem implements Visitable { } // END - if // Debug message - /* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($this->getProtocolName()) . '-LISTENER: ' . $visitorInstance->__toString() . ' has visited ' . $this->__toString() . ' - EXIT!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($this->getProtocolName()) . '-LISTENER: ' . $visitorInstance->__toString() . ' has visited ' . $this->__toString() . ' - EXIT!'); } /** @@ -295,7 +295,7 @@ class BaseListener extends BaseHubSystem implements Visitable { */ protected function doListenSocketSelect ($peerSuffix) { // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('LISTENER: peerSuffix=%s - CALLED!', $peerSuffix)); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('LISTENER: peerSuffix=%s - CALLED!', $peerSuffix)); // Check on all instances assert($this->getPoolInstance() instanceof Poolable); @@ -305,19 +305,19 @@ class BaseListener extends BaseHubSystem implements Visitable { $socketInstance = SocketFactory::createNextAcceptedSocketFromPool($this->getPoolInstance(), $this->getSocketInstance()); // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('LISTENER: socketInstance[]=%s accepted.', gettype($socketInstance))); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('LISTENER: socketInstance[]=%s accepted.', gettype($socketInstance))); // Is socket instance set? if (!($socketInstance instanceof StorableSocket)) { // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('LISTENER: No new connection on listener ... - EXIT!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('LISTENER: No new connection on listener ... - EXIT!'); // Nothing has changed on the listener return; } // END - if // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('LISTENER: socketInstance.socketResource=%s accepted.', $socketInstance->getSocketResource())); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('LISTENER: socketInstance.socketResource=%s accepted.', $socketInstance->getSocketResource())); // Init peer address/port $peerAddress = '0.0.0.0'; @@ -368,7 +368,7 @@ class BaseListener extends BaseHubSystem implements Visitable { $currentSocketData = $this->getIteratorInstance()->current(); // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('LISTENER: currentSocketData=' . $currentSocketData[Poolable::SOCKET_ARRAY_INSTANCE] . ',type=' . $currentSocketData[Poolable::SOCKET_ARRAY_CONN_TYPE] . ',serverSocket=' . $this->getSocketInstance()->getSocketResource()); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('LISTENER: currentSocketData=' . $currentSocketData[Poolable::SOCKET_ARRAY_INSTANCE] . ',type=' . $currentSocketData[Poolable::SOCKET_ARRAY_CONN_TYPE] . ',serverSocket=' . $this->getSocketInstance()->getSocketResource()); // Handle it here, if not main server socket if (($currentSocketData[Poolable::SOCKET_ARRAY_CONN_TYPE] != StorableSocket::CONNECTION_TYPE_SERVER) && (!$currentSocketData[Poolable::SOCKET_ARRAY_INSTANCE]->equals($this->getSocketInstance()))) { @@ -380,7 +380,7 @@ class BaseListener extends BaseHubSystem implements Visitable { $this->getIteratorInstance()->next(); // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('LISTENER: EXIT!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('LISTENER: EXIT!'); } /** @@ -391,7 +391,7 @@ class BaseListener extends BaseHubSystem implements Visitable { */ public function ifListenerAcceptsPackageData (array $packageData) { // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('LISTENER: packageData()=%d - CALLED!', count($packageData))); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('LISTENER: packageData()=%d - CALLED!', count($packageData))); // Check if same socket protocol $socketProtocol = $this->getSocketInstance()->getSocketProtocol(); @@ -403,13 +403,13 @@ class BaseListener extends BaseHubSystem implements Visitable { $unlProtocol = $unlInstance->getUnlProtocol(); // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('LISTENER: unlInstance.unlProtocol=%s,socketProtocol=%s', $unlProtocol, $socketProtocol)); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('LISTENER: unlInstance.unlProtocol=%s,socketProtocol=%s', $unlProtocol, $socketProtocol)); // Is same protocol? $accepts = ($unlProtocol == $socketProtocol); // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('LISTENER: accepts=%d - EXIT!', $accepts)); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('LISTENER: accepts=%d - EXIT!', $accepts)); // Return the result return $accepts; diff --git a/application/hub/classes/listener/class_BaseListenerDecorator.php b/application/hub/classes/listener/class_BaseListenerDecorator.php index 620a4eec4..866c6d81b 100644 --- a/application/hub/classes/listener/class_BaseListenerDecorator.php +++ b/application/hub/classes/listener/class_BaseListenerDecorator.php @@ -71,7 +71,7 @@ class BaseListenerDecorator extends BaseDecorator implements Visitable { */ public final function getListenAddress () { // Trace message - /* NOSY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('LISTENER-DECORATOR: Calling this->getListenerInstance()->getListenAddress() ...'); + //* NOSY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('LISTENER-DECORATOR: Calling this->getListenerInstance()->getListenAddress() ...'); return $this->getListenerInstance()->getListenAddress(); } @@ -82,7 +82,7 @@ class BaseListenerDecorator extends BaseDecorator implements Visitable { */ public final function getListenPort () { // Trace message - /* NOSY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('LISTENER-DECORATOR: Calling this->getListenerInstance()->getListenPort() ...'); + //* NOSY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('LISTENER-DECORATOR: Calling this->getListenerInstance()->getListenPort() ...'); return $this->getListenerInstance()->getListenPort(); } @@ -126,7 +126,7 @@ class BaseListenerDecorator extends BaseDecorator implements Visitable { */ public final function getPoolInstance () { // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('LISTENER-DECORATOR: Getting poolInstance from inner listenerInstance=%s - CALLED!', $this->getListenerInstance()->__toString())); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('LISTENER-DECORATOR: Getting poolInstance from inner listenerInstance=%s - CALLED!', $this->getListenerInstance()->__toString())); // Get it return $this->getListenerInstance()->getPoolInstance(); @@ -140,7 +140,7 @@ class BaseListenerDecorator extends BaseDecorator implements Visitable { */ public function monitorIncomingRawData () { // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('LISTENER-DECORATOR: CALLED!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('LISTENER-DECORATOR: CALLED!'); // Get the handler instance $handlerInstance = $this->getListenerInstance()->getHandlerInstance(); @@ -152,17 +152,17 @@ class BaseListenerDecorator extends BaseDecorator implements Visitable { */ if (!$handlerInstance instanceof Networkable) { // Skip this silently for now. Later on, this will become mandatory! - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('LISTENER-DECORATOR: No handler assigned to this listener decorator. this=' . $this->__toString() . ', listenerInstance=' . $this->getListenerInstance()->__toString()); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('LISTENER-DECORATOR: No handler assigned to this listener decorator. this=' . $this->__toString() . ', listenerInstance=' . $this->getListenerInstance()->__toString()); return; } // END - if // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('LISTENER-DECORATOR: handlerInstance=%s', $handlerInstance->__toString())); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('LISTENER-DECORATOR: handlerInstance=%s', $handlerInstance->__toString())); // Does the handler have some decoded data pending? if (!$handlerInstance->isRawDataPending()) { // No data is pending so skip further code silently - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('LISTENER-DECORATOR: No data pending on handlerInstance=' . $handlerInstance->__toString() . ' - EXIT!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('LISTENER-DECORATOR: No data pending on handlerInstance=' . $handlerInstance->__toString() . ' - EXIT!'); return; } // END - if @@ -176,11 +176,11 @@ class BaseListenerDecorator extends BaseDecorator implements Visitable { * know if the decoded data origins from a TCP or UDP connection so it * can just be passed over to the network package receiver. */ - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('LISTENER-DECORATOR: Going to handle over some raw data to receiverInstance=' . $receiverInstance->__toString() . ' ...'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('LISTENER-DECORATOR: Going to handle over some raw data to receiverInstance=' . $receiverInstance->__toString() . ' ...'); $receiverInstance->addRawDataToIncomingStack($handlerInstance); // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('LISTENER-DECORATOR: EXIT!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('LISTENER-DECORATOR: EXIT!'); } /** diff --git a/application/hub/classes/listener/socket/class_SocketFileListener.php b/application/hub/classes/listener/socket/class_SocketFileListener.php index d35a4bc00..02b8fd252 100644 --- a/application/hub/classes/listener/socket/class_SocketFileListener.php +++ b/application/hub/classes/listener/socket/class_SocketFileListener.php @@ -107,13 +107,13 @@ class SocketFileListener extends BaseListener implements Listenable { */ public function doListen() { // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-FILE-LISTENER: Calling this->doListenSocketSelect() ... - CALLED!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-FILE-LISTENER: Calling this->doListenSocketSelect() ... - CALLED!'); // Call super method $this->doListenSocketSelect(''); // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-FILE-LISTENER: EXIT!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-FILE-LISTENER: EXIT!'); } /** @@ -124,12 +124,12 @@ class SocketFileListener extends BaseListener implements Listenable { */ public function ifListenerAcceptsPackageData (array $packageData) { // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('SOCKET-FILE-LISTENER: packageData()=%d - CALLED!', count($packageData))); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('SOCKET-FILE-LISTENER: packageData()=%d - CALLED!', count($packageData))); // Call parent method if (!parent::ifListenerAcceptsPackageData($packageData)) { // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-FILE-LISTENER: Protocol mismatching, not accepting package.'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-FILE-LISTENER: Protocol mismatching, not accepting package.'); // Is already different protocol return FALSE; @@ -145,7 +145,7 @@ class SocketFileListener extends BaseListener implements Listenable { $accepts = $tagsInstance->ifPackageDataIsAcceptedByListener($packageData, $this); // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('SOCKET-FILE-LISTENER: accepts=%d - EXIT!', $accepts)); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('SOCKET-FILE-LISTENER: accepts=%d - EXIT!', $accepts)); // Return the result return $accepts; diff --git a/application/hub/classes/listener/tcp/class_TcpListener.php b/application/hub/classes/listener/tcp/class_TcpListener.php index afe84f4d6..11c7b2c1f 100644 --- a/application/hub/classes/listener/tcp/class_TcpListener.php +++ b/application/hub/classes/listener/tcp/class_TcpListener.php @@ -106,13 +106,13 @@ class TcpListener extends BaseListener implements Listenable { */ public function doListen () { // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('TCP-LISTENER: Calling this->doListenSocketSelect(:0) ... - CALLED!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('TCP-LISTENER: Calling this->doListenSocketSelect(:0) ... - CALLED!'); // Call super method $this->doListenSocketSelect(':0'); // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('TCP-LISTENER: EXIT!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('TCP-LISTENER: EXIT!'); } /** diff --git a/application/hub/classes/listener/udp/class_UdpListener.php b/application/hub/classes/listener/udp/class_UdpListener.php index 60a94ecac..668a35e83 100644 --- a/application/hub/classes/listener/udp/class_UdpListener.php +++ b/application/hub/classes/listener/udp/class_UdpListener.php @@ -106,13 +106,13 @@ class UdpListener extends BaseListener implements Listenable { */ public function doListen () { // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('UDP-LISTENER: Calling this->doListenSocketSelect(:0) ... - CALLED!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('UDP-LISTENER: Calling this->doListenSocketSelect(:0) ... - CALLED!'); // Call super method $this->doListenSocketSelect(':0'); // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('UDP-LISTENER: EXIT!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('UDP-LISTENER: EXIT!'); } /** diff --git a/application/hub/classes/locator/class_UniversalNodeLocator.php b/application/hub/classes/locator/class_UniversalNodeLocator.php index fb32da8da..8f381f390 100644 --- a/application/hub/classes/locator/class_UniversalNodeLocator.php +++ b/application/hub/classes/locator/class_UniversalNodeLocator.php @@ -170,7 +170,7 @@ class UniversalNodeLocator extends BaseHubSystem implements LocateableNode, Regi */ public function parseStringAsUnl ($unl) { // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('UNIVERSAL-NODE-LOCATOR: unl=[%s]=%s - CALLED!', gettype($unl), $unl)); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('UNIVERSAL-NODE-LOCATOR: unl=[%s]=%s - CALLED!', gettype($unl), $unl)); // Is it basically valid? if (!is_string($unl)) { @@ -213,7 +213,7 @@ class UniversalNodeLocator extends BaseHubSystem implements LocateableNode, Regi */ private function parseUniversalNodeLocator ($unl) { // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('UNIVERSAL-NODE-LOCATOR: unl=[%s]=%s - CALLED!', gettype($unl), $unl)); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('UNIVERSAL-NODE-LOCATOR: unl=[%s]=%s - CALLED!', gettype($unl), $unl)); // Make sure the UNL is valid if (!$this->isValidUniversalNodeLocator($unl)) { @@ -238,7 +238,7 @@ class UniversalNodeLocator extends BaseHubSystem implements LocateableNode, Regi ); // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('UNIVERSAL-NODE-LOCATOR: unlData=' . print_r($unlData, TRUE) . ' - EXIT!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('UNIVERSAL-NODE-LOCATOR: unlData=' . print_r($unlData, TRUE) . ' - EXIT!'); // Call init method $this->initUniversalNodeLocator($unlData); @@ -287,13 +287,13 @@ class UniversalNodeLocator extends BaseHubSystem implements LocateableNode, Regi */ private final function isValidUniversalNodeLocator ($unl) { // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('UNIVERSAL-NODE-LOCATOR: unl=' . $unl . ' - CALLED!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('UNIVERSAL-NODE-LOCATOR: unl=' . $unl . ' - CALLED!'); // Very basic regex check $isValid = (preg_match($this->getRegularExpression(), $unl) === 1); // Return result - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('UNIVERSAL-NODE-LOCATOR: isValid=' . intval($isValid) . ' - EXIT!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('UNIVERSAL-NODE-LOCATOR: isValid=' . intval($isValid) . ' - EXIT!'); return $isValid; } diff --git a/application/hub/classes/nodes/class_BaseHubNode.php b/application/hub/classes/nodes/class_BaseHubNode.php index 9f1597154..964d5427f 100644 --- a/application/hub/classes/nodes/class_BaseHubNode.php +++ b/application/hub/classes/nodes/class_BaseHubNode.php @@ -683,13 +683,13 @@ class BaseHubNode extends BaseHubSystem implements Updateable, AddableCriteria { */ public function ifNodeIsAnnouncing () { // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NODE: ifNodeIsAnnouncing(): state=' . $this->getStateInstance()->getStateName()); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NODE: ifNodeIsAnnouncing(): state=' . $this->getStateInstance()->getStateName()); // Simply check the state of this node $hasAnnounced = ($this->getStateInstance() instanceof NodeAnnouncingState); // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NODE: ifNodeIsAnnouncing(): hasAnnounced=' . intval($hasAnnounced)); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NODE: ifNodeIsAnnouncing(): hasAnnounced=' . intval($hasAnnounced)); // Return it return $hasAnnounced; @@ -703,13 +703,13 @@ class BaseHubNode extends BaseHubSystem implements Updateable, AddableCriteria { */ public function ifNodeHasAnnouncementCompleted () { // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NODE: ifNodeHasAnnouncementCompleted(): state=' . $this->getStateInstance()->getStateName()); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NODE: ifNodeHasAnnouncementCompleted(): state=' . $this->getStateInstance()->getStateName()); // Simply check the state of this node $hasAnnouncementCompleted = ($this->getStateInstance() instanceof NodeAnnouncementCompletedState); // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NODE: ifNodeHasAnnouncementCompleted(): hasAnnouncementCompleted=' . intval($hasAnnouncementCompleted)); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NODE: ifNodeHasAnnouncementCompleted(): hasAnnouncementCompleted=' . intval($hasAnnouncementCompleted)); // Return it return $hasAnnouncementCompleted; @@ -732,7 +732,7 @@ class BaseHubNode extends BaseHubSystem implements Updateable, AddableCriteria { * @return void */ public final function enableAcceptDhtBootstrap ($acceptDhtBootstrap = TRUE) { - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NODE: Enabling DHT bootstrap requests ...'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NODE: Enabling DHT bootstrap requests ...'); $this->acceptDhtBootstrap = $acceptDhtBootstrap; } @@ -760,7 +760,7 @@ class BaseHubNode extends BaseHubSystem implements Updateable, AddableCriteria { */ public function determineUniversalNodeLocator () { // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NODE: CALLED!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NODE: CALLED!'); // Is there cache? if (!isset($GLOBALS[__METHOD__])) { @@ -773,7 +773,7 @@ class BaseHubNode extends BaseHubSystem implements Updateable, AddableCriteria { } // END - if // Return it - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NODE: unlInstance= ' . $GLOBALS[__METHOD__]->__toString() . ' - EXIT!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NODE: unlInstance= ' . $GLOBALS[__METHOD__]->__toString() . ' - EXIT!'); return $GLOBALS[__METHOD__]; } diff --git a/application/hub/classes/package/assembler/class_PackageAssembler.php b/application/hub/classes/package/assembler/class_PackageAssembler.php index b21adaf75..4e8eddfd7 100644 --- a/application/hub/classes/package/assembler/class_PackageAssembler.php +++ b/application/hub/classes/package/assembler/class_PackageAssembler.php @@ -117,7 +117,7 @@ class PackageAssembler extends BaseHubSystem implements Assembler, Registerable, $isInputBufferEmpty = $this->getPackageInstance()->getStackInstance()->isStackEmpty(NetworkPackage::STACKER_NAME_DECODED_HANDLED); // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-ASSEMBLER: isInputBufferEmpty=' . intval($isInputBufferEmpty)); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-ASSEMBLER: isInputBufferEmpty=' . intval($isInputBufferEmpty)); // Return it return $isInputBufferEmpty; @@ -186,7 +186,7 @@ class PackageAssembler extends BaseHubSystem implements Assembler, Registerable, */ private function handlePackageByUnhandledPackage (array $packageContent) { // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-ASSEMBLER: packageData[' . BaseRawDataHandler::PACKAGE_RAW_DATA . ']=' . $packageContent[BaseRawDataHandler::PACKAGE_RAW_DATA]); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-ASSEMBLER: packageData[' . BaseRawDataHandler::PACKAGE_RAW_DATA . ']=' . $packageContent[BaseRawDataHandler::PACKAGE_RAW_DATA]); // Check for some conditions if ((!$this->ifInputBufferIsEmpty()) || (!$this->isPackageContentCompleted($packageContent))) { @@ -194,7 +194,7 @@ class PackageAssembler extends BaseHubSystem implements Assembler, Registerable, $this->pendingData .= $packageContent[BaseRawDataHandler::PACKAGE_RAW_DATA]; // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-ASSEMBLER: Partial data received. Waiting for more ... ( ' . strlen($packageContent[BaseRawDataHandler::PACKAGE_RAW_DATA]) . ' bytes)'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-ASSEMBLER: Partial data received. Waiting for more ... ( ' . strlen($packageContent[BaseRawDataHandler::PACKAGE_RAW_DATA]) . ' bytes)'); } else { // Debug message //* DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-ASSEMBLER: packageContent=' . print_r($packageContent, TRUE) . ',chunks='.print_r($chunks, TRUE)); @@ -225,7 +225,7 @@ class PackageAssembler extends BaseHubSystem implements Assembler, Registerable, $isPending = (!$this->getStackInstance()->isStackEmpty(self::STACKER_NAME_MULTIPLE_MESSAGE)); // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-ASSEMBLER: isPending=' . intval($isPending) . ' - EXIT!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-ASSEMBLER: isPending=' . intval($isPending) . ' - EXIT!'); // Return it return $isPending; @@ -238,7 +238,7 @@ class PackageAssembler extends BaseHubSystem implements Assembler, Registerable, */ public function handlePendingData () { // Debug output - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-ASSEMBLER: Going to decode ' . strlen($this->pendingData) . ' Bytes of pending data. pendingData=' . $this->pendingData); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-ASSEMBLER: Going to decode ' . strlen($this->pendingData) . ' Bytes of pending data. pendingData=' . $this->pendingData); // Assert on condition assert(!$this->isPendingDataEmpty()); @@ -246,8 +246,8 @@ class PackageAssembler extends BaseHubSystem implements Assembler, Registerable, // No markers set? if (!$this->ifStartEndMarkersSet($this->pendingData)) { // This will cause an assertition in next call, so simply wait for more data - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-ASSEMBLER: Pending data of ' . strlen($this->pendingData) . ' Bytes are incomplete, waiting for more ...'); - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-ASSEMBLER: this->pendingData=' . $this->pendingData); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-ASSEMBLER: Pending data of ' . strlen($this->pendingData) . ' Bytes are incomplete, waiting for more ...'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-ASSEMBLER: this->pendingData=' . $this->pendingData); return; } elseif (substr_count($this->pendingData, BaseRawDataHandler::STREAM_START_MARKER) > 1) { /* @@ -282,7 +282,7 @@ class PackageAssembler extends BaseHubSystem implements Assembler, Registerable, $this->clearPendingData(); // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-ASSEMBLER: Last block of partial data received. A total of ' . strlen($packageContent[BaseRawDataHandler::PACKAGE_RAW_DATA]) . ' bytes has been received.'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-ASSEMBLER: Last block of partial data received. A total of ' . strlen($packageContent[BaseRawDataHandler::PACKAGE_RAW_DATA]) . ' bytes has been received.'); // Make sure last CHUNK_SEPARATOR is not there if (substr($packageContent[BaseRawDataHandler::PACKAGE_RAW_DATA], -1, 1) == PackageFragmenter::CHUNK_SEPARATOR) { @@ -298,7 +298,7 @@ class PackageAssembler extends BaseHubSystem implements Assembler, Registerable, $chunks = explode(PackageFragmenter::CHUNK_SEPARATOR, $packageContent[BaseRawDataHandler::PACKAGE_RAW_DATA]); // Add all chunks because the last final chunk is found - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-ASSEMBLER: Going to add ' . count($chunks) . ' to chunk handler ...'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-ASSEMBLER: Going to add ' . count($chunks) . ' to chunk handler ...'); $this->getHandlerInstance()->addAllChunksWithFinal($chunks); } diff --git a/application/hub/classes/package/class_NetworkPackage.php b/application/hub/classes/package/class_NetworkPackage.php index 9f70d1ab0..a7a0b05b0 100644 --- a/application/hub/classes/package/class_NetworkPackage.php +++ b/application/hub/classes/package/class_NetworkPackage.php @@ -404,7 +404,7 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R // Is an entry found? if (count($senderData) > 0) { // Make sure the element 'private_key_hash' is there - /* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: senderData=' . print_r($senderData, TRUE)); + //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: senderData=' . print_r($senderData, TRUE)); assert(isset($senderData[NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_PRIVATE_KEY_HASH])); // Don't accept empty hashes @@ -439,7 +439,7 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R */ private function getHashFromContent ($content) { // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: content[md5]=' . md5($content) . ',sender=' . $this->getSessionId() . ',compressor=' . $this->getCompressorInstance()->getCompressorExtension()); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: content[md5]=' . md5($content) . ',sender=' . $this->getSessionId() . ',compressor=' . $this->getCompressorInstance()->getCompressorExtension()); // Create the hash // @TODO md5() is very weak, but it needs to be fast @@ -452,7 +452,7 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R ); // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: content[md5]=' . md5($content) . ',sender=' . $this->getSessionId() . ',hash=' . $hash . ',compressor=' . $this->getCompressorInstance()->getCompressorExtension()); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: content[md5]=' . md5($content) . ',sender=' . $this->getSessionId() . ',hash=' . $hash . ',compressor=' . $this->getCompressorInstance()->getCompressorExtension()); // And return it return $hash; @@ -513,7 +513,7 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R */ public function getHashFromContentSessionId (array $decodedContent, $sessionId) { // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: content[md5]=' . md5($decodedContent[self::PACKAGE_CONTENT_MESSAGE]) . ',sender=' . $sessionId . ',compressor=' . $decodedContent[self::PACKAGE_CONTENT_EXTENSION]); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: content[md5]=' . md5($decodedContent[self::PACKAGE_CONTENT_MESSAGE]) . ',sender=' . $sessionId . ',compressor=' . $decodedContent[self::PACKAGE_CONTENT_EXTENSION]); // Create the hash // @TODO md5() is very weak, but it needs to be fast @@ -569,7 +569,7 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R $currentRecipient = $iteratorInstance->current(); // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: Setting recipient to ' . $currentRecipient . ',previous=' . $packageData[self::PACKAGE_DATA_RECIPIENT]); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: Setting recipient to ' . $currentRecipient . ',previous=' . $packageData[self::PACKAGE_DATA_RECIPIENT]); // Set the recipient $packageData[self::PACKAGE_DATA_RECIPIENT] = $currentRecipient; @@ -578,7 +578,7 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R $this->getStackInstance()->pushNamed(self::STACKER_NAME_DECLARED, $packageData); // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: Package declared for recipient ' . $currentRecipient); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: Package declared for recipient ' . $currentRecipient); // Skip to next entry $iteratorInstance->next(); @@ -603,7 +603,7 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R */ private function deliverRawPackageData (array $packageData) { // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE: packageData()=%d - CALLED!', count($packageData))); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE: packageData()=%d - CALLED!', count($packageData))); /* * This package may become big, depending on the shared object size or @@ -623,7 +623,7 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R $socketInstance = $discoveryInstance->discoverSocket($packageData, StorableSocket::CONNECTION_TYPE_OUTGOING); // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: Reached line ' . __LINE__ . ' after discoverSocket() has been called.'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: Reached line ' . __LINE__ . ' after discoverSocket() has been called.'); // The socket needs to be put in a special registry that can handle such data $registryInstance = SocketRegistryFactory::createSocketRegistryInstance(); @@ -632,7 +632,7 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R $helperInstance = Registry::getRegistry()->getInstance('connection'); // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: stateInstance=' . $helperInstance->getStateInstance()); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: stateInstance=' . $helperInstance->getStateInstance()); // And make sure it is valid assert($helperInstance instanceof ConnectionHelper); @@ -644,12 +644,12 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R $infoInstance->fillWithConnectionHelperInformation($helperInstance); // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: Reached line ' . __LINE__ . ' before isSocketRegistered() has been called.'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: Reached line ' . __LINE__ . ' before isSocketRegistered() has been called.'); // Is it not there? if (($socketInstance->isValidSocket()) && (!$registryInstance->isSocketRegistered($infoInstance, $socketInstance))) { // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: Registering socket ' . $socketInstance . ' ...'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: Registering socket ' . $socketInstance . ' ...'); // Then register it $registryInstance->registerSocketInstance($infoInstance, $socketInstance, $packageData); @@ -662,19 +662,19 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R } // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: Reached line ' . __LINE__ . ' after isSocketRegistered() has been called.'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: Reached line ' . __LINE__ . ' after isSocketRegistered() has been called.'); // Make sure the connection is up $helperInstance->getStateInstance()->validatePeerStateConnected(); // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: Reached line ' . __LINE__ . ' after validatePeerStateConnected() has been called.'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: Reached line ' . __LINE__ . ' after validatePeerStateConnected() has been called.'); // Enqueue it again on the out-going queue, the connection is up and working at this point $this->getStackInstance()->pushNamed(self::STACKER_NAME_OUTGOING, $packageData); // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: Reached line ' . __LINE__ . ' after pushNamed() has been called.'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: Reached line ' . __LINE__ . ' after pushNamed() has been called.'); } /** @@ -721,12 +721,12 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R */ private function generatePackageHash ($content, $senderId) { // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: content()=' . strlen($content) . ',senderId=' . $senderId . ' - CALLED!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: content()=' . strlen($content) . ',senderId=' . $senderId . ' - CALLED!'); // Is the feature enabled? if (!FrameworkFeature::isFeatureAvailable('hubcoin_reward')) { // Feature is not enabled - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: Feature "hubcoin_reward" not available, not generating package hash. Returning NULL ...'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: Feature "hubcoin_reward" not available, not generating package hash. Returning NULL ...'); return NULL; } // END - if @@ -738,11 +738,11 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R ); // Hash content and sender id together, use scrypt - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: senderId=' . $senderId . ',content()=' . strlen($content)); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: senderId=' . $senderId . ',content()=' . strlen($content)); $hash = FrameworkFeature::callFeature('hubcoin_reward', 'generateHash', array($senderId . ':' . $content . ':' . $this->determineSenderPrivateKeyHash($data))); // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: hash=' . $hash . ' - EXIT!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: hash=' . $hash . ' - EXIT!'); // Return it return $hash; @@ -758,7 +758,7 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R */ private function isPackageHashValid (array $decodedArray) { // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: decodedArray=' . print_r($decodedArray, TRUE) . ' - CALLED!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: decodedArray=' . print_r($decodedArray, TRUE) . ' - CALLED!'); // Make sure the required array elements are there assert(isset($decodedArray[self::PACKAGE_CONTENT_SENDER])); @@ -769,17 +769,17 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R // Is the feature enabled? if (!FrameworkFeature::isFeatureAvailable('hubcoin_reward')) { // Feature is not enabled, so hashes are always valid - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: Feature "hubcoin_reward" not available, not checking hash. Returning TRUE ...'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: Feature "hubcoin_reward" not available, not checking hash. Returning TRUE ...'); return TRUE; } // END - if // Check validity - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: senderId=' . $decodedArray[self::PACKAGE_CONTENT_SENDER] . ',message()=' . strlen($decodedArray[self::PACKAGE_CONTENT_MESSAGE]) . ',hash=' . $decodedArray[self::PACKAGE_CONTENT_HASH]); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: senderId=' . $decodedArray[self::PACKAGE_CONTENT_SENDER] . ',message()=' . strlen($decodedArray[self::PACKAGE_CONTENT_MESSAGE]) . ',hash=' . $decodedArray[self::PACKAGE_CONTENT_HASH]); //* DEBUG-DIE: */ die(__METHOD__ . ': decodedArray=' . print_r($decodedArray, TRUE)); $isHashValid = FrameworkFeature::callFeature('hubcoin_reward', 'checkHash', array($decodedArray[self::PACKAGE_CONTENT_SENDER] . ':' . $decodedArray[self::PACKAGE_CONTENT_MESSAGE] . ':' . $this->determineSenderPrivateKeyHash($decodedArray), $decodedArray[self::PACKAGE_CONTENT_HASH])); // Return it - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: isHashValid=' . intval($isHashValid) . ' - EXIT!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: isHashValid=' . intval($isHashValid) . ' - EXIT!'); return $isHashValid; } @@ -793,11 +793,11 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R */ public function enqueueRawDataFromTemplate (HubHelper $helperInstance) { // Debug message - /* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: CALLED!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: CALLED!'); // Get the raw content ... $content = $helperInstance->getTemplateInstance()->getRawTemplateData(); - /* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('content(' . strlen($content) . ')=' . $content); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('content(' . strlen($content) . ')=' . $content); // ... and compress it $compressed = $this->getCompressorInstance()->compressStream($content); @@ -821,7 +821,7 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R ); // Debug message - /* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: Enqueueing package for recipientType=' . $helperInstance->getRecipientType() . ' ...'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: Enqueueing package for recipientType=' . $helperInstance->getRecipientType() . ' ...'); // Now prepare the temporary array and push it on the 'undeclared' stack $this->getStackInstance()->pushNamed(self::STACKER_NAME_UNDECLARED, array( @@ -835,7 +835,7 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R )); // Debug message - /* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: EXIT!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: EXIT!'); } /** @@ -848,7 +848,7 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R $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))); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE: isEnqueued=%d - EXIT!', intval($isEnqueued))); // Return the result return $isEnqueued; @@ -864,7 +864,7 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R $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))); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE: isDeclared=%d - EXIT!', intval($isDeclared))); // Return the result return $isDeclared; @@ -880,7 +880,7 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R $isWaitingDelivery = (($this->getStackInstance()->isStackInitialized(self::STACKER_NAME_OUTGOING)) && (!$this->getStackInstance()->isStackEmpty(self::STACKER_NAME_OUTGOING))); // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE: isWaitingDelivery=%d - EXIT!', intval($isWaitingDelivery))); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE: isWaitingDelivery=%d - EXIT!', intval($isWaitingDelivery))); // Return the result return $isWaitingDelivery; @@ -896,7 +896,7 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R $isPending = (($this->getStackInstance()->isStackInitialized(self::STACKER_NAME_OUTGOING_STREAM)) && (!$this->getStackInstance()->isStackEmpty(self::STACKER_NAME_OUTGOING_STREAM))); // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE: isPending=%d - EXIT!', intval($isPending))); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE: isPending=%d - EXIT!', intval($isPending))); // Return the result return $isPending; @@ -914,7 +914,7 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R */ public function declareEnqueuedPackage () { // Debug message - /* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: CALLED!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: CALLED!'); // Make sure this method isn't working if there is no package enqueued if (!$this->isPackageEnqueued()) { @@ -933,7 +933,7 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R $this->declareRawPackageData($packageData); // Debug message - /* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: EXIT!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: EXIT!'); } /** @@ -945,7 +945,7 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R */ public function processDeclaredPackage () { // Debug message - /* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: CALLED!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: CALLED!'); // Sanity check if we have packages declared if (!$this->isPackageDeclared()) { @@ -976,7 +976,7 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R } // Debug message - /* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: EXIT!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: EXIT!'); } /** @@ -986,7 +986,7 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R */ public function sendWaitingPackage () { // Debug message - /* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: CALLED!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: CALLED!'); // Sanity check if we have packages waiting for delivery if (!$this->isPackageWaitingForDelivery()) { @@ -1013,7 +1013,7 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R } // Debug message - /* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: EXIT!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: EXIT!'); } /** @@ -1023,7 +1023,7 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R */ public function sendEncodedData () { // Debug message - /* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: CALLED!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: CALLED!'); // Make sure there is pending encoded data assert($this->isEncodedDataPending()); @@ -1040,7 +1040,7 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R assert($encodedDataArray[self::RAW_INDEX_SOCKET_INSTANCE]->isValidSocket()); // Trace message - /* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE: Calling socketInstance->writeBufferToSocketByArray(%d,%d) ...', count($encodedDataArray), $sentBytes)); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE: Calling socketInstance->writeBufferToSocketByArray(%d,%d) ...', count($encodedDataArray), $sentBytes)); // And deliver it if (!$encodedDataArray[self::RAW_INDEX_SOCKET_INSTANCE]->writeBufferToSocketByArray($encodedDataArray, $sentBytes)) { @@ -1049,16 +1049,16 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R } // END - if // Debug message - /* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE: sentBytes[%s]=%d', gettype($sentBytes), $sentBytes)); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE: sentBytes[%s]=%d', gettype($sentBytes), $sentBytes)); // If there was an error, don't continue here if (($sentBytes === 0) && (strlen($encodedDataArray[self::RAW_INDEX_ENCODED_DATA]) > 0)) { // Nothing sent means all data has been sent - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CONNECTION-HELPER: All sent! (LINE=' . __LINE__ . ')'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CONNECTION-HELPER: All sent! (LINE=' . __LINE__ . ')'); return; } elseif (strlen($encodedDataArray[self::RAW_INDEX_ENCODED_DATA]) <= 0) { // Abort here, all sent! - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CONNECTION-HELPER: All sent! (LINE=' . __LINE__ . ')'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('CONNECTION-HELPER: All sent! (LINE=' . __LINE__ . ')'); return; } @@ -1066,7 +1066,7 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R $this->getStackInstance()->pushNamed(self::STACKER_NAME_OUTGOING_STREAM, $encodedDataArray); // Debug message - /* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: EXIT!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: EXIT!'); } /////////////////////////////////////////////////////////////////////////// @@ -1080,7 +1080,7 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R */ private function isRawDataPending () { // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: CALLED!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: CALLED!'); // Just return whether the stack is not empty $isPending = (!$this->getStackInstance()->isStackEmpty(self::STACKER_NAME_DECODED_INCOMING)); @@ -1096,7 +1096,7 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R */ public function isNewRawDataPending () { // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE: Calling this->getListenerPoolInstance()->accept(%s) ... - CALLED!', $this->getVisitorInstance())); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE: Calling this->getListenerPoolInstance()->accept(%s) ... - CALLED!', $this->getVisitorInstance())); // Visit the pool. This monitors the pool for incoming raw data. $this->getListenerPoolInstance()->accept($this->getVisitorInstance()); @@ -1105,7 +1105,7 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R $hasArrived = $this->isRawDataPending(); // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE: hasArrived=%d - EXIT!', intval($hasArrived))); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE: hasArrived=%d - EXIT!', intval($hasArrived))); // Return the status return $hasArrived; @@ -1130,7 +1130,7 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R } // END - if // Very noisy debug message: - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: Stacker size is ' . $this->getStackInstance()->getStackCount(self::STACKER_NAME_DECODED_INCOMING) . ' entries.'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: Stacker size is ' . $this->getStackInstance()->getStackCount(self::STACKER_NAME_DECODED_INCOMING) . ' entries.'); // "Pop" the next entry (the same array again) from the stack $decodedData = $this->getStackInstance()->popNamed(self::STACKER_NAME_DECODED_INCOMING); @@ -1146,7 +1146,7 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R * Also make sure the error code is SOCKET_ERROR_UNHANDLED because we * only want to handle unhandled packages here. */ - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: errorCode=' . $decodedData[BaseRawDataHandler::PACKAGE_ERROR_CODE] . '(' . StorableSocket::SOCKET_ERROR_UNHANDLED . ')'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: errorCode=' . $decodedData[BaseRawDataHandler::PACKAGE_ERROR_CODE] . '(' . StorableSocket::SOCKET_ERROR_UNHANDLED . ')'); assert($decodedData[BaseRawDataHandler::PACKAGE_ERROR_CODE] == StorableSocket::SOCKET_ERROR_UNHANDLED); // Remove the last chunk SEPARATOR (because there is no need for it) @@ -1156,7 +1156,7 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R } // END - if // This package is "handled" and can be pushed on the next stack - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: Pushing ' . strlen($decodedData[BaseRawDataHandler::PACKAGE_RAW_DATA]) . ' bytes to stack ' . self::STACKER_NAME_DECODED_HANDLED . ' ...'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: Pushing ' . strlen($decodedData[BaseRawDataHandler::PACKAGE_RAW_DATA]) . ' bytes to stack ' . self::STACKER_NAME_DECODED_HANDLED . ' ...'); $this->getStackInstance()->pushNamed(self::STACKER_NAME_DECODED_HANDLED, $decodedData); } @@ -1174,7 +1174,7 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R $decodedData = $handlerInstance->getNextRawData(); // Very noisy debug message: - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: decodedData[' . gettype($decodedData) . ']=' . print_r($decodedData, TRUE)); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: decodedData[' . gettype($decodedData) . ']=' . print_r($decodedData, TRUE)); // And push it on our stack $this->getStackInstance()->pushNamed(self::STACKER_NAME_DECODED_INCOMING, $decodedData); @@ -1268,7 +1268,7 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R $this->getStackInstance()->popNamed(self::STACKER_NAME_DECODED_HANDLED); // ... and push it on the 'chunked' stacker - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: Pushing ' . strlen($packageContent[BaseRawDataHandler::PACKAGE_RAW_DATA]) . ' bytes on stack ' . self::STACKER_NAME_DECODED_CHUNKED . ',packageContent=' . print_r($packageContent, TRUE)); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: Pushing ' . strlen($packageContent[BaseRawDataHandler::PACKAGE_RAW_DATA]) . ' bytes on stack ' . self::STACKER_NAME_DECODED_CHUNKED . ',packageContent=' . print_r($packageContent, TRUE)); $this->getStackInstance()->pushNamed(self::STACKER_NAME_DECODED_CHUNKED, $packageContent); } @@ -1280,7 +1280,7 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R */ public function accept (Visitor $visitorInstance) { // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: ' . $visitorInstance->__toString() . ' has visited - CALLED!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: ' . $visitorInstance->__toString() . ' has visited - CALLED!'); // Visit the package $visitorInstance->visitNetworkPackage($this); @@ -1289,7 +1289,7 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R $this->getAssemblerInstance()->accept($visitorInstance); // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: ' . $visitorInstance->__toString() . ' has visited - EXIT!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: ' . $visitorInstance->__toString() . ' has visited - EXIT!'); } /** @@ -1302,7 +1302,7 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R $this->initStacks(TRUE); // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: All stacker have been re-initialized.'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: All stacker have been re-initialized.'); } /** @@ -1487,7 +1487,7 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R $messageArray[self::MESSAGE_ARRAY_DATA][self::MESSAGE_ARRAY_TYPE] = $messageArray[self::MESSAGE_ARRAY_TYPE]; // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: messageArray=' . print_r($messageArray, TRUE)); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: messageArray=' . print_r($messageArray, TRUE)); // Create a handler instance from given message type $handlerInstance = MessageTypeHandlerFactory::createMessageTypeHandlerInstance($messageArray[self::MESSAGE_ARRAY_TYPE]); @@ -1510,6 +1510,9 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R * @todo ~10% done? */ public function feedHashToMiner (array $messageData) { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE: messageData()=%d - CALLED!', count($messageData))); + // Is the feature enabled? if (!FrameworkFeature::isFeatureAvailable('hubcoin_reward')) { /* @@ -1532,7 +1535,7 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R unset($messageData[self::MESSAGE_ARRAY_DATA]); // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: messageData=' . print_r($messageData, TRUE)); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE: messageData=' . print_r($messageData, TRUE)); // Resolve session id ('sender' is a session id) into node id $nodeId = HubTools::resolveNodeIdBySessionId($messageData[self::MESSAGE_ARRAY_SENDER]); @@ -1549,7 +1552,8 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R // Also remove tags as the miner don't need this. unset($messageData[self::MESSAGE_ARRAY_TAGS]); - $this->partialStub('@TODO nodeId=' . $nodeId . ',messageData=' . print_r($messageData, TRUE)); + // Unfinished stuff: + $this->partialStub(sprintf('[%s:%d]: @TODO nodeId=%s,messageData=%s', __METHOD__, __LINE__, $nodeId, print_r($messageData, TRUE))); } } diff --git a/application/hub/classes/package/fragmenter/class_PackageFragmenter.php b/application/hub/classes/package/fragmenter/class_PackageFragmenter.php index ab7d86789..fd49cfe5a 100644 --- a/application/hub/classes/package/fragmenter/class_PackageFragmenter.php +++ b/application/hub/classes/package/fragmenter/class_PackageFragmenter.php @@ -232,7 +232,7 @@ class PackageFragmenter extends BaseHubSystem implements Fragmentable, Registera assert(strlen($finalHash) > 0); // Is the pointer already initialized? - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-FRAGMENTER: finalHash[' . gettype($finalHash) . ']=' . $finalHash); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-FRAGMENTER: finalHash[' . gettype($finalHash) . ']=' . $finalHash); assert(isset($this->chunkPointers[$finalHash])); // Return it @@ -249,7 +249,7 @@ class PackageFragmenter extends BaseHubSystem implements Fragmentable, Registera assert(isset($this->chunkPointers[$finalHash])); // Count one up - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-FRAGMENTER: finalHash[' . gettype($finalHash) . ']=' . $finalHash); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-FRAGMENTER: finalHash[' . gettype($finalHash) . ']=' . $finalHash); $this->chunkPointers[$finalHash]++; } @@ -314,7 +314,7 @@ class PackageFragmenter extends BaseHubSystem implements Fragmentable, Registera $this->generateHashFromRawData($lastChunk); // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-FRAGMENTER: Adding EOP chunk with size of ' . strlen($chunkData) . ',finalHash=' . $finalHash . ' ...'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-FRAGMENTER: Adding EOP chunk with size of ' . strlen($chunkData) . ',finalHash=' . $finalHash . ' ...'); // Add it as regular chunk $this->addChunkData($finalHash, $chunkData); @@ -335,7 +335,7 @@ class PackageFragmenter extends BaseHubSystem implements Fragmentable, Registera // Calculate real (data) chunk size $dataChunkSize = $this->getDataChunkSizeFromHash($finalHash); - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-FRAGMENTER: dataChunkSize=' . $dataChunkSize); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-FRAGMENTER: dataChunkSize=' . $dataChunkSize); // Init variables $chunkHash = ''; @@ -351,7 +351,7 @@ class PackageFragmenter extends BaseHubSystem implements Fragmentable, Registera } // END - for // Debug output - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-FRAGMENTER: Raw data of ' . strlen($rawData) . ' bytes has been fragmented into ' . count($this->chunks[$finalHash]) . ' chunk(s).'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-FRAGMENTER: Raw data of ' . strlen($rawData) . ' bytes has been fragmented into ' . count($this->chunks[$finalHash]) . ' chunk(s).'); // Add end-of-package chunk $this->appendEndOfPackageChunk($chunkData, $finalHash); @@ -378,18 +378,18 @@ class PackageFragmenter extends BaseHubSystem implements Fragmentable, Registera ); // Make sure the chunk is not larger than a TCP package can hold - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-FRAGMENTER: assert: ' . strlen($rawData) . '/' . NetworkPackage::TCP_PACKAGE_SIZE . ' ...'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-FRAGMENTER: assert: ' . strlen($rawData) . '/' . NetworkPackage::TCP_PACKAGE_SIZE . ' ...'); // @TODO This assert broke packages where the hash chunk was very large: assert(strlen($rawData) <= NetworkPackage::TCP_PACKAGE_SIZE); // Add it to the array if ($prepend === TRUE) { // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-FRAGMENTER: Prepending ' . strlen($rawData) . ' bytes of a chunk, finalHash=' . $finalHash . ' ...'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-FRAGMENTER: Prepending ' . strlen($rawData) . ' bytes of a chunk, finalHash=' . $finalHash . ' ...'); array_unshift($this->chunkHashes[$finalHash], $rawDataHash); array_unshift($this->chunks[$finalHash] , $rawData); } else { // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-FRAGMENTER: Appending ' . strlen($rawData) . ' bytes of a chunk, finalHash=' . $finalHash . ' ...'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-FRAGMENTER: Appending ' . strlen($rawData) . ' bytes of a chunk, finalHash=' . $finalHash . ' ...'); // Is the array there? if (!isset($this->chunks[$finalHash])) { @@ -430,14 +430,14 @@ class PackageFragmenter extends BaseHubSystem implements Fragmentable, Registera assert($this->serialNumber[$finalHash] <= $this->maxSerialNumber); // Encode the current serial number - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-FRAGMENTER: serialNumber[' . $finalHash . ']=' . $this->serialNumber[$finalHash]); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-FRAGMENTER: serialNumber[' . $finalHash . ']=' . $this->serialNumber[$finalHash]); $encodedSerialNumber = $this->dec2Hex($this->serialNumber[$finalHash], self::MAX_SERIAL_LENGTH); // Count one up $this->serialNumber[$finalHash]++; // Return the encoded serial number - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-FRAGMENTER: encodedSerialNumber=' . $encodedSerialNumber); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-FRAGMENTER: encodedSerialNumber=' . $encodedSerialNumber); return $encodedSerialNumber; } @@ -482,7 +482,7 @@ class PackageFragmenter extends BaseHubSystem implements Fragmentable, Registera } // Return final hash - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-FRAGMENTER: finalHash[' . gettype($finalHash) . ']=' . $finalHash); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-FRAGMENTER: finalHash[' . gettype($finalHash) . ']=' . $finalHash); return $finalHash; } @@ -497,7 +497,7 @@ class PackageFragmenter extends BaseHubSystem implements Fragmentable, Registera */ public function getNextRawDataChunk ($finalHash) { // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-FRAGMENTER: finalHash[' . gettype($finalHash) . ']=' . $finalHash); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('PACKAGE-FRAGMENTER: finalHash[' . gettype($finalHash) . ']=' . $finalHash); try { // Get current chunk index @@ -516,12 +516,12 @@ class PackageFragmenter extends BaseHubSystem implements Fragmentable, Registera // If there is no entry left, return an empty array if ((!isset($this->chunkHashes[$finalHash][$current])) || (!isset($this->chunks[$finalHash][$current]))) { // No more entries found - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(__METHOD__. ': finalHash=' . $finalHash . ',current=' . $current . ' - No more entries found!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(__METHOD__. ': finalHash=' . $finalHash . ',current=' . $current . ' - No more entries found!'); return array(); } // END - if // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(__METHOD__. ': finalHash=' . $finalHash . ',current=' . $current . ',chunkHashes()=' . count($this->chunkHashes[$finalHash]) .' - Entry choosen ...'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(__METHOD__. ': finalHash=' . $finalHash . ',current=' . $current . ',chunkHashes()=' . count($this->chunkHashes[$finalHash]) .' - Entry choosen ...'); // Generate the array $rawDataChunk = array( @@ -548,7 +548,5 @@ class PackageFragmenter extends BaseHubSystem implements Fragmentable, Registera // Reset/set serial number $this->serialNumber[$finalHash] = 0; } -} -// [EOF] -?> +} diff --git a/application/hub/classes/pools/class_BasePool.php b/application/hub/classes/pools/class_BasePool.php index ab2ba2ed4..0e6109f81 100644 --- a/application/hub/classes/pools/class_BasePool.php +++ b/application/hub/classes/pools/class_BasePool.php @@ -67,7 +67,7 @@ abstract class BasePool extends BaseHubSystem implements Poolable, Visitable { */ protected final function addInstance ($group, $poolName, Visitable $visitableInstance) { // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('POOL: group=' . $group . ',poolName=' . $poolName . ',visitableInstance=' . $visitableInstance->__toString() . ' - CALLED!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('POOL: group=' . $group . ',poolName=' . $poolName . ',visitableInstance=' . $visitableInstance->__toString() . ' - CALLED!'); // Make sure the group is not 'invalid' assert($group != 'invalid'); @@ -82,7 +82,7 @@ abstract class BasePool extends BaseHubSystem implements Poolable, Visitable { $this->getPoolEntriesInstance()->addInstance($group, $poolName, $visitableInstance); // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('POOL: EXIT!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('POOL: EXIT!'); } /** @@ -126,7 +126,7 @@ abstract class BasePool extends BaseHubSystem implements Poolable, Visitable { */ public function accept (Visitor $visitorInstance) { // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('POOL: ' . $visitorInstance->__toString() . ' has visited - CALLED!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('POOL: ' . $visitorInstance->__toString() . ' has visited - CALLED!'); // Visit this pool $visitorInstance->visitPool($this); @@ -143,30 +143,33 @@ abstract class BasePool extends BaseHubSystem implements Poolable, Visitable { Registry::getRegistry()->addInstance($visitorInstance->getVisitorMode() . '_pool_iterator', $iteratorInstance); } - // Reset the counter - $iteratorInstance->rewind(); + // Is it valid? + if (!$iteratorInstance->valid()) { + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('POOL: Rewinding iterator ...'); - // Visit all registered entries - while ($iteratorInstance->valid()) { - // Get current entry - $poolEntry = $iteratorInstance->current(); + // Rewind it + $iteratorInstance->rewind(); + } // END - if + + // Get current entry + $poolEntry = $iteratorInstance->current(); - // Is this entry visitable? - if ($poolEntry instanceof Visitable) { - // Visit this entry as well - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('POOL: Going to visit pooled object ' . $poolEntry->__toString() . ' with visitor ' . $visitorInstance->__toString() . ' ...'); - $poolEntry->accept($visitorInstance); - } else { - // Cannot visit this entry - $this->partialStub('Pool entry with key ' . $iteratorInstance->key() . ' has improper type ' . gettype($poolEntry) . ', reason: not implementing Visitable.'); - } + // Is this entry visitable? + if ($poolEntry instanceof Visitable) { + // Visit this entry as well + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('POOL: Going to visit pooled object ' . $poolEntry->__toString() . ' with visitor ' . $visitorInstance->__toString() . ' ...'); + $poolEntry->accept($visitorInstance); + } else { + // Cannot visit this entry + $this->partialStub('Pool entry with key ' . $iteratorInstance->key() . ' has improper type ' . gettype($poolEntry) . ', reason: not implementing Visitable.'); + } - // Advance to next entry - $iteratorInstance->next(); - } // END - while + // Advance to next entry + $iteratorInstance->next(); // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('POOL: ' . $visitorInstance->__toString() . ' has visited - EXIT!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('POOL: ' . $visitorInstance->__toString() . ' has visited - EXIT!'); } /** @@ -176,7 +179,7 @@ abstract class BasePool extends BaseHubSystem implements Poolable, Visitable { */ public function preShutdown () { // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('POOL: Shutting down listener pool - CALLED!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('POOL: Shutting down listener pool - CALLED!'); // Get a new visitor $visitorInstance = ObjectFactory::createObjectByConfiguredName('shutdown_listener_pool_visitor_class'); @@ -185,7 +188,7 @@ abstract class BasePool extends BaseHubSystem implements Poolable, Visitable { $this->accept($visitorInstance); // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('POOL: Shutting down listener pool - EXIT!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('POOL: Shutting down listener pool - EXIT!'); } /** @@ -210,7 +213,7 @@ abstract class BasePool extends BaseHubSystem implements Poolable, Visitable { */ public function generateListHashFromEntry (array $entry) { // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('POOL: entry()=%d - CALLED!', count($entry))); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('POOL: entry()=%d - CALLED!', count($entry))); // Debugging: //* DEBUG-DIE: */ die(__METHOD__.':entry='.print_r($entry, TRUE)); @@ -228,7 +231,7 @@ abstract class BasePool extends BaseHubSystem implements Poolable, Visitable { } // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('POOL: hash[%s]=%s - EXIT!', gettype($hash), $hash)); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('POOL: hash[%s]=%s - EXIT!', gettype($hash), $hash)); // Return hash return $hash; diff --git a/application/hub/classes/pools/listener/class_DefaultListenerPool.php b/application/hub/classes/pools/listener/class_DefaultListenerPool.php index f95ea003a..6485d298c 100644 --- a/application/hub/classes/pools/listener/class_DefaultListenerPool.php +++ b/application/hub/classes/pools/listener/class_DefaultListenerPool.php @@ -65,18 +65,19 @@ class DefaultListenerPool extends BasePool implements PoolableListener { */ public function addListener (Listenable $listenerInstance) { // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('DEFAULT-LISTENER-POOL: listenerInstance=%s - CALLED!', $listenerInstance->__toString())); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('DEFAULT-LISTENER-POOL: listenerInstance=%s - CALLED!', $listenerInstance->__toString())); // Add this listener instance to the instance list parent::addInstance($listenerInstance->getProtocolName(), 'listener', $listenerInstance); // Debug message - self::createDebugInstance(__CLASS__, __LINE__)->debugOutput( - 'DEFAULT-LISTENER-POOL: Listener ' . $listenerInstance->__toString() . - ' with protocol ' . $listenerInstance->getProtocolName() . - ' listening to ' . $listenerInstance->getListenAddress() . ':' . - $listenerInstance->getListenPort() . ' added to listener pool.' - ); + self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf( + 'DEFAULT-LISTENER-POOL: Listener %s with protocol %s listening to %s:%d added to listener pool.', + $listenerInstance->__toString(), + $listenerInstance->getProtocolName(), + $listenerInstance->getListenAddress(), + $listenerInstance->getListenPort() + )); } } diff --git a/application/hub/classes/pools/peer/class_DefaultPeerPool.php b/application/hub/classes/pools/peer/class_DefaultPeerPool.php index a843c7c9d..83a29ce30 100644 --- a/application/hub/classes/pools/peer/class_DefaultPeerPool.php +++ b/application/hub/classes/pools/peer/class_DefaultPeerPool.php @@ -78,7 +78,7 @@ class DefaultPeerPool extends BasePool implements PoolablePeer { */ private function validateSocket (StorableSocket $socketInstance) { // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('HUB-SYSTEM: socketInstance.socketResource=%s - CALLED!', $socketInstance->getSocketResource())); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('HUB-SYSTEM: socketInstance.socketResource=%s - CALLED!', $socketInstance->getSocketResource())); // Is it a valid resource? if (!$socketInstance->isValidSocket()) { @@ -106,7 +106,7 @@ class DefaultPeerPool extends BasePool implements PoolablePeer { */ public function addPeer (StorableSocket $socketInstance, $connectionType) { // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DEFAULT-PEER-POOL: socketResource[' . gettype($socketInstance->getSocketResource()) . ']=' . $socketInstance->getSocketResource() . ',connectionType=' . $connectionType . ' - CALLED!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DEFAULT-PEER-POOL: socketResource[' . gettype($socketInstance->getSocketResource()) . ']=' . $socketInstance->getSocketResource() . ',connectionType=' . $connectionType . ' - CALLED!'); // Validate the socket $this->validateSocket($socketInstance); @@ -122,7 +122,7 @@ class DefaultPeerPool extends BasePool implements PoolablePeer { $peerPort = '0'; // Trace message - /* NOSY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DEFAULT-PEER-POOL: Calling this->getListenerInstance() ...'); + //* NOSY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DEFAULT-PEER-POOL: Calling this->getListenerInstance() ...'); // The socket resource should not match server socket if (!$this->getListenerInstance()->getSocketInstance()->equals($socketInstance)) { @@ -137,7 +137,7 @@ class DefaultPeerPool extends BasePool implements PoolablePeer { } // Debug message - self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DEFAULT-PEER-POOL: Adding peer ' . $peerAddress . ':' . $peerPort . ',socketResource=' . $socketInstance->getSocketResource() . ',connectionType=' . $connectionType); + /* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DEFAULT-PEER-POOL: Adding peer ' . $peerAddress . ':' . $peerPort . ',socketResource=' . $socketInstance->getSocketResource() . ',connectionType=' . $connectionType); // Construct the array $socketArray = array( @@ -228,7 +228,7 @@ class DefaultPeerPool extends BasePool implements PoolablePeer { */ public function getSocketFromPackageData (array $packageData, $connectionType = NULL) { // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('DEFAULT-PEER-POOL:packageData()=%d,connectionType[%s]=%s - CALLED!', count($packageData), gettype($connectionType), $connectionType)); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('DEFAULT-PEER-POOL:packageData()=%d,connectionType[%s]=%s - CALLED!', count($packageData), gettype($connectionType), $connectionType)); // Default is no socket $socketInstance = NULL; @@ -240,7 +240,7 @@ class DefaultPeerPool extends BasePool implements PoolablePeer { $unlInstance = $handlerInstance->getUniversalNodeLocatorInstance(); // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DEFAULT-PEER-POOL: Checking ' . count($this->getAllSockets()) . ' socket(s),unlInstance.unl=' . $unlInstance->generateUnl() . ' ...'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DEFAULT-PEER-POOL: Checking ' . count($this->getAllSockets()) . ' socket(s),unlInstance.unl=' . $unlInstance->generateUnl() . ' ...'); // Default is all sockets $sockets = $this->getAllSockets(); @@ -248,7 +248,7 @@ class DefaultPeerPool extends BasePool implements PoolablePeer { // Get all sockets and check them, skip the server socket foreach ($sockets as $socketArray) { // Debugging: - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('DEFAULT-PEER-POOL: socketArray(%d)=%s', count($socketArray), implode(',', $socketArray))); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('DEFAULT-PEER-POOL: socketArray(%d)=%s', count($socketArray), implode(',', $socketArray))); //* DEBUG-DIE: */ die(__METHOD__.':connectionType='.$connectionType.',socketArray='.print_r($socketArray, TRUE)); // Is connection type set? @@ -263,12 +263,12 @@ 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]->getSocketResource(), $socketArray[Poolable::SOCKET_ARRAY_CONN_TYPE], $connectionType)); continue; } // Debug message - /* 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]->getSocketResource(), $socketArray[Poolable::SOCKET_ARRAY_INSTANCE]->getSocketProtocol(), Poolable::SOCKET_ARRAY_CONN_TYPE, $socketArray[Poolable::SOCKET_ARRAY_CONN_TYPE])); // Init peer address/port $peerAddress = '0.0.0.0'; @@ -281,7 +281,7 @@ class DefaultPeerPool extends BasePool implements PoolablePeer { } // END - if // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('DEFAULT-PEER-POOL: peerAddress=%s,peerPort=%d,unlInstance.addressPart=%s', $peerAddress, $peerPort, $unlInstance->getAddressPart())); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('DEFAULT-PEER-POOL: peerAddress=%s,peerPort=%d,unlInstance.addressPart=%s', $peerAddress, $peerPort, $unlInstance->getAddressPart())); // If the "peer" IP and recipient is same, use it if ($peerAddress == $unlInstance->getAddressPart()) { @@ -289,13 +289,13 @@ 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]->getSocketResource(), $socketArray[Poolable::SOCKET_ARRAY_CONN_TYPE])); break; } // END - if } // END - foreach // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DEFAULT-PEER-POOL: socketInstance[]=' . gettype($socketInstance) . ' - EXIT!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('DEFAULT-PEER-POOL: socketInstance[]=' . gettype($socketInstance) . ' - EXIT!'); // Return the determined socket instance return $socketInstance; diff --git a/application/hub/classes/registry/socket/class_SocketRegistry.php b/application/hub/classes/registry/socket/class_SocketRegistry.php index 4657192dd..90729f5ed 100644 --- a/application/hub/classes/registry/socket/class_SocketRegistry.php +++ b/application/hub/classes/registry/socket/class_SocketRegistry.php @@ -85,14 +85,14 @@ class SocketRegistry extends BaseRegistry implements Register, RegisterableSocke */ private function getSubRegistryKey (ShareableInfo $infoInstance) { // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-REGISTRY: infoInstance=' . $infoInstance->__toString() . ' - CALLED!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-REGISTRY: infoInstance=' . $infoInstance->__toString() . ' - CALLED!'); // Get address and port $address = $infoInstance->getAddress(); $port = $infoInstance->getPort(); // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-REGISTRY: address=' . $address . ',port=' . $port); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-REGISTRY: address=' . $address . ',port=' . $port); // Get connection type and port number and add both together $key = sprintf('%s:%s:%s:%s', @@ -103,7 +103,7 @@ class SocketRegistry extends BaseRegistry implements Register, RegisterableSocke ); // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-REGISTRY: key=' . $key . ' - EXIT!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-REGISTRY: key=' . $key . ' - EXIT!'); // Return resulting key return $key; @@ -117,13 +117,13 @@ class SocketRegistry extends BaseRegistry implements Register, RegisterableSocke */ private function getRegistryKeyFromInfo (ShareableInfo $infoInstance) { // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-REGISTRY: this=' . $this->__toString() . ',infoInstance=' . $infoInstance->__toString() . ' - CALLED!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-REGISTRY: this=' . $this->__toString() . ',infoInstance=' . $infoInstance->__toString() . ' - CALLED!'); // Get the key $key = $infoInstance->getProtocolName(); // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-REGISTRY: key=' . $key . ' - EXIT!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-REGISTRY: key=' . $key . ' - EXIT!'); // Return resulting key return $key; @@ -137,7 +137,7 @@ class SocketRegistry extends BaseRegistry implements Register, RegisterableSocke */ private function isInfoRegistered (ShareableInfo $infoInstance) { // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-REGISTRY: protocolName=' . $infoInstance->getProtocolName() . ' - CALLED!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-REGISTRY: protocolName=' . $infoInstance->getProtocolName() . ' - CALLED!'); // Get the key $key = $this->getRegistryKeyFromInfo($infoInstance); @@ -146,7 +146,7 @@ class SocketRegistry extends BaseRegistry implements Register, RegisterableSocke $isRegistered = $this->instanceExists($key); // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-REGISTRY: protocolName=' . $infoInstance->getProtocolName() . ',isRegistered=' . intval($isRegistered) . ' - EXIT!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-REGISTRY: protocolName=' . $infoInstance->getProtocolName() . ',isRegistered=' . intval($isRegistered) . ' - EXIT!'); // Return result return $isRegistered; @@ -162,7 +162,7 @@ class SocketRegistry extends BaseRegistry implements Register, RegisterableSocke */ public function isSocketRegistered (ShareableInfo $infoInstance, StorableSocket $socketInstance) { // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-REGISTRY: protocolName=' . $infoInstance->getProtocolName() . ',socketResource[' . gettype($socketInstance->getSocketResource()) . ']=' . $socketInstance->getSocketResource() . ' - CALLED!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-REGISTRY: protocolName=' . $infoInstance->getProtocolName() . ',socketResource[' . gettype($socketInstance->getSocketResource()) . ']=' . $socketInstance->getSocketResource() . ' - CALLED!'); // Default is not registered $isRegistered = FALSE; @@ -173,7 +173,7 @@ class SocketRegistry extends BaseRegistry implements Register, RegisterableSocke $key = $this->getRegistryKeyFromInfo($infoInstance); // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-REGISTRY: this=' . $this->__toString() . ',protocolName=' . $infoInstance->getProtocolName() . ',socketResource[' . gettype($socketInstance->getSocketResource()) . ']=' . $socketInstance->getSocketResource() . ',key=' . $key . ' - Trying to get instance ...'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-REGISTRY: this=' . $this->__toString() . ',protocolName=' . $infoInstance->getProtocolName() . ',socketResource[' . gettype($socketInstance->getSocketResource()) . ']=' . $socketInstance->getSocketResource() . ',key=' . $key . ' - Trying to get instance ...'); // Get the registry $registryInstance = $this->getInstance($key); @@ -182,12 +182,12 @@ class SocketRegistry extends BaseRegistry implements Register, RegisterableSocke $socketKey = $this->getSubRegistryKey($infoInstance); // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-REGISTRY: this=' . $this->__toString() . ',protocolName=' . $infoInstance->getProtocolName() . ',socketResource[' . gettype($socketInstance->getSocketResource()) . ']=' . $socketInstance->getSocketResource() . ',key=' . $key . ',socketKey=' . $socketKey . ' - Checking existence ...'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-REGISTRY: this=' . $this->__toString() . ',protocolName=' . $infoInstance->getProtocolName() . ',socketResource[' . gettype($socketInstance->getSocketResource()) . ']=' . $socketInstance->getSocketResource() . ',key=' . $key . ',socketKey=' . $socketKey . ' - Checking existence ...'); // Is it there? if ($registryInstance->instanceExists($socketKey)) { // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-REGISTRY: Found instance for socketKey=' . $socketKey . ':' . $registryInstance->getInstance($socketKey)); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-REGISTRY: Found instance for socketKey=' . $socketKey . ':' . $registryInstance->getInstance($socketKey)); // Get the instance $registeredInstance = $registryInstance->getInstance($socketKey); @@ -196,12 +196,12 @@ class SocketRegistry extends BaseRegistry implements Register, RegisterableSocke $isRegistered = (($registeredInstance instanceof StorableSocket) && ($registeredInstance->equals($socketInstance))); // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-REGISTRY: Final result: isRegistered(' . $socketInstance->getSocketResource() . ')=' . intval($isRegistered)); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-REGISTRY: Final result: isRegistered(' . $socketInstance->getSocketResource() . ')=' . intval($isRegistered)); } // END - if } // END - if // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-REGISTRY: protocolName=' . $infoInstance->getProtocolName() . ',socketResource[' . gettype($socketInstance->getSocketResource()) . ']=' . $socketInstance->getSocketResource() . ',isRegistered=' . intval($isRegistered) . ' - EXIT!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-REGISTRY: protocolName=' . $infoInstance->getProtocolName() . ',socketResource[' . gettype($socketInstance->getSocketResource()) . ']=' . $socketInstance->getSocketResource() . ',isRegistered=' . intval($isRegistered) . ' - EXIT!'); // Return the result return $isRegistered; @@ -218,7 +218,7 @@ class SocketRegistry extends BaseRegistry implements Register, RegisterableSocke */ public function registerSocketInstance (ShareableInfo $infoInstance, StorableSocket $socketInstance, array $packageData = array()) { // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-REGISTRY: protocolName=' . $infoInstance->getProtocolName() . ',socketResource[' . gettype($socketInstance->getSocketResource()) . ']=' . $socketInstance->getSocketResource() . ' - CALLED!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-REGISTRY: protocolName=' . $infoInstance->getProtocolName() . ',socketResource[' . gettype($socketInstance->getSocketResource()) . ']=' . $socketInstance->getSocketResource() . ' - CALLED!'); // Is the socket already registered? if ($this->isSocketRegistered($infoInstance, $socketInstance)) { @@ -258,7 +258,7 @@ class SocketRegistry extends BaseRegistry implements Register, RegisterableSocke */ public function getRegisteredSocketResource (Listenable $listenerInstance) { // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-REGISTRY:listener=' . $listenerInstance->getProtocolName() . ' - CALLED!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-REGISTRY:listener=' . $listenerInstance->getProtocolName() . ' - CALLED!'); // The socket must be registered before we can return it if (!$this->isInfoRegistered($listenerInstance)) { @@ -279,7 +279,7 @@ class SocketRegistry extends BaseRegistry implements Register, RegisterableSocke $socketInstance = $registryInstance->getInstance($socketKey); // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-REGISTRY:listener=' . $listenerInstance->getProtocolName() . ',socketResource[]=' . gettype($socketInstance) . ' - EXIT!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-REGISTRY: listener=' . $listenerInstance->getProtocolName() . ',socketInstance[]=' . gettype($socketInstance) . ' - EXIT!'); // Return the resource return $socketInstance; @@ -299,12 +299,12 @@ class SocketRegistry extends BaseRegistry implements Register, RegisterableSocke // Get all keys and check them foreach ($this->getInstanceRegistry() as $key => $registryInstance) { // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-REGISTRY: key=' . $key . ',registryInstance=' . $registryInstance->__toString()); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-REGISTRY: key=' . $key . ',registryInstance=' . $registryInstance->__toString()); // This is always a SubRegistry instance foreach ($registryInstance->getInstanceRegistry() as $subKey => $socketInstance) { // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-REGISTRY: key=' . $key . ',subKey=' . $subKey . ',socketInstance=' . $socketInstance->__toString()); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-REGISTRY: key=' . $key . ',subKey=' . $subKey . ',socketInstance=' . $socketInstance->__toString()); // Is this a StorableSocket instance and is the address the same? if (($socketInstance instanceof StorableSocket) && ($socketInstance->ifAddressMatches($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT]))) { @@ -312,14 +312,14 @@ class SocketRegistry extends BaseRegistry implements Register, RegisterableSocke //* DEBUG-DIE: */ die(__METHOD__ . ': socketInstance=' . print_r($socketInstance, TRUE)); // Trace message - /* NOSY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-REGISTRY: Calling socketInstance->getListenerInstance() ...'); + //* NOSY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-REGISTRY: Calling socketInstance->getListenerInstance() ...'); // Get listener and helper instances $listenerInstance = $socketInstance->getListenerInstance(); $helperInstance = $socketInstance->getHelperInstance(); // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-REGISTRY: key=' . $key . ',subKey=' . $subKey . ',listenerInstance[]=' . gettype($listenerInstance) . ',helperInstance[]=' . gettype($helperInstance)); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-REGISTRY: key=' . $key . ',subKey=' . $subKey . ',listenerInstance[]=' . gettype($listenerInstance) . ',helperInstance[]=' . gettype($helperInstance)); // Is a listener or helper set? if ($listenerInstance instanceof Listenable) { @@ -340,7 +340,7 @@ class SocketRegistry extends BaseRegistry implements Register, RegisterableSocke } // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-REGISTRY: key=' . $key . ',subKey=' . $subKey . ',infoInstance[' . gettype($infoInstance) . ']=' . $infoInstance->__toString() . ' with protocol ' . $infoInstance->getProtocolName() . ' - FOUND!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-REGISTRY: key=' . $key . ',subKey=' . $subKey . ',infoInstance[' . gettype($infoInstance) . ']=' . $infoInstance->__toString() . ' with protocol ' . $infoInstance->getProtocolName() . ' - FOUND!'); break; } // END - if } // END - foreach @@ -352,6 +352,9 @@ class SocketRegistry extends BaseRegistry implements Register, RegisterableSocke } // END - if } // END - foreach + // Debug message + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SOCKET-REGISTRY: infoInstance[]=' . gettype($infoInstance) . ' - EXIT!'); + // Return the info instance return $infoInstance; } 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 4eccc7ae5..5ca6481df 100644 --- a/application/hub/classes/streams/raw_data/output/class_RawDataOutputStream.php +++ b/application/hub/classes/streams/raw_data/output/class_RawDataOutputStream.php @@ -68,9 +68,13 @@ class RawDataOutputStream extends BaseStream implements OutputStream { * [[S]] - Start marker * [[E]] - End marker */ - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('RAW-OUTPUT-STREAM: data()=' . strlen($data) . ' - BEFORE!'); - $data = BaseRawDataHandler::STREAM_START_MARKER . base64_encode($data) . BaseRawDataHandler::STREAM_END_MARKER; - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('RAW-OUTPUT-STREAM: data(' . strlen($data) . ')=' . $data); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('RAW-OUTPUT-STREAM: data()=' . strlen($data) . ' - BEFORE!'); + $data = sprintf('%s%s%s', + BaseRawDataHandler::STREAM_START_MARKER, + base64_encode($data), + BaseRawDataHandler::STREAM_END_MARKER + ); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('RAW-OUTPUT-STREAM: data(' . strlen($data) . ')=' . $data); // Return it return $data; diff --git a/application/hub/classes/tasks/network/class_NetworkPackageReaderTask.php b/application/hub/classes/tasks/network/class_NetworkPackageReaderTask.php index 09b1a4895..f965bad16 100644 --- a/application/hub/classes/tasks/network/class_NetworkPackageReaderTask.php +++ b/application/hub/classes/tasks/network/class_NetworkPackageReaderTask.php @@ -66,13 +66,13 @@ class NetworkPackageReaderTask extends BaseTask implements Taskable, Visitable { */ public function accept (Visitor $visitorInstance) { // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-READER-TASK: visitorInstance=%s - CALLED!', $visitorInstance->__toString())); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-READER-TASK: visitorInstance=%s - CALLED!', $visitorInstance->__toString())); // Visit this task $visitorInstance->visitTask($this); // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-READER-TASK: EXIT!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-READER-TASK: EXIT!'); } /** @@ -82,18 +82,18 @@ class NetworkPackageReaderTask extends BaseTask implements Taskable, Visitable { */ public function executeTask () { // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-READER-TASK: CALLED!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-READER-TASK: CALLED!'); // Get package instance $packageInstance = NetworkPackageFactory::createNetworkPackageInstance(); // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-READER-TASK: packageInstance=%s', $packageInstance->__toString())); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-READER-TASK: packageInstance=%s', $packageInstance->__toString())); // Do we have something to handle? if ($packageInstance->isProcessedMessagePending()) { // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-READER-TASK: Calling packageInstance->handleProcessedMessage() ...'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-READER-TASK: Calling packageInstance->handleProcessedMessage() ...'); /* * A previously proccessed message is waiting for being @@ -103,7 +103,7 @@ class NetworkPackageReaderTask extends BaseTask implements Taskable, Visitable { $packageInstance->handleProcessedMessage(); } elseif ($packageInstance->isNewMessageArrived()) { // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-READER-TASK: Calling packageInstance->handleNewlyArrivedMessage() ...'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-READER-TASK: Calling packageInstance->handleNewlyArrivedMessage() ...'); /* * A fully "decoded" message has been received and added for being @@ -115,7 +115,7 @@ class NetworkPackageReaderTask extends BaseTask implements Taskable, Visitable { $packageInstance->handleNewlyArrivedMessage(); } elseif ($packageInstance->isIncomingRawDataHandled()) { // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-READER-TASK: Calling packageInstance->assembleDecodedDataToPackage() ...'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-READER-TASK: Calling packageInstance->assembleDecodedDataToPackage() ...'); /* * Incoming decoded data has been handled (see below) so it needs to @@ -125,7 +125,7 @@ class NetworkPackageReaderTask extends BaseTask implements Taskable, Visitable { $packageInstance->assembleDecodedDataToPackage(); } elseif ($packageInstance->ifMultipleMessagesPending()) { // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-READER-TASK: Calling packageInstance->handleMultipleMessages() ...'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-READER-TASK: Calling packageInstance->handleMultipleMessages() ...'); /* * Some raw data contained multiple messages which where now splitted. @@ -133,20 +133,20 @@ class NetworkPackageReaderTask extends BaseTask implements Taskable, Visitable { $packageInstance->handleMultipleMessages(); } elseif ($packageInstance->isNewRawDataPending()) { // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-READER-TASK: Calling packageInstance->handleIncomingDecodedData() ...'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-READER-TASK: Calling packageInstance->handleIncomingDecodedData() ...'); // Raw, decoded data has been received $packageInstance->handleIncomingDecodedData(); } elseif ($packageInstance->ifAssemblerHasPendingDataLeft()) { // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-READER-TASK: Calling packageInstance->handleAssemblerPendingData() ...'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-READER-TASK: Calling packageInstance->handleAssemblerPendingData() ...'); // Handle any pending data from the package assembler $packageInstance->handleAssemblerPendingData(); } // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-READER-TASK: EXIT!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-READER-TASK: EXIT!'); } /** diff --git a/application/hub/classes/tasks/network/class_NetworkPackageWriterTask.php b/application/hub/classes/tasks/network/class_NetworkPackageWriterTask.php index d9609e6d2..d177f322c 100644 --- a/application/hub/classes/tasks/network/class_NetworkPackageWriterTask.php +++ b/application/hub/classes/tasks/network/class_NetworkPackageWriterTask.php @@ -66,13 +66,13 @@ class NetworkPackageWriterTask extends BaseTask implements Taskable, Visitable { */ public function accept (Visitor $visitorInstance) { // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-WRITER-TASK: visitorInstance=%s - CALLED!', $visitorInstance->__toString())); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('NETWORK-PACKAGE-WRITER-TASK: visitorInstance=%s - CALLED!', $visitorInstance->__toString())); // Visit this task $visitorInstance->visitTask($this); // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-WRITER-TASK: EXIT!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-WRITER-TASK: EXIT!'); } /** @@ -82,7 +82,7 @@ class NetworkPackageWriterTask extends BaseTask implements Taskable, Visitable { */ public function executeTask () { // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-WRITER-TASK: CALLED!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-WRITER-TASK: CALLED!'); // "Cache" package instance $packageInstance = NetworkPackageFactory::createNetworkPackageInstance(); @@ -90,32 +90,32 @@ class NetworkPackageWriterTask extends BaseTask implements Taskable, Visitable { // Do we have something to deliver? if ($packageInstance->isEncodedDataPending()) { // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-WRITER-TASK: Calling packageInstance->sendEncodedData() ...'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-WRITER-TASK: Calling packageInstance->sendEncodedData() ...'); // Sent encoded (raw) data $packageInstance->sendEncodedData(); } elseif ($packageInstance->isPackageWaitingForDelivery()) { // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-WRITER-TASK: Calling packageInstance->sendWaitingPackage() ...'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-WRITER-TASK: Calling packageInstance->sendWaitingPackage() ...'); // Sent it finally out $packageInstance->sendWaitingPackage(); } elseif ($packageInstance->isPackageDeclared()) { // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-WRITER-TASK: Calling packageInstance->processDeclaredPackage() ...'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-WRITER-TASK: Calling packageInstance->processDeclaredPackage() ...'); // Prepare package for delivery $packageInstance->processDeclaredPackage(); } elseif ($packageInstance->isPackageEnqueued()) { // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-WRITER-TASK: Calling packageInstance->declareEnqueuedPackage() ...'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-WRITER-TASK: Calling packageInstance->declareEnqueuedPackage() ...'); // Okay, then deliver (better discover its recipients) this package $packageInstance->declareEnqueuedPackage(); } // Trace message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-WRITER-TASK: EXIT!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NETWORK-PACKAGE-WRITER-TASK: EXIT!'); } /** diff --git a/application/hub/classes/tasks/node/listener/class_NodeSocketListenerTask.php b/application/hub/classes/tasks/node/listener/class_NodeSocketListenerTask.php index b5eb564c0..a852ca3b9 100644 --- a/application/hub/classes/tasks/node/listener/class_NodeSocketListenerTask.php +++ b/application/hub/classes/tasks/node/listener/class_NodeSocketListenerTask.php @@ -68,7 +68,7 @@ class NodeSocketListenerTask extends BaseTask implements Taskable, Visitable { $nodeInstance = NodeObjectFactory::createNodeInstance(); // Visit the pool listener task - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('LISTENER-TASK: Going to visit object ' . $nodeInstance->getListenerPoolInstance()->__toString() . ' ...'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('LISTENER-TASK: Going to visit object ' . $nodeInstance->getListenerPoolInstance()->__toString() . ' ...'); $nodeInstance->getListenerPoolInstance()->accept($visitorInstance); // Visit this task diff --git a/application/hub/classes/tools/class_HubTools.php b/application/hub/classes/tools/class_HubTools.php index ab791df49..57adbd25f 100644 --- a/application/hub/classes/tools/class_HubTools.php +++ b/application/hub/classes/tools/class_HubTools.php @@ -142,7 +142,7 @@ class HubTools extends BaseHubSystem { $nodeData = DhtObjectFactory::createDhtInstance('node')->findNodeLocalBySessionId($sessionId); // Make sure the node id is there - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('HUB-TOOLS: sessionId=' . $sessionId . ', nodeData[' . gettype($nodeData) . ']=' . print_r($nodeData, TRUE)); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('HUB-TOOLS: sessionId=' . $sessionId . ', nodeData[' . gettype($nodeData) . ']=' . print_r($nodeData, TRUE)); assert(isset($nodeData[NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_NODE_ID])); // Return it @@ -241,31 +241,31 @@ class HubTools extends BaseHubSystem { */ public static function determineOwnInternalAddress () { // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NODE: CALLED!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NODE: CALLED!'); // Is the internal_address config entry set? if (FrameworkConfiguration::getSelfInstance()->getConfigEntry('allow_publish_internal_address') == 'N') { // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NODE: Calling self::determineOwnExternalAddress() as allow_publish_internal_address=N is set ...'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NODE: Calling self::determineOwnExternalAddress() as allow_publish_internal_address=N is set ...'); // Not allowed to publish internal address, so use external $unl = self::determineOwnExternalAddress(); } elseif (FrameworkConfiguration::getSelfInstance()->getConfigEntry('internal_address') != '') { // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NODE: Getting config entry internal_address ...'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NODE: Getting config entry internal_address ...'); // Use it as internal address $unl = FrameworkConfiguration::getSelfInstance()->getConfigEntry('internal_address'); } else { // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NODE: Calling self::determineInternalUniversalNodeLocator() ...'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NODE: Calling self::determineInternalUniversalNodeLocator() ...'); // Determine own internal address $unl = self::determineInternalUniversalNodeLocator(); } // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NODE: unl=' . $unl . ' - EXIT!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NODE: unl=' . $unl . ' - EXIT!'); // Return it return $unl; @@ -278,7 +278,7 @@ class HubTools extends BaseHubSystem { */ public static function determineInternalUniversalNodeLocator () { // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NODE: CALLED!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NODE: CALLED!'); // Is there cache? (This shortens a lot calls) if (!isset($GLOBALS[__METHOD__])) { @@ -295,7 +295,7 @@ class HubTools extends BaseHubSystem { } // END - if // Return it - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NODE: unl=' . $GLOBALS[__METHOD__] . ' - EXIT!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NODE: unl=' . $GLOBALS[__METHOD__] . ' - EXIT!'); return $GLOBALS[__METHOD__]; } @@ -306,7 +306,7 @@ class HubTools extends BaseHubSystem { */ public static function determineExternalUniversalNodeLocator () { // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NODE: CALLED!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NODE: CALLED!'); // Is there cache? (This shortens a lot calls) if (!isset($GLOBALS[__METHOD__])) { @@ -323,7 +323,7 @@ class HubTools extends BaseHubSystem { } // END - if // Return it - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NODE: unl=' . $GLOBALS[__METHOD__] . ' - EXIT!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('NODE: unl=' . $GLOBALS[__METHOD__] . ' - EXIT!'); return $GLOBALS[__METHOD__]; } diff --git a/application/hub/classes/visitor/pool/monitor/class_RawDataPoolMonitorVisitor.php b/application/hub/classes/visitor/pool/monitor/class_RawDataPoolMonitorVisitor.php index 6f7e64d9c..7ec3db43d 100644 --- a/application/hub/classes/visitor/pool/monitor/class_RawDataPoolMonitorVisitor.php +++ b/application/hub/classes/visitor/pool/monitor/class_RawDataPoolMonitorVisitor.php @@ -72,7 +72,7 @@ class RawDataPoolMonitorVisitor extends BaseVisitor implements PoolVisitor, List */ public function visitPool (Poolable $poolInstance) { // A pool doesn't normally have any raw data waiting - /* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('RAWDATA-MONITOR-VISITOR: poolInstance=' . $poolInstance->__toString() . ' - CALLED!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('RAWDATA-MONITOR-VISITOR: poolInstance=' . $poolInstance->__toString() . ' - CALLED!'); } /** @@ -87,7 +87,7 @@ class RawDataPoolMonitorVisitor extends BaseVisitor implements PoolVisitor, List * traffic. This is why its method monitorIncomingRawData() is not * called. */ - /* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('RAWDATA-MONITOR-VISITOR: listenerInstance=' . $listenerInstance->__toString() . ' - CALLED!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('RAWDATA-MONITOR-VISITOR: listenerInstance=' . $listenerInstance->__toString() . ' - CALLED!'); } /** @@ -98,9 +98,9 @@ class RawDataPoolMonitorVisitor extends BaseVisitor implements PoolVisitor, List */ public function visitDecorator (BaseDecorator $decoratorInstance) { // Do monitor here - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('RAWDATA-MONITOR-VISITOR: Visiting decoratorInstance=' . $decoratorInstance->__toString() . ' - CALLED!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('RAWDATA-MONITOR-VISITOR: Visiting decoratorInstance=' . $decoratorInstance->__toString() . ' - CALLED!'); $decoratorInstance->monitorIncomingRawData(); - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('RAWDATA-MONITOR-VISITOR: Visiting decoratorInstance=' . $decoratorInstance->__toString() . ' - EXIT!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('RAWDATA-MONITOR-VISITOR: Visiting decoratorInstance=' . $decoratorInstance->__toString() . ' - EXIT!'); } } diff --git a/application/hub/classes/visitor/pool/shutdown/class_ShutdownListenerPoolVisitor.php b/application/hub/classes/visitor/pool/shutdown/class_ShutdownListenerPoolVisitor.php index cd1802a17..7fc8831c9 100644 --- a/application/hub/classes/visitor/pool/shutdown/class_ShutdownListenerPoolVisitor.php +++ b/application/hub/classes/visitor/pool/shutdown/class_ShutdownListenerPoolVisitor.php @@ -67,13 +67,13 @@ class ShutdownListenerPoolVisitor extends BaseVisitor implements PoolVisitor { */ public function visitPool (Poolable $poolInstance) { // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SHUTDOWN-LISTENER-POOL-VISITOR: Visit of ' . $poolInstance->__toString() . ' - CALLED!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SHUTDOWN-LISTENER-POOL-VISITOR: Visit of ' . $poolInstance->__toString() . ' - CALLED!'); // Pre-shutdown the pool $poolInstance->preShutdown(); // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SHUTDOWN-LISTENER-POOL-VISITOR: Visit of ' . $poolInstance->__toString() . ' - EXIT!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SHUTDOWN-LISTENER-POOL-VISITOR: Visit of ' . $poolInstance->__toString() . ' - EXIT!'); } /** @@ -84,13 +84,13 @@ class ShutdownListenerPoolVisitor extends BaseVisitor implements PoolVisitor { */ public function visitDecorator (Listenable $decoratorInstance) { // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SHUTDOWN-LISTENER-POOL-VISITOR: Visit of ' . $decoratorInstance->__toString() . ' - CALLED!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SHUTDOWN-LISTENER-POOL-VISITOR: Visit of ' . $decoratorInstance->__toString() . ' - CALLED!'); // Pre-shutdown the pool $decoratorInstance->doShutdown(); // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SHUTDOWN-LISTENER-POOL-VISITOR: Visit of ' . $decoratorInstance->__toString() . ' - EXIT!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SHUTDOWN-LISTENER-POOL-VISITOR: Visit of ' . $decoratorInstance->__toString() . ' - EXIT!'); } /** @@ -101,15 +101,13 @@ class ShutdownListenerPoolVisitor extends BaseVisitor implements PoolVisitor { */ public function visitListener (Listenable $listenerInstance) { // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SHUTDOWN-LISTENER-POOL-VISITOR: Visit of ' . $listenerInstance->__toString() . ' - CALLED!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SHUTDOWN-LISTENER-POOL-VISITOR: Visit of ' . $listenerInstance->__toString() . ' - CALLED!'); // Pre-shutdown the pool $listenerInstance->doShutdown(); // Debug message - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SHUTDOWN-LISTENER-POOL-VISITOR: Visit of ' . $listenerInstance->__toString() . ' - EXIT!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('SHUTDOWN-LISTENER-POOL-VISITOR: Visit of ' . $listenerInstance->__toString() . ' - EXIT!'); } -} -// -?> +} diff --git a/application/hub/classes/visitor/tasks/class_ActiveTaskVisitor.php b/application/hub/classes/visitor/tasks/class_ActiveTaskVisitor.php index 634c1ed83..976ccc109 100644 --- a/application/hub/classes/visitor/tasks/class_ActiveTaskVisitor.php +++ b/application/hub/classes/visitor/tasks/class_ActiveTaskVisitor.php @@ -72,9 +72,9 @@ class ActiveTaskVisitor extends BaseVisitor implements TaskVisitor, PoolVisitor, */ public function visitTask (Taskable $taskInstance) { // Execute the task from this visitor - /* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('ACTIVE-TASK-VISITOR: Visiting task ' . $taskInstance->__toString() . ' - CALLED!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('ACTIVE-TASK-VISITOR: Visiting task ' . $taskInstance->__toString() . ' - CALLED!'); $taskInstance->executeTask(); - /* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('ACTIVE-TASK-VISITOR: Visiting task ' . $taskInstance->__toString() . ' - EXIT!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('ACTIVE-TASK-VISITOR: Visiting task ' . $taskInstance->__toString() . ' - EXIT!'); } /** @@ -84,11 +84,11 @@ class ActiveTaskVisitor extends BaseVisitor implements TaskVisitor, PoolVisitor, * @return void */ public function visitPool (Poolable $poolInstance) { - /** - * We don't need to visit a pool as an active task because a pool can - * never become a task. Instead e.g. by a listener pool we should visit - * all listeners one by one + /* + * No need to visit a pool as an active task because a pool can never + * become a task. Instead visit all pool members one-by-one. */ + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('ACTIVE-TASK-VISITOR: poolInstance=%s - CALLED!', $poolInstance->__toString())); } /** @@ -99,9 +99,9 @@ class ActiveTaskVisitor extends BaseVisitor implements TaskVisitor, PoolVisitor, */ public function visitListener (Listenable $listenerInstance) { // Do "listen" here - /* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('ACTIVE-TASK-VISITOR: Visiting listenerInstance=' . $listenerInstance->__toString() . ' - CALLED!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('ACTIVE-TASK-VISITOR: Visiting listenerInstance=' . $listenerInstance->__toString() . ' - CALLED!'); $listenerInstance->doListen(); - /* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('ACTIVE-TASK-VISITOR: Visiting listenerInstance=' . $listenerInstance->__toString() . ' - EXIT!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('ACTIVE-TASK-VISITOR: Visiting listenerInstance=' . $listenerInstance->__toString() . ' - EXIT!'); } /** @@ -111,8 +111,11 @@ class ActiveTaskVisitor extends BaseVisitor implements TaskVisitor, PoolVisitor, * @return void */ public function visitDecorator (BaseDecorator $decoratorInstance) { - // A decorator itself can never become an active task so this method - // remains empty. + /* + * A decorator itself can never become an active task so this method + * remains empty. + */ + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('ACTIVE-TASK-VISITOR: decoratorInstance=%s - CALLED!', $decoratorInstance->__toString())); } } diff --git a/application/hub/interfaces/shareable/info/class_ShareableInfo.php b/application/hub/interfaces/shareable/info/class_ShareableInfo.php index 6aada607a..74cdc0a41 100644 --- a/application/hub/interfaces/shareable/info/class_ShareableInfo.php +++ b/application/hub/interfaces/shareable/info/class_ShareableInfo.php @@ -3,6 +3,7 @@ namespace Hub\Information; // Import application-specific stuff +use Hub\Container\Socket\StorableSocket; use Hub\Helper\Connection\ConnectionHelper; use Hub\Listener\Listenable; @@ -50,4 +51,12 @@ interface ShareableInfo extends HubInterface { */ function fillWithConnectionHelperInformation (ConnectionHelper $helperInstance); + /** + * Fills the information class with peer data from given socket instance + * + * @param $socketInstance An instance of a StorableSocket class + * @return void + */ + function fillWithSocketPeerInformation (StorableSocket $socketInstance); + } diff --git a/core b/core index fc0b718d5..e72033bed 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit fc0b718d5c258e187b226e2a088769e5d14fcc1f +Subproject commit e72033bed456c820815feeb2d25335245499448e -- 2.39.5