1 #ifndef COMMAND_TABLE_H 2 #define COMMAND_TABLE_H 10 #include <unordered_map> 15 constexpr uint32_t PROTOCOL_VERS = 2;
16 constexpr int32_t SERVER_DEFAULT_PORT = 7777;
18 using identifier_t = int32_t;
21 constexpr uint32_t VersionProtocol = 2;
22 constexpr uint32_t Command = 2;
23 constexpr uint32_t Datetime =
sizeof(
DateTime);
24 constexpr uint32_t LoginName = 16;
25 constexpr uint32_t Password = 32;
26 constexpr uint32_t LoginId =
sizeof(identifier_t);
27 constexpr uint32_t RoomId =
sizeof(identifier_t);
28 constexpr uint32_t TextMessage = 255;
30 constexpr uint32_t Header = VersionProtocol + Command + Datetime;
31 constexpr uint32_t InputOption = LoginName + Password;
34 enum class TypeCommand : uint16_t {
38 AuthorisationRequest = 0x0003,
41 EchoResponse = 0x0006,
43 JoinRoomResponse = 0x0008,
44 LeaveRoomRequest = 0x0009,
47 static const std::unordered_map< TypeCommand, std::string> type_command_str = {
48 {TypeCommand::RegistrationRequest,
"RegistrationRequest"},
49 {TypeCommand::RegistrationResponse,
"RegistrationResponse"},
50 {TypeCommand::AuthorisationRequest,
"AuthorisationRequest"},
51 {TypeCommand::AutorisationResponse,
"AutorisationResponse"},
52 {TypeCommand::EchoRequest,
"EchoRequest"},
53 {TypeCommand::EchoResponse,
"EchoResponse"},
54 {TypeCommand::JoinRoomRequest,
"JoinRoomRequest"},
56 {TypeCommand::Unknown,
"Unknown"},
58 inline const std::string& get_command_str(TypeCommand command) {
59 if (
auto it=type_command_str.find(command); it!=type_command_str.end()) {
62 assert(type_command_str.at(TypeCommand::Unknown)==
"Unknown");
63 return type_command_str.at(TypeCommand::Unknown);
66 enum class InputCode : int {
77 virtual const void* get_header()
const = 0;
78 virtual void* get_header() = 0;
79 virtual const void* get_data()
const = 0;
80 virtual void* get_data() = 0;
82 virtual uint16_t get_protocol_version()
const = 0;
84 virtual TypeCommand get_type()
const = 0;
85 virtual TypeCommand get_type_data()
const = 0;
87 virtual DateTime get_datetime()
const = 0;
89 virtual uint32_t get_length_data()
const = 0;
92 using packet_ptr = std::shared_ptr<IPacket>;
94 #endif // COMMAND_TABLE_H Definition: command_table.h:20
The RegistrationResponse class.
Definition: input_response.h:34
The AutorisationResponse class.
Definition: input_response.h:54
Definition: control_request.h:34
Definition: command_table.h:73
The RegistrationRequest class.
Definition: input_request.h:33