Skip to content

Commit

Permalink
message-buffer: add id to the beginning of the array
Browse files Browse the repository at this point in the history
  • Loading branch information
Grillo-0 committed Mar 20, 2022
1 parent c5de54a commit 125dcab
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/message-buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ void MessagesBuffer::write(std::uint8_t id, const nlohmann::json& message)

constexpr int numBytes = 90;
Message messageObj(numBytes);

messageObj.save<std::int8_t>(id);
messageObj << message;

m_messages.insert(std::make_pair(id, messageObj));
Expand Down
5 changes: 3 additions & 2 deletions src/message-buffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@ class Message {
std::size_t m_currSize;

void write(const nlohmann::json& json);
template <typename T>
void save(const nlohmann::json& json);

public:
explicit Message(std::size_t maxSize);

template <typename T>
void save(const nlohmann::json& json);

void operator<<(const nlohmann::json& json);
void operator>>(nlohmann::json& json);
};
Expand Down

0 comments on commit 125dcab

Please sign in to comment.