// @TODO This is very static, rewrite it to more flexible
$cfg->setConfigEntry('package_recipient_max_count', 3);
-// CFG: DHT-CLASS
-$cfg->setConfigEntry('dht_class', 'NodeDhtFacade');
+// CFG: NODE-DHT-CLASS
+$cfg->setConfigEntry('node_dht_class', 'NodeDhtFacade');
///////////////////////////////////////////////////////////////////////////////
// Peer states
$chainInstance = Registry::getRegistry()->getInstance($registryKey);
} else {
// Initialize a filter chain class
- $chainInstance = ObjectFactory::createObjectByConfiguredName('package_filter_chain_class');
+ $chainInstance = self::createObjectByConfiguredName('package_filter_chain_class');
// "Walk" through all tags entries
foreach ($tags as $tag) {
* simply means the tag is not valid. This however should be
* handled some calls before this method is called.
*/
- $filterInstance = ObjectFactory::createObjectByConfiguredName('package_tag_' . $tag . '_filter');
+ $filterInstance = self::createObjectByConfiguredName('package_tag_' . $tag . '_filter');
// Add this filter to the chain
$chainInstance->addFilter($filterInstance);
/**
* Returns a singleton (registry-based) DHT object instance
*
+ * @param $prefix Prefix for DHT class name and registry key
* @return $dhtInstance An instance of a DHT object class
*/
- public static final function createDhtObjectInstance () {
+ public static final function createDhtObjectInstance ($prefix) {
// If there is no handler?
- if (Registry::getRegistry()->instanceExists('dht')) {
+ if (Registry::getRegistry()->instanceExists($prefix . '_dht')) {
// Get handler from registry
- $dhtInstance = Registry::getRegistry()->getInstance('dht');
+ $dhtInstance = Registry::getRegistry()->getInstance($prefix . '_dht');
} else {
// Get the handler instance
- $dhtInstance = self::createObjectByConfiguredName('dht_class');
+ $dhtInstance = self::createObjectByConfiguredName($prefix . '_dht_class');
// Add it to the registry
- Registry::getRegistry()->addInstance('dht', $dhtInstance);
+ Registry::getRegistry()->addInstance($prefix . '_dht', $dhtInstance);
}
// Return the instance
$taskInstance = new NodeDhtBootstrapTask();
// Get a DHT instance
- $dhtInstance = DhtObjectFactory::createDhtObjectInstance();
+ $dhtInstance = DhtObjectFactory::createDhtObjectInstance('node');
// Set the DHT instance here
$taskInstance->setDhtInstance($dhtInstance);
$taskInstance = new NodeDhtInitializationTask();
// Get a DHT instance
- $dhtInstance = DhtObjectFactory::createDhtObjectInstance();
+ $dhtInstance = DhtObjectFactory::createDhtObjectInstance('node');
// Set the DHT instance here
$taskInstance->setDhtInstance($dhtInstance);
$taskInstance = new NodeDhtQueryTask();
// Get a DHT instance
- $dhtInstance = DhtObjectFactory::createDhtObjectInstance();
+ $dhtInstance = DhtObjectFactory::createDhtObjectInstance('node');
// Set the DHT instance here
$taskInstance->setDhtInstance($dhtInstance);
*/
protected function resolveIpPortBySessionId ($sessionId, $protocol) {
// Get a DHT instance
- $dhtInstance = DhtObjectFactory::createDhtObjectInstance();
+ $dhtInstance = DhtObjectFactory::createDhtObjectInstance('node');
// And ask it for ip:port by given session id
$recipient = $dhtInstance->findNodeBySessionId($sessionId, $protocol);
*/
public static function resolveSessionIdByIpPort ($ipPort, $protocol) {
// Get a DHT instance
- $dhtInstance = DhtObjectFactory::createDhtObjectInstance();
+ $dhtInstance = DhtObjectFactory::createDhtObjectInstance('node');
// And ask it for session id by given ip:port
$recipient = $dhtInstance->findNodeByIpPort($ipPort, $protocol);