* @return $listenerInstance An instance of a Listenable instance or null
*/
public function discoverListenerInstance ($protocolName, array $packageData) {
+ // Debug message
+ //* NOISY-DEBUG: */ $this->debugOutput('SOCKET-DISCOVERY: protocolName=' . $protocolName . ' - ENTERED!');
+
/*
* Get the listener pool instance, we need to lookup the matching
* listener->poolInstance chain there.
* pool.
*/
foreach ($poolInstance->getPoolEntriesInstance()->getArrayFromGroup($protocolName) as $listenerInstance) {
+ // Debug output
+ //* NOISY-DEBUG: */ $this->debugOutput('SOCKET-DISCOVERY: protocolName=' . $protocolName . ',listenerInstance=' . $listenerInstance->__toString());
+
// Does the listener want that package?
if ($listenerInstance->ifListenerAcceptsPackageData($packageData)) {
// This listener likes our package data, so abort here
+ //* NOISY-DEBUG: */ $this->debugOutput('SOCKET-DISCOVERY: Listener is accepting package data.');
break;
} // END - if
+
+ // Debug output
+ //* NOISY-DEBUG: */ $this->debugOutput('SOCKET-DISCOVERY: Listener is NOT accepting package data.');
} // END - foreach
// Return it
* @param $packageData Raw package data array
* @return $socketResource A valid socket resource or FALSE if an error occured
* @throws NoListGroupException If the procol group is not found in peer list
+ * @throws NullPointerException If listenerInstance is NULL
*/
public function discoverSocket (array $packageData) {
// Determine protocol name
// If there is no listener who wants to have that package, we simply drop it here
if (is_null($listenerInstance)) {
- // @TODO We may need some logging here
// Abort with no resource
- return false;
+ throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
} // END - if
/*
*/
$socketResource = $listenerInstance->getPoolInstance()->getSocketFromPackageData($packageData);
+ // Debug message
+ //* NOISY-DEBUG: */ $this->debugOutput('socketResource=' . $socketResource . ',packageData='.print_r($packageData,true));
+
// Is it false, the recipient isn't known to us and we have no connection to it
if (($socketResource === false) || (!is_resource($socketResource)) || (socket_last_error($socketResource) > 0)) {
// Try to create a new socket resource
}
// And return it
+ $this->debugOutput('SOCKET-DISCOVERY: socketResource=' . $socketResource . ',packageData=' . print_r($packageData, true));
return $socketResource;
}
}
}
/**
- * Creates a socket resource ("connection") for given recipient in package data
+ * Creates a half-connected socket resource ("connection") for given
+ * recipient in package data. After you called this method you still need to
+ * connect to the other node.
*
* @param $packageData Raw package data
* @return $socketResource Socket resource
}
/**
- * Creates a socket resource ("connection") for given recipient in package data
+ * Creates a half-connected socket resource ("connection") for given
+ * recipient in package data. After you called this method you still need to
+ * connect to the other node.
*
* @param $packageData Raw package data
* @return $socketResource Socket resource
// Get an iterator
$iteratorInstance = $this->listGroups[$groupName]->getIterator();
+ // Rewind the iterator for this round
+ $iteratorInstance->rewind();
+
// Go through all entries
while ($iteratorInstance->valid()) {
// Get key
// ... and the final entry which is the stored instance
$entry = $this->getEntry($entryIndex);
+ // Debug message
+ //* NOISY-DEBUG: */ $this->debugOutput('LIST: Adding entry ' . $entry . ' ...');
+
// Add it to the list
$entries[$iteratorInstance->current()] = $entry;
// Now get an iterator
$iteratorInstance = $discoveryInstance->getIterator();
+ // Rewind back to the beginning
+ $iteratorInstance->rewind();
+
// ... and begin iteration
while ($iteratorInstance->valid()) {
// Get current entry
$currentRecipient = $iteratorInstance->current();
- // Debug message
- $this->debugOutput('PACKAGE: Package declared for recipient ' . $currentRecipient);
-
// Set the recipient
$packageData[self::PACKAGE_DATA_RECIPIENT] = $currentRecipient;
// And enqueue it to the writer class
$this->getStackerInstance()->pushNamed(self::STACKER_NAME_DECLARED, $packageData);
+ // Debug message
+ $this->debugOutput('PACKAGE: Package declared for recipient ' . $currentRecipient);
+
// Skip to next entry
$iteratorInstance->next();
} // END - while
$socketResource = $discoveryInstance->discoverSocket($packageData);
// Debug message
- //* NOISY-DEBUG: */ $this->debugOutput('NETWORK-PACKAGE: Reached line ' . __LINE__ . ' after discoverSocket() has been called.');
+ //* NOISY-DEBUG: */ $this->debugOutput('PACKAGE: Reached line ' . __LINE__ . ' after discoverSocket() has been called.');
// We have to put this socket in our registry, so get an instance
$registryInstance = SocketRegistry::createSocketRegistry();
$helperInstance = Registry::getRegistry()->getInstance('connection');
// Debug message
- //* NOISY-DEBUG: */ $this->debugOutput('NETWORK-PACKAGE: Reached line ' . __LINE__ . ' before isSocketRegistered() has been called.');
+ //* NOISY-DEBUG: */ $this->debugOutput('PACKAGE: stateInstance=' . $helperInstance->getStateInstance());
+ //* NOISY-DEBUG: */ $this->debugOutput('PACKAGE: Reached line ' . __LINE__ . ' before isSocketRegistered() has been called.');
// Is it not there?
if ((is_resource($socketResource)) && (!$registryInstance->isSocketRegistered($helperInstance, $socketResource))) {
}
// Debug message
- //* NOISY-DEBUG: */ $this->debugOutput('NETWORK-PACKAGE: Reached line ' . __LINE__ . ' after isSocketRegistered() has been called.');
+ //* NOISY-DEBUG: */ $this->debugOutput('PACKAGE: Reached line ' . __LINE__ . ' after isSocketRegistered() has been called.');
// Make sure the connection is up
$helperInstance->getStateInstance()->validatePeerStateConnected();
// Debug message
- //* NOISY-DEBUG: */ $this->debugOutput('NETWORK-PACKAGE: Reached line ' . __LINE__ . ' after validatePeerStateConnected() has been called.');
+ //* NOISY-DEBUG: */ $this->debugOutput('PACKAGE: Reached line ' . __LINE__ . ' after validatePeerStateConnected() has been called.');
// Enqueue it again on the out-going queue, the connection is up and working at this point
$this->getStackerInstance()->pushNamed(self::STACKER_NAME_OUTGOING, $packageData);
// Debug message
- //* NOISY-DEBUG: */ $this->debugOutput('NETWORK-PACKAGE: Reached line ' . __LINE__ . ' after pushNamed() has been called.');
+ //* NOISY-DEBUG: */ $this->debugOutput('PACKAGE: Reached line ' . __LINE__ . ' after pushNamed() has been called.');
}
/**
// Sanity check if we have packages declared
if (!$this->isPackageDeclared()) {
// This is not fatal but should be avoided
- // @TODO Add some logging here
+ $this->debugOutput('PACKAGE: No package has been declared, but ' . __METHOD__ . ' has been called!');
return;
} // END - if
./application/hub/main/database/wrapper/states/class_PeerStateLookupDatabaseWrapper.php:177: * @todo Unfinished area
./application/hub/main/database/wrapper/states/class_PeerStateLookupDatabaseWrapper.php:219: * @todo Unfinished area
./application/hub/main/discovery/package/class_PackageRecipientDiscovery.php:100: * @todo Add some validation of recipient field, e.g. ip:port is found
-./application/hub/main/discovery/socket/class_PackageSocketDiscovery.php:102: // @TODO We may need some logging here
./application/hub/main/factories/socket/class_SocketFactory.php:10: * @todo Find an interface for hub helper
./application/hub/main/filter/bootstrap/chat/class_ChatBootstrapGenericActivationFilter.php:54: * @todo Maybe we want to do somthing more here?
./application/hub/main/filter/bootstrap/cruncher/class_CruncherBootstrapBufferQueueInitializerFilter.php:54: * @todo 0% done
./application/hub/main/helper/connection/class_BaseConnectionHelper.php:182: // @TODO Move this to the socket error handler
./application/hub/main/helper/connection/class_BaseConnectionHelper.php:210: * @todo Rewrite the while() loop to a iterator to not let the software stay very long here
./application/hub/main/helper/connection/tcp/class_TcpConnectionHelper.php:10: * @todo Find an interface for hub helper
-./application/hub/main/helper/connection/tcp/class_TcpConnectionHelper.php:143: * @todo We may want to implement a filter for ease notification of other objects like our pool
-./application/hub/main/helper/connection/tcp/class_TcpConnectionHelper.php:47: * @todo $errorCode/-Message are now in handleSocketError()'s call-back methods
-./application/hub/main/helper/connection/tcp/class_TcpConnectionHelper.php:84: // @TODO The whole resolving part should be moved out and made more configurable
+./application/hub/main/helper/connection/tcp/class_TcpConnectionHelper.php:145: * @todo We may want to implement a filter for ease notification of other objects like our pool
+./application/hub/main/helper/connection/tcp/class_TcpConnectionHelper.php:49: * @todo $errorCode/-Message are now in handleSocketError()'s call-back methods
+./application/hub/main/helper/connection/tcp/class_TcpConnectionHelper.php:86: // @TODO The whole resolving part should be moved out and made more configurable
./application/hub/main/helper/connection/udp/class_UdpConnectionHelper.php:10: * @todo Find an interface for hub helper
-./application/hub/main/helper/connection/udp/class_UdpConnectionHelper.php:54: * @todo Implement a filter for ease notification of other objects like the pool
+./application/hub/main/helper/connection/udp/class_UdpConnectionHelper.php:56: * @todo Implement a filter for ease notification of other objects like the pool
./application/hub/main/helper/hub/announcement/class_HubDescriptorHelper.php:10: * @todo Find an interface for hub helper
./application/hub/main/helper/hub/announcement/class_HubDescriptorHelper.php:61: * @todo Rewrite the ->renderXmlContent() call to no arguments
./application/hub/main/helper/hub/connection/class_HubSelfConnectHelper.php:10: * @todo Find an interface for hub helper
./application/hub/main/package/class_NetworkPackage.php:23: * @todo Needs to add functionality for handling the object's type
./application/hub/main/package/class_NetworkPackage.php:244: * @todo $helperInstance is unused
./application/hub/main/package/class_NetworkPackage.php:248: // @TODO crc32() is very weak, but it needs to be fast
-./application/hub/main/package/class_NetworkPackage.php:426: // @TODO We may want to do somthing more here?
-./application/hub/main/package/class_NetworkPackage.php:554: // @TODO Add some logging here
-./application/hub/main/package/class_NetworkPackage.php:580: // @TODO Add some logging here
-./application/hub/main/package/class_NetworkPackage.php:684: // @TODO Add some logging here
-./application/hub/main/package/class_NetworkPackage.php:783: // @TODO Add some content here
-./application/hub/main/package/class_NetworkPackage.php:822: * @todo This may be enchanced for outgoing packages?
+./application/hub/main/package/class_NetworkPackage.php:430: // @TODO We may want to do somthing more here?
+./application/hub/main/package/class_NetworkPackage.php:558: // @TODO Add some logging here
+./application/hub/main/package/class_NetworkPackage.php:688: // @TODO Add some logging here
+./application/hub/main/package/class_NetworkPackage.php:787: // @TODO Add some content here
+./application/hub/main/package/class_NetworkPackage.php:826: * @todo This may be enchanced for outgoing packages?
./application/hub/main/package/fragmenter/class_PackageFragmenter.php:274: * @todo Implement a way to send non-announcement packages with extra-salt
./application/hub/main/package/fragmenter/class_PackageFragmenter.php:442: * @todo $helperInstance is unused
./application/hub/main/producer/cruncher/keys/class_CruncherKeyProducer.php:106: // @TODO Do something with it