/* */ #include "SimpleBtMessage.h" #include "message.h" #include "Peer.h" #include "PeerConnection.h" #include "Logger.h" #include "util.h" namespace aria2 { SimpleBtMessage::SimpleBtMessage(uint8_t id, const std::string& name): AbstractBtMessage(id, name) {} void SimpleBtMessage::send() { if(isInvalidate()) { return; } if(!sendPredicate() && !isSendingInProgress()) { return; } if(!isSendingInProgress()) { if(getLogger()->info()) { getLogger()->info(MSG_SEND_PEER_MESSAGE, util::itos(getCuid()).c_str(), getPeer()->getIPAddress().c_str(), getPeer()->getPort(), toString().c_str()); } unsigned char* msg = createMessage(); size_t msgLength = getMessageLength(); if(getLogger()->debug()) { getLogger()->debug("msglength = %lu bytes", static_cast(msgLength)); } getPeerConnection()->pushBytes(msg, msgLength); } getPeerConnection()->sendPendingData(); setSendingInProgress(!getPeerConnection()->sendBufferIsEmpty()); if(!isSendingInProgress()) { onSendComplete(); } } } // namespace aria2