* Checks whether given socket resource is registered. If $socketResource is
* FALSE only the instance will be checked.
*
- * @param $listenerInstance An instance of a Listenable class
+ * @param $infoInstance An instance of a ShareableInfo class
* @param $socketResource A valid socket resource
* @return $isRegistered Whether the given socket resource is registered
*/
- function isSocketRegistered (Listenable $listenerInstance, $socketResource);
+ function isSocketRegistered (ShareableInfo $infoInstance, $socketResource);
/**
* Registeres given socket for listener or throws an exception if it is already registered
*
- * @param $listenerlInstance An instance of a Listenable class
+ * @param $infoInstance An instance of a ShareableInfo class
* @param $socketResource A valid socket resource
* @return void
* @throws SocketAlreadyRegisteredException If the given socket is already registered
*/
- function registerSocket (Listenable $listenerInstance, $socketResource);
+ function registerSocket (ShareableInfo $infoInstance, $socketResource);
/**
* Getter for given listener's socket resource
* 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();
// 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);
/**
* 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;
/**
* 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