/* */ #include "IndexBtMessage.h" #include "util.h" #include "a2functional.h" #include "bittorrent_helper.h" namespace aria2 { unsigned char* IndexBtMessage::createMessage() { /** * len --- 5, 4bytes * id --- ?, 1byte * piece index --- index, 4bytes * total: 9bytes */ unsigned char* 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