X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fnet%2FPacket.hpp;fp=src%2Fnet%2FPacket.hpp;h=c9184d47000b40e5252d296619176f0c6c3185d4;hb=ca90ec459ca0bd48c1483a45f30496aed61e9c21;hp=7b9b69e447289efbd2831503f5e3ea2689ce64e4;hpb=54f3f1260b95a924fcb40d9d6de3fa2e2c382f6f;p=blank.git diff --git a/src/net/Packet.hpp b/src/net/Packet.hpp index 7b9b69e..c9184d4 100644 --- a/src/net/Packet.hpp +++ b/src/net/Packet.hpp @@ -218,6 +218,23 @@ struct Packet { void ReadBlock(Block &, std::uint32_t) const noexcept; }; + struct Message : public Payload { + static constexpr std::uint8_t TYPE = 12; + static constexpr std::size_t MAX_LEN = 455; + + static constexpr std::size_t MAX_MESSAGE_LEN = 450; + static std::size_t GetSize(const std::string &msg) noexcept { + return 5 + std::min(msg.size() + 1, MAX_MESSAGE_LEN); + } + + void WriteType(std::uint8_t) noexcept; + void ReadType(std::uint8_t &) const noexcept; + void WriteReferral(std::uint32_t) noexcept; + void ReadReferral(std::uint32_t &) const noexcept; + void WriteMessage(const std::string &) noexcept; + void ReadMessage(std::string &) const noexcept; + }; + template PayloadType As() {