#ifndef _D_MOCK_DHT_MESSAGE_FACTORY_H_ #define _D_MOCK_DHT_MESSAGE_FACTORY_H_ #include "DHTMessageFactory.h" #include "DHTNode.h" #include "MockDHTMessage.h" #include "Dictionary.h" #include "Data.h" namespace aria2 { class MockDHTMessageFactory:public DHTMessageFactory { protected: SharedHandle _localNode; public: MockDHTMessageFactory() {} virtual ~MockDHTMessageFactory() {} virtual SharedHandle createQueryMessage(const Dictionary* d, const std::string& ipaddr, uint16_t port) { return 0; } virtual SharedHandle createResponseMessage(const std::string& messageType, const Dictionary* d, const SharedHandle& remoteNode) { SharedHandle m = new MockDHTMessage(_localNode, remoteNode, reinterpret_cast(d->get("t"))->toString()); m->setReply(true); return m; } virtual SharedHandle createPingMessage(const SharedHandle& remoteNode, const std::string& transactionID = "") { return 0; } virtual SharedHandle createPingReplyMessage(const SharedHandle& remoteNode, const unsigned char* remoteNodeID, const std::string& transactionID) { return 0; } virtual SharedHandle createFindNodeMessage(const SharedHandle& remoteNode, const unsigned char* targetNodeID, const std::string& transactionID = "") { return 0; } virtual SharedHandle createFindNodeReplyMessage(const SharedHandle& remoteNode, const std::deque >& closestKNodes, const std::string& transactionID) { return 0; } virtual SharedHandle createGetPeersMessage(const SharedHandle& remoteNode, const unsigned char* infoHash, const std::string& transactionID) { return 0; } virtual SharedHandle createGetPeersReplyMessage(const SharedHandle& remoteNode, const std::deque >& closestKNodes, const std::string& token, const std::string& transactionID) { return 0; } virtual SharedHandle createGetPeersReplyMessage(const SharedHandle& remoteNode, const std::deque >& peers, const std::string& token, const std::string& transactionID) { return 0; } virtual SharedHandle createAnnouncePeerMessage(const SharedHandle& remoteNode, const unsigned char* infoHash, uint16_t tcpPort, const std::string& token, const std::string& transactionID = "") { return 0; } virtual SharedHandle createAnnouncePeerReplyMessage(const SharedHandle& remoteNode, const std::string& transactionID) { return 0; } virtual SharedHandle createUnknownMessage(const char* data, size_t length, const std::string& ipaddr, uint16_t port) { return 0; } void setLocalNode(const SharedHandle& node) { _localNode = node; } }; } // namespace aria2 #endif // _D_MOCK_DHT_MESSAGE_FACTORY_H_