#ifndef D_MOCK_DHT_MESSAGE_FACTORY_H #define D_MOCK_DHT_MESSAGE_FACTORY_H #include "DHTMessageFactory.h" #include "DHTNode.h" #include "MockDHTMessage.h" namespace aria2 { class MockDHTMessageFactory:public DHTMessageFactory { protected: std::shared_ptr localNode_; public: MockDHTMessageFactory() {} virtual ~MockDHTMessageFactory() {} virtual std::shared_ptr createQueryMessage(const Dict* dict, const std::string& ipaddr, uint16_t port) { return std::shared_ptr(); } virtual std::shared_ptr createResponseMessage(const std::string& messageType, const Dict* dict, const std::string& ipaddr, uint16_t port) { std::shared_ptr remoteNode(new DHTNode()); // TODO At this point, removeNode's ID is random. remoteNode->setIPAddress(ipaddr); remoteNode->setPort(port); std::shared_ptr m (new MockDHTResponseMessage(localNode_, remoteNode, downcast(dict->get("t"))->s())); return m; } virtual std::shared_ptr createPingMessage(const std::shared_ptr& remoteNode, const std::string& transactionID = "") { return std::shared_ptr(); } virtual std::shared_ptr createPingReplyMessage(const std::shared_ptr& remoteNode, const unsigned char* remoteNodeID, const std::string& transactionID) { return std::shared_ptr(); } virtual std::shared_ptr createFindNodeMessage(const std::shared_ptr& remoteNode, const unsigned char* targetNodeID, const std::string& transactionID = "") { return std::shared_ptr(); } virtual std::shared_ptr createFindNodeReplyMessage (const std::shared_ptr& remoteNode, const std::vector >& closestKNodes, const std::string& transactionID) { return std::shared_ptr(); } virtual std::shared_ptr createGetPeersMessage(const std::shared_ptr& remoteNode, const unsigned char* infoHash, const std::string& transactionID) { return std::shared_ptr(); } virtual std::shared_ptr createGetPeersReplyMessage (const std::shared_ptr& remoteNode, const std::vector >& closestKNodes, const std::vector >& peers, const std::string& token, const std::string& transactionID) { return std::shared_ptr(); } virtual std::shared_ptr createAnnouncePeerMessage(const std::shared_ptr& remoteNode, const unsigned char* infoHash, uint16_t tcpPort, const std::string& token, const std::string& transactionID = "") { return std::shared_ptr(); } virtual std::shared_ptr createAnnouncePeerReplyMessage(const std::shared_ptr& remoteNode, const std::string& transactionID) { return std::shared_ptr(); } virtual std::shared_ptr createUnknownMessage(const unsigned char* data, size_t length, const std::string& ipaddr, uint16_t port) { return std::shared_ptr(); } void setLocalNode(const std::shared_ptr& node) { localNode_ = node; } }; } // namespace aria2 #endif // D_MOCK_DHT_MESSAGE_FACTORY_H