Botcraft 1.21.5
Loading...
Searching...
No Matches
Packet.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <vector>
4#include <memory>
5
7
8namespace ProtocolCraft
9{
10 class Handler;
11
12 class Packet : public NetworkType
13 {
14 public:
15 virtual ~Packet()
16 {
17
18 }
19
20 virtual void Write(WriteContainer& container) const override
21 {
22 WriteData<VarInt>(GetId(), container);
23 return WriteImpl(container);
24 }
25
26 void Dispatch(Handler *handler)
27 {
28 return DispatchImpl(handler);
29 }
30
31 virtual int GetId() const = 0;
32
33 virtual std::string_view GetName() const = 0;
34
35#ifdef PROTOCOLCRAFT_DETAILED_PARSING
36 /// @brief Get a default initialized copy of this type
37 /// @return A shared ptr to the same derived type of this Packet
38 virtual std::shared_ptr<Packet> CopyTypeOnly() const = 0;
39#endif
40
41 protected:
42 virtual void DispatchImpl(Handler *handler) = 0;
43 };
44} // ProtocolCraft
virtual void WriteImpl(WriteContainer &container) const =0
virtual std::string_view GetName() const =0
virtual void DispatchImpl(Handler *handler)=0
virtual int GetId() const =0
void Dispatch(Handler *handler)
Definition Packet.hpp:26
virtual void Write(WriteContainer &container) const override
Definition Packet.hpp:20
std::vector< unsigned char > WriteContainer