#include "message.hpp"
#include <cstring>
#include <vector>
Go to the source code of this file.
|
bool | decodeMessage (const char *data, size_t length, Message &out) |
| Decodes a raw buffer into a Message (2-byte type, 2-byte length, then payload).
|
|
std::vector< uint8_t > | encodeMessage (const Message &msg) |
| Encodes a Message into a raw buffer (2-byte type, 2-byte length, then payload).
|
|
◆ decodeMessage()
bool decodeMessage |
( |
const char * | data, |
|
|
size_t | length, |
|
|
Message & | out ) |
|
inline |
Decodes a raw buffer into a Message (2-byte type, 2-byte length, then payload).
- Parameters
-
data | Pointer to the incoming data. |
length | Total bytes available in data . |
out | The Message struct to fill. |
- Returns
- true if successful, false if invalid format.
Definition at line 13 of file message_codec.hpp.
◆ encodeMessage()
std::vector< uint8_t > encodeMessage |
( |
const Message & | msg | ) |
|
|
inline |
Encodes a Message into a raw buffer (2-byte type, 2-byte length, then payload).
- Parameters
-
- Returns
- A vector of bytes ready to send.
Definition at line 32 of file message_codec.hpp.