From: Roland Häder Date: Thu, 3 Dec 2020 08:38:00 +0000 (+0100) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=9b86f70d2b26908bf338b671376c482e837ffdfa;p=hub.git Continued: - $socketInstance is required in BaseConnectionHelper, so moved the trait loading there - also fixed NULL reference as it might not be set at all times Signed-off-by: Roland Häder --- diff --git a/application/hub/classes/helper/connection/class_BaseConnectionHelper.php b/application/hub/classes/helper/connection/class_BaseConnectionHelper.php index e3ed55c08..ec409c796 100644 --- a/application/hub/classes/helper/connection/class_BaseConnectionHelper.php +++ b/application/hub/classes/helper/connection/class_BaseConnectionHelper.php @@ -3,6 +3,7 @@ namespace Org\Shipsimu\Hub\Helper\Connection; // Import application-specific stuff +use Org\Shipsimu\Hub\Container\Socket\StorableSocket; use Org\Shipsimu\Hub\Factory\Fragmenter\FragmenterFactory; use Org\Shipsimu\Hub\Factory\Handler\Network\NetworkPackageHandlerFactory; use Org\Shipsimu\Hub\Factory\Network\NetworkPackageFactory; @@ -12,6 +13,7 @@ use Org\Shipsimu\Hub\Helper\BaseHubSystemHelper; use Org\Shipsimu\Hub\Network\Delivery\Deliverable; use Org\Shipsimu\Hub\Network\Package\DeliverablePackage; use Org\Shipsimu\Hub\Network\Package\Delivery\Fragment\Fragmentable; +use Org\Shipsimu\Hub\Traits\Container\Socket\StorableSocketTrait; use Org\Shipsimu\Hub\Traits\Fragmenter\FragmentableTrait; // Import framework stuff @@ -52,6 +54,7 @@ abstract class BaseConnectionHelper extends BaseHubSystemHelper implements Visit use FragmentableTrait; use OutputStreamTrait; use StateableTrait; + use StorableSocketTrait; // Exception codes const EXCEPTION_UNSUPPORTED_ERROR_HANDLER = 0x9100; @@ -188,10 +191,18 @@ abstract class BaseConnectionHelper extends BaseHubSystemHelper implements Visit * @return $class Expanded class name */ private function getConnectionClassNameFromSocket () { - // Get recipient address/port + // Default is none /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-CONNECTION-HELPER: CALLED!'); - $recipientAddress = $this->getSocketInstance()->getSocketRecipientAddress(); - $recipientPort = $this->getSocketInstance()->getSocketRecipientPort(); + $recipientAddress = '0.0.0.0'; + $recipientPort = 0; + + // Is a socket instance set? + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-CONNECTION-HELPER: socketInstance[]=%s', gettype($this->getSocketInstance()))); + if ($this->getSocketInstance() instanceof StorableSocket) { + // Get recipient address/port + $recipientAddress = $this->getSocketInstance()->getSocketRecipientAddress(); + $recipientPort = $this->getSocketInstance()->getSocketRecipientPort(); + } // Construct it /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-CONNECTION-HELPER: recipientAddress=%s,recipientPort=%d', $recipientAddress, $recipientPort)); diff --git a/application/hub/classes/helper/connection/ipv4/class_BaseIpV4ConnectionHelper.php b/application/hub/classes/helper/connection/ipv4/class_BaseIpV4ConnectionHelper.php index e26b4eb87..51182d0ae 100644 --- a/application/hub/classes/helper/connection/ipv4/class_BaseIpV4ConnectionHelper.php +++ b/application/hub/classes/helper/connection/ipv4/class_BaseIpV4ConnectionHelper.php @@ -6,7 +6,6 @@ namespace Org\Shipsimu\Hub\Helper\Connection\Network\IpV4; use Org\Shipsimu\Hub\Factory\State\Peer\PeerStateFactory; use Org\Shipsimu\Hub\Helper\Connection\BaseConnectionHelper; use Org\Shipsimu\Hub\Locator\Node\LocateableNode; -use Org\Shipsimu\Hub\Traits\Container\Socket\StorableSocketTrait; // Import framework stuff use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap; @@ -41,7 +40,6 @@ use \BadMethodCallException; abstract class BaseIpV4ConnectionHelper extends BaseConnectionHelper { // Load traits use HandleableTrait; - use StorableSocketTrait; /** * Name of used protocol