]> git.localhorst.tv Git - blank.git/blob - src/net/Packet.hpp
tag packets withsequence numbers
[blank.git] / src / net / Packet.hpp
1 #ifndef BLANK_NET_PACKET_HPP_
2 #define BLANK_NET_PACKET_HPP_
3
4 #include <cstdint>
5 #include <string>
6
7
8 namespace blank {
9
10 struct Packet {
11
12         static constexpr std::uint32_t TAG = 0xFB1AB1AF;
13
14         enum Type {
15                 PING = 0,
16                 LOGIN = 1,
17         };
18
19         struct TControl {
20                 std::uint16_t seq;
21                 std::uint16_t ack;
22                 std::uint32_t hist;
23         };
24
25         struct Header {
26                 std::uint32_t tag;
27                 TControl ctrl;
28                 std::uint8_t type;
29         } header;
30
31         std::uint8_t payload[500 - sizeof(Header)];
32
33
34         void Tag() noexcept;
35
36         std::size_t Ping() noexcept;
37         std::size_t Login(const std::string &name) noexcept;
38
39 };
40
41 }
42
43 #endif