// CFG: NODE-DHT-DB-WRAPPER-CLASS
$cfg->setConfigEntry('node_dht_db_wrapper_class', 'NodeDistributedHashTableDatabaseWrapper');
+// CFG: NODE-DHT-LIST-LIMIT
+$cfg->setConfigEntry('node_dht_list_limit', 20);
+
// CFG: PEER-LOOKUP-DB-WRAPPER-CLASS
$cfg->setConfigEntry('peer_state_lookup_db_wrapper_class', 'PeerStateLookupDatabaseWrapper');
* - external-ip (hostname or IP number)
* - listen-port (TCP/UDP listen port for inbound connections)
*
- * @param $messageArray An array with all minimum message data
+ * @param $messageData An array with all minimum message data
* @param $handlerInstance An instance of a Handleable class
* @param $forceUpdate Optionally force update, don't register (default: register if not found)
* @return void
*/
function registerNodeByMessageData (array $messageData, Handleable $handlerInstance, $forceUpdate = FALSE);
+
+ /**
+ * Queries the local DHT data(base) for a node list with all supported
+ * object types except the node by given session id.
+ *
+ * @param $messageData An array with message data from a node_list request
+ * @return $nodeList An array with all found nodes
+ */
+ function queryLocalNodeListExceptByMessageData (array $messageData);
}
// [EOF]
// Save last exception
$handlerInstance->setLastException($this->getWrapperInstance()->getLastException());
}
+
+ /**
+ * Queries the local DHT data(base) for a node list with all supported
+ * object types except the node by given session id.
+ *
+ * @param $messageData An array with message data from a node_list request
+ * @return $nodeList An array with all found nodes
+ * @todo Implement exclusion/choise-inclusion criteria
+ */
+ public function queryLocalNodeListExceptByMessageData (array $messageData) {
+ // Get a search criteria class
+ $searchInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
+
+ // Debug message
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('DHT-FACADE: messageData=' . print_r($messageData, true));
+
+ // Only X entries are fine
+ $searchInstance->setLimit($this->getConfigInstance()->getConfigEntry('node_dht_list_limit'));
+
+ // Run the query
+ $resultInstance = $this->getWrapperInstance()->doSelectByCriteria($searchInstance);
+
+ // Get node list
+ $nodeList = array();
+ while ($resultInstance->next()) {
+ // Add this entry
+ array_push($nodeList, $resultInstance->current());
+ } // END - while
+
+ // Save last exception
+ $handlerInstance->setLastException($this->getWrapperInstance()->getLastException());
+
+ // Return node list (array)
+ return $nodeList;
+ }
}
// [EOF]
$this->getConfigInstance()->setConfigEntry($targetKey, $this->getConfigInstance()->getConfigEntry($sourceKey));
} // END - foreach
+ // Query local DHT for nodes except given session id
+ $nodeList = $this->getDhtInstance()->queryLocalNodeListExceptByMessageData($messageData);
+ die('nodeList='.print_r($nodeList, true));
+
// Translate last exception into a status code
$statusCode = $this->getTranslatedStatusFromLastException();