/* */ #include "IndexBtMessage.h" #include "util.h" #include "a2functional.h" #include "bittorrent_helper.h" namespace aria2 { const unsigned char* IndexBtMessage::getMessage() { if(!_msg) { /** * len --- 5, 4bytes * id --- ?, 1byte * piece index --- index, 4bytes * total: 9bytes */ _msg = new unsigned char[MESSAGE_LENGTH]; bittorrent::createPeerMessageString(_msg, MESSAGE_LENGTH, 5, getId()); bittorrent::setIntParam(&_msg[5], _index); } return _msg; } size_t IndexBtMessage::getMessageLength() { return MESSAGE_LENGTH; } std::string IndexBtMessage::toString() const { return strconcat(getName(), " index=", util::itos(_index)); } } // namespace aria2