protected function __construct ($className) {
// Call parent constructor
parent::__construct($className);
+
+ // Get a DHT instance
+ $dhtInstance = DhtObjectFactory::createDhtObjectInstance('node');
+
+ // Set it here
+ $this->setDhtInstance($dhtInstance);
}
/**
// Call parent constructor
parent::__construct(__CLASS__);
+ // Get a DHT instance
+ $dhtInstance = DhtObjectFactory::createDhtObjectInstance('node');
+
+ // Set it here
+ $this->setDhtInstance($dhtInstance);
+
// Init salt length
$this->sessionIdLength = 32 + $this->getConfigInstance()->getConfigEntry('salt_length');
}
* @return $recipient Recipient as ip:port combination
*/
protected function resolveIpPortBySessionId ($sessionId) {
- // Get a DHT instance
- $dhtInstance = DhtObjectFactory::createDhtObjectInstance('node');
-
// And ask it for ip:port by given session id
- $recipient = $dhtInstance->findNodeBySessionId($sessionId);
+ $recipient = $this->getDhtInstance()->findNodeBySessionId($sessionId);
// Is the recipient invalid?
if ((!isset($recipient[NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_IP_PORT])) || ($recipient[NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_IP_PORT] == 'invalid:invalid')) {
* @return $sessionId Valid session id
*/
public static function resolveSessionIdByIpPort ($ipPort) {
- // Get a DHT instance
- $dhtInstance = DhtObjectFactory::createDhtObjectInstance('node');
-
// And ask it for session id by given ip:port
- $recipient = $dhtInstance->findNodeByIpPort($ipPort);
+ $recipient = $this->getDhtInstance()->findNodeByIpPort($ipPort);
die(__METHOD__.':recipient=<pre>'.print_r($recipient, true).'</pre>' . PHP_EOL);
// Return result