Botcraft 1.21.4
Loading...
Searching...
No Matches
Message.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 Message : public NetworkType
13 {
14 public:
15 virtual ~Message()
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 Message
38 virtual std::shared_ptr<Message> CopyTypeOnly() const = 0;
39#endif
40
41 protected:
42 virtual void DispatchImpl(Handler *handler) = 0;
43 };
44} // ProtocolCraft
virtual int GetId() const =0
virtual void DispatchImpl(Handler *handler)=0
void Dispatch(Handler *handler)
Definition Message.hpp:26
virtual std::string_view GetName() const =0
virtual void Write(WriteContainer &container) const override
Definition Message.hpp:20
virtual void WriteImpl(WriteContainer &container) const =0
std::vector< unsigned char > WriteContainer