/* */ #include "BtNotInterestedMessage.h" #include "Peer.h" #include "PeerStorage.h" #include "SocketBuffer.h" namespace aria2 { const char BtNotInterestedMessage::NAME[] = "not interested"; BtNotInterestedMessage::BtNotInterestedMessage() : ZeroBtMessage(ID, NAME), peerStorage_(nullptr) {} BtNotInterestedMessage::~BtNotInterestedMessage() {} std::unique_ptr BtNotInterestedMessage::create (const unsigned char* data, size_t dataLength) { return ZeroBtMessage::create(data, dataLength); } void BtNotInterestedMessage::doReceivedAction() { if(isMetadataGetMode()) { return; } getPeer()->peerInterested(false); if(!getPeer()->amChoking()) { peerStorage_->executeChoke(); } } bool BtNotInterestedMessage::sendPredicate() const { return getPeer()->amInterested(); } namespace { struct ThisProgressUpdate : public ProgressUpdate { ThisProgressUpdate(std::shared_ptr peer) : peer(std::move(peer)) {} virtual void update(size_t length, bool complete) CXX11_OVERRIDE { if(complete) { peer->amInterested(false); } } std::shared_ptr peer; }; } // namespace std::unique_ptr BtNotInterestedMessage::getProgressUpdate() { return make_unique(getPeer()); } void BtNotInterestedMessage::setPeerStorage(PeerStorage* peerStorage) { peerStorage_ = peerStorage; } } // namespace aria2