X-Git-Url: https://git.mxchange.org/?p=core.git;a=blobdiff_plain;f=inc%2Fclasses%2Fmain%2Fcontainer%2Fsocket%2Fclass_SocketContainer.php;h=656f81d12813d17cc6121e729bcd0bb7a608f099;hp=66900af5309622e903930f3def7bfa987af2ae7a;hb=3ca66c867ea6a3ea6b10a805df94c1e4938aece3;hpb=a6f1d3c871c6847c5b81fd1537647b297e1abcf8 diff --git a/inc/classes/main/container/socket/class_SocketContainer.php b/inc/classes/main/container/socket/class_SocketContainer.php index 66900af5..656f81d1 100644 --- a/inc/classes/main/container/socket/class_SocketContainer.php +++ b/inc/classes/main/container/socket/class_SocketContainer.php @@ -36,11 +36,11 @@ class SocketContainer extends BaseContainer implements Registerable { * Creates an instance of this Container class and prepares it for usage * * @param $socketResource A valid socket resource - * @param $listenerInstance A Listenable instance + * @param $infoInstance An instance of a ShareableInfo class * @param $packageData Raw package data * @return $containerInstance An instance of this Container class */ - public static final function createSocketContainer ($socketResource, Listenable $listenerInstance = NULL, array $packageData = array()) { + public static final function createSocketContainer ($socketResource, ShareableInfo $infoInstance = NULL, array $packageData = array()) { // Get a new instance $containerInstance = new SocketContainer(); @@ -51,15 +51,21 @@ class SocketContainer extends BaseContainer implements Registerable { // Debug message //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-CONTAINER[' . __METHOD__ . ':' . __LINE__ . ']:socketResource=' . $socketResource . ',packageData='.print_r($packageData, TRUE)); - // Set the resource ... - $containerInstance->setSocketResource($socketResource); + // Is the info instance set? + if ($infoInstance instanceof ShareableInfo) { + // Get listener from info class + $listenerInstance = $infoInstance->getListenerInstance(); - // Is a listener instance given? - if ($listenerInstance instanceof Listenable) { - // ..., listener instance ... - $containerInstance->setListenerInstance($listenerInstance); + // Is there a listener instance set? + if ($listenerInstance instanceof Listenable) { + // Set it here for later usage + $containerInstance->setListenerInstance($listenerInstance); + } // END - if } // END - if + // Set the resource ... + $containerInstance->setSocketResource($socketResource); + // ... and package data $containerInstance->setPackageData($packageData); @@ -70,19 +76,18 @@ class SocketContainer extends BaseContainer implements Registerable { /** * Checks whether the given Universal Node Locator matches with the one from package data * - * @param $unlInstance An instance of a LocateableNode class - * @return $matches Whether $address matches with the one from package data + * @param $unl A Universal Node Locator + * @return $matches Whether $address matches with the one from package data */ - public final function ifAddressMatches (LocateableNode $unlInstance) { + public final function ifAddressMatches ($unl) { // Get current package data $packageData = $this->getPackageData(); // Debug message - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-CONTAINER: unlInstance=' . print_r($unlInstance, TRUE) . ',packageData=' . print_r($packageData, TRUE)); + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('SOCKET-CONTAINER: unl=' . $unl . ',packageData=' . print_r($packageData, TRUE)); // So, does both match? - die(__METHOD__ . ': Unfinished.' . PHP_EOL); - $matches = ((isset($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT])) && ($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT] === $unlInstance)); + $matches = ((isset($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT])) && ($packageData[NetworkPackage::PACKAGE_DATA_RECIPIENT] === $unl)); // Return result return $matches; @@ -91,8 +96,8 @@ class SocketContainer extends BaseContainer implements Registerable { /** * Checks whether the given socket matches with stored * - * @param $unlInstance An instance of a LocateableNode class - * @return $matches Whether given socket matches + * @param $socketResource A valid socket resource + * @return $matches Whether given socket matches */ public final function ifSocketResourceMatches ($socketResource) { // Debug message