R-Type  2
Doom but in better
Loading...
Searching...
No Matches
message_codec.hpp File Reference
#include "message.hpp"
#include <cstring>
#include <vector>
Include dependency graph for message_codec.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

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).
 

Function Documentation

◆ 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
dataPointer to the incoming data.
lengthTotal bytes available in data.
outThe 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
msgThe Message to encode.
Returns
A vector of bytes ready to send.

Definition at line 32 of file message_codec.hpp.