|
Furrent
|
#include <message.hpp>

Public Member Functions | |
| virtual | ~Message ()=default |
| virtual std::vector< uint8_t > | encode () const |
| virtual MessageKind | kind () const =0 |
Static Public Member Functions | |
| static Result< std::unique_ptr< Message >, DecodeError > | decode (const TorrentFile &torrent, const std::vector< uint8_t > &buf) |
Virtual class for messages exchanged between BitTorrent clients. They are all shaped like: <length><id><payload>
|
virtualdefault |
|
static |
Try decoding a finite sequence of bytes into a Message. A return value std::nullopt indicates failure and receding communication with the peer is advised to avoid invalid state. The TorrentFile is currently only required because BitfieldMessage needs to know the piece count to decode itself nicely.
|
virtual |
Encode this message to wire format. This is virtual because KeepAliveMessage uses a slightly different encoding that all other messages. That's the only subclass overriding encode.
Reimplemented in fur::download::message::KeepAliveMessage.
|
pure virtual |
Returns the kind of this message. Used before dynamic_casting when the underlying type is not known beforehand.
Implemented in fur::download::message::PieceMessage, fur::download::message::RequestMessage, fur::download::message::BitfieldMessage, fur::download::message::HaveMessage, fur::download::message::NotInterestedMessage, fur::download::message::InterestedMessage, fur::download::message::UnchokeMessage, fur::download::message::ChokeMessage, and fur::download::message::KeepAliveMessage.
1.8.17