|
unilink
0.4.3
A simple C++ library for unified async communication
|
Framer for binary packet protocols. More...
#include <packet_framer.hpp>
Public Member Functions | |
| PacketFramer (const std::vector< uint8_t > &start_pattern, const std::vector< uint8_t > &end_pattern, size_t max_length) | |
| Construct a new Packet Framer. More... | |
| ~PacketFramer () override=default | |
| void | push_bytes (memory::ConstByteSpan data) override |
| Push raw bytes into the framer's internal buffer. More... | |
| void | set_on_message (MessageCallback cb) override |
| void | reset () override |
| Reset internal state/buffer. More... | |
Public Member Functions inherited from unilink::framer::IFramer | |
| virtual | ~IFramer ()=default |
Additional Inherited Members | |
Public Types inherited from unilink::framer::IFramer | |
| using | MessageCallback = std::function< void(memory::ConstByteSpan)> |
| Register a callback to be invoked when a complete message is extracted. More... | |
Framer for binary packet protocols.
Handles protocols with start and end patterns. Syncs by searching for start pattern, then collects data until end pattern is found.
Definition at line 33 of file packet_framer.hpp.
| unilink::framer::PacketFramer::PacketFramer | ( | const std::vector< uint8_t > & | start_pattern, |
| const std::vector< uint8_t > & | end_pattern, | ||
| size_t | max_length | ||
| ) |
Construct a new Packet Framer.
| start_pattern | The start pattern bytes |
| end_pattern | The end pattern bytes |
| max_length | Maximum packet length (including patterns) before reset |
Definition at line 26 of file packet_framer.cc.
|
overridedefault |
|
overridevirtual |
Push raw bytes into the framer's internal buffer.
The framer will buffer the data and invoke the message callback whenever a complete message is extracted.
| data | The raw data chunk to process. |
Implements unilink::framer::IFramer.
Definition at line 34 of file packet_framer.cc.
|
overridevirtual |
Reset internal state/buffer.
Should be called on connection loss or when resynchronization is needed.
Implements unilink::framer::IFramer.
Definition at line 223 of file packet_framer.cc.
|
overridevirtual |
Implements unilink::framer::IFramer.
Definition at line 221 of file packet_framer.cc.