/* */ #include "SimpleBtMessage.h" #include "message.h" #include "BtRegistry.h" #include "Peer.h" #include "PeerConnection.h" #include "Logger.h" namespace aria2 { SimpleBtMessage::SimpleBtMessage():leftDataLength(0) {} SimpleBtMessage::~SimpleBtMessage() {} void SimpleBtMessage::send() { if(invalidate) { return; } if(sendPredicate() || sendingInProgress) { const unsigned char* msg = getMessage(); int32_t msgLength = getMessageLength(); if(!sendingInProgress) { logger->info(MSG_SEND_PEER_MESSAGE, cuid, peer->ipaddr.c_str(), peer->port, toString().c_str()); leftDataLength = getMessageLength(); } sendingInProgress = false; int32_t writtenLength = peerConnection->sendMessage(msg+msgLength-leftDataLength, leftDataLength); if(writtenLength == leftDataLength) { onSendComplete(); } else { leftDataLength -= writtenLength; sendingInProgress = true; } } } } // namespace aria2