My Project
Loading...
Searching...
No Matches
MessageFrame.hpp
1#pragma once
2
3#include <string>
4#include <vector>
5#include "extern/nlohmann/json.hpp"
6
7using json = nlohmann::json;
8
9enum class MessageType {
10 Data,
11 Command,
12 Debug,
13 Algorithm,
14 // Add more types as needed
15};
16
17NLOHMANN_JSON_SERIALIZE_ENUM(MessageType, {
18 {MessageType::Data, "Data"},
19 {MessageType::Command, "Command"},
20 {MessageType::Debug, "Debug"},
21 {MessageType::Algorithm, "Algorithm"},
22})
23
24struct MessageHeader {
25 std::string messageId; // UUID or random message identifier
26 int sequenceNumber; // Fragment number
27 bool isLast; // Is this the last fragment
28 int payloadSize; // Payload size
29 MessageType type; // Type of the message
30
31 NLOHMANN_DEFINE_TYPE_INTRUSIVE(MessageHeader, messageId, sequenceNumber, isLast, payloadSize, type)
32};
33
35 MessageHeader header;
36 std::string payload; // Fragment of serialized JSON
37
38 NLOHMANN_DEFINE_TYPE_INTRUSIVE(MessageFrame, header, payload)
39};
Definition MessageFrame.hpp:34