/* */ #include "DHTFindNodeMessage.h" #include "DHTNode.h" #include "Data.h" #include "Dictionary.h" #include "DHTRoutingTable.h" #include "DHTMessageFactory.h" #include "DHTMessageDispatcher.h" #include "DHTMessageCallback.h" #include namespace aria2 { DHTFindNodeMessage::DHTFindNodeMessage(const SharedHandle& localNode, const SharedHandle& remoteNode, const unsigned char* targetNodeID, const std::string& transactionID): DHTQueryMessage(localNode, remoteNode, transactionID) { memcpy(_targetNodeID, targetNodeID, DHT_ID_LENGTH); } DHTFindNodeMessage::~DHTFindNodeMessage() {} void DHTFindNodeMessage::doReceivedAction() { std::deque > nodes = _routingTable->getClosestKNodes(_targetNodeID); SharedHandle reply = _factory->createFindNodeReplyMessage(_remoteNode, nodes, _transactionID); _dispatcher->addMessageToQueue(reply); } Dictionary* DHTFindNodeMessage::getArgument() { Dictionary* a = new Dictionary(); a->put("id", new Data(reinterpret_cast(_localNode->getID()), DHT_ID_LENGTH)); a->put("target", new Data(reinterpret_cast(_targetNodeID), DHT_ID_LENGTH)); return a; } std::string DHTFindNodeMessage::getMessageType() const { return "find_node"; } void DHTFindNodeMessage::validate() const {} } // namespace aria2