#ifndef _D_MOCK_DHT_MESSAGE_H_ #define _D_MOCK_DHT_MESSAGE_H_ #include "DHTMessage.h" #include "DHTQueryMessage.h" #include "DHTResponseMessage.h" #include #include "DHTNode.h" #include "Peer.h" namespace aria2 { class DHTMessageCallback; class MockDHTMessage:public DHTMessage { public: bool isReply_; std::string messageType_; std::vector > nodes_; std::vector > peers_; std::string token_; public: MockDHTMessage(const SharedHandle& localNode, const SharedHandle& remoteNode, const std::string& messageType = "mock", const std::string& transactionID = ""): DHTMessage(localNode, remoteNode, transactionID), isReply_(false), messageType_(messageType) {} virtual ~MockDHTMessage() {} virtual void doReceivedAction() {} virtual bool send() { return true; } virtual bool isReply() const { return isReply_; } void setReply(bool f) { isReply_ = f; } virtual const std::string& getMessageType() const { return messageType_; } virtual std::string toString() const { return "MockDHTMessage"; } }; class MockDHTQueryMessage:public DHTQueryMessage { public: std::string messageType_; std::vector > nodes_; std::vector > peers_; std::string token_; public: MockDHTQueryMessage(const SharedHandle& localNode, const SharedHandle& remoteNode, const std::string& messageType = "mock", const std::string& transactionID = ""): DHTQueryMessage(localNode, remoteNode, transactionID), messageType_(messageType) {} virtual ~MockDHTQueryMessage() {} virtual void doReceivedAction() {} virtual bool send() { return true; } virtual bool isReply() const { return false; } virtual const std::string& getMessageType() const { return messageType_; } virtual std::string toString() const { return "MockDHTMessage"; } virtual SharedHandle getArgument() { return Dict::g(); } }; class MockDHTResponseMessage:public DHTResponseMessage { public: std::string messageType_; std::vector > nodes_; std::vector > peers_; std::string token_; public: MockDHTResponseMessage(const SharedHandle& localNode, const SharedHandle& remoteNode, const std::string& messageType = "mock", const std::string& transactionID = ""): DHTResponseMessage(localNode, remoteNode, transactionID), messageType_(messageType) {} virtual ~MockDHTResponseMessage() {} virtual void doReceivedAction() {} virtual bool send() { return true; } virtual bool isReply() const { return true; } virtual const std::string& getMessageType() const { return messageType_; } virtual std::string toString() const { return "MockDHTMessage"; } virtual SharedHandle getResponse() { return Dict::g(); } virtual void accept(DHTMessageCallback* callback) {} }; } // namespace aria2 #endif // _D_MOCK_DHT_MESSAGE_H_