/* */ #include "SimpleBtMessage.h" #include "message.h" #include "Peer.h" #include "PeerConnection.h" #include "Logger.h" #include "LogFactory.h" #include "util.h" #include "fmt.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()) { A2_LOG_INFO(fmt(MSG_SEND_PEER_MESSAGE, getCuid(), getPeer()->getIPAddress().c_str(), getPeer()->getPort(), toString().c_str())); unsigned char* msg = createMessage(); size_t msgLength = getMessageLength(); A2_LOG_DEBUG(fmt("msglength = %lu bytes", static_cast(msgLength))); getPeerConnection()->pushBytes(msg, msgLength); } getPeerConnection()->sendPendingData(); setSendingInProgress(!getPeerConnection()->sendBufferIsEmpty()); if(!isSendingInProgress()) { onSendComplete(); } } } // namespace aria2