X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=application%2Fhub%2Fmain%2Fpools%2Fpeer%2Fclass_DefaultPeerPool.php;h=90e76fde8207dbfc8aa8677ea609af4b916feca7;hb=73aff29b9bc78031853b0b8c0fe0a8e04f66ac29;hp=c0bfd31861b8d0ee79324dd0627acd83edf22e38;hpb=0553b20da2815d73580a07212106ee3be7aa3407;p=hub.git diff --git a/application/hub/main/pools/peer/class_DefaultPeerPool.php b/application/hub/main/pools/peer/class_DefaultPeerPool.php index c0bfd3186..90e76fde8 100644 --- a/application/hub/main/pools/peer/class_DefaultPeerPool.php +++ b/application/hub/main/pools/peer/class_DefaultPeerPool.php @@ -4,7 +4,7 @@ * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2014 Hub Developer Team + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team * @license GNU GPL 3.0 or any newer version * @link http://www.shipsimu.org * @@ -94,7 +94,7 @@ class DefaultPeerPool extends BasePool implements PoolablePeer { */ public function addPeer ($socketResource, $connectionType) { // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DEFAULT-PEER-POOL[' . __METHOD__ . ':' . __LINE__ . ']: socketResource[' . gettype($socketResource) . ']=' . $socketResource . ',connectionType=' . $connectionType . ' - ENTERED!'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DEFAULT-PEER-POOL[' . __METHOD__ . ':' . __LINE__ . ']: socketResource[' . gettype($socketResource) . ']=' . $socketResource . ',connectionType=' . $connectionType . ' - CALLED!'); // Validate the socket $this->validateSocket($socketResource); @@ -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->getUniversalNodeLocatorDataArray(); // 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];