/* */ #ifndef D_UT_PEX_EXTENSION_MESSAGE_H #define D_UT_PEX_EXTENSION_MESSAGE_H #include "ExtensionMessage.h" #include #include #include #include "a2time.h" namespace aria2 { class PeerStorage; class Peer; class UTPexExtensionMessage:public ExtensionMessage { private: uint8_t extensionMessageID_; std::vector > freshPeers_; std::vector > droppedPeers_; std::shared_ptr peerStorage_; time_t interval_; size_t maxFreshPeer_; size_t maxDroppedPeer_; std::pair, std::pair > createCompactPeerListAndFlag(const std::vector >& peers); public: UTPexExtensionMessage(uint8_t extensionMessageID); virtual ~UTPexExtensionMessage(); virtual std::string getPayload(); virtual uint8_t getExtensionMessageID() { return extensionMessageID_; } virtual const char* getExtensionName() const { return EXTENSION_NAME; } static const char EXTENSION_NAME[]; virtual std::string toString() const; virtual void doReceivedAction(); bool addFreshPeer(const std::shared_ptr& peer); const std::vector >& getFreshPeers() const { return freshPeers_; } bool freshPeersAreFull() const; bool addDroppedPeer(const std::shared_ptr& peer); const std::vector >& getDroppedPeers() const { return droppedPeers_; } bool droppedPeersAreFull() const; void setPeerStorage(const std::shared_ptr& peerStorage); static UTPexExtensionMessage* create(const unsigned char* data, size_t len); void setMaxFreshPeer(size_t maxFreshPeer); size_t getMaxFreshPeer() const { return maxFreshPeer_; } void setMaxDroppedPeer(size_t maxDroppedPeer); size_t getMaxDroppedPeer() const { return maxDroppedPeer_; } static const time_t DEFAULT_INTERVAL = 60; }; } // namespace aria2 #endif // D_UT_PEX_EXTENSION_MESSAGE_H