]> git.localhorst.tv Git - blank.git/blobdiff - src/net/Packet.hpp
added message packet
[blank.git] / src / net / Packet.hpp
index 7b9b69e447289efbd2831503f5e3ea2689ce64e4..c9184d47000b40e5252d296619176f0c6c3185d4 100644 (file)
@@ -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<class PayloadType>
        PayloadType As() {