]> git.mxchange.org Git - hub.git/blobdiff - application/hub/main/pools/peer/class_DefaultPeerPool.php
Continued rewrite:
[hub.git] / application / hub / main / pools / peer / class_DefaultPeerPool.php
index c0bfd31861b8d0ee79324dd0627acd83edf22e38..1a87fc4a20cfa3d51d38578e727cb300674ca7e4 100644 (file)
@@ -220,15 +220,19 @@ class DefaultPeerPool extends BasePool implements PoolablePeer {
                // Default is no socket
                $socketResource = FALSE;
 
-               // Temporary resolve recipient field
-               die(__METHOD__ . ': UNFINISHED!' . PHP_EOL);
-               $unlData = explode(':', HubTools::resolveSessionId($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT]));
+               // Resolve recipient (UNL) into a handler instance
+               $handlerInstance = ProtocolHandlerFactory::createProtocolHandlerFromPackageData($packageData);
+
+               // Get UNL data
+               $unlData = $handlerInstance->getUniversalNodeLocatorData();
 
                // Make sure it is a valid Universal Node Locator array (3 elements)
-               assert(count($unlData) == 3);
+               assert(isset($unlData[UniversalNodeLocator::UNL_PART_PROTOCOL]));
+               assert(isset($unlData[UniversalNodeLocator::UNL_PART_ADDRESS]));
+               assert(isset($unlData[UniversalNodeLocator::UNL_PART_PORT]));
 
                // Debug message
-               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('POOL[' . __METHOD__ . ':' . __LINE__ . ']: Checking ' . count($this->getAllSockets()) . ' socket(s),unlData[0]=' . $unlData[0] . ',unlData[1]=' . $unlData[1] . ' ...');
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('POOL[' . __METHOD__ . ':' . __LINE__ . ']: Checking ' . count($this->getAllSockets()) . ' socket(s),unlData[' . UniversalNodeLocator::UNL_PART_ADDRESS . ']=' . $unlData[UniversalNodeLocator::UNL_PART_ADDRESS] . ',unlData[' . UniversalNodeLocator::UNL_PART_PORT . ']=' . $unlData[UniversalNodeLocator::UNL_PART_PORT] . ' ...');
 
                // Default is all sockets
                $sockets = $this->getAllSockets();
@@ -259,7 +263,7 @@ class DefaultPeerPool extends BasePool implements PoolablePeer {
 
                        // Get
                        // If the "peer" IP and recipient is same, use it
-                       if ($peerIp == $unlData[0]) {
+                       if ($peerIp == $unlData[UniversalNodeLocator::UNL_PART_ADDRESS]) {
                                // IPs match, so take the socket and quit this loop
                                $socketResource = $socketArray[self::SOCKET_ARRAY_RESOURCE];