qb
2.0.0.0
C++17 Actor Framework
|
Protocol for binary messages where the payload is preceded by a fixed-size header indicating its length. More...
#include <text.h>
Classes | |
Structure representing a binary message. More... |
Public Member Functions | |
basic_binary ()=delete | |
Default constructor (deleted) | |
basic_binary (_IO_ &io) noexcept | |
Constructor with I/O reference. | |
void | onMessage (std::size_t size) const noexcept |
Process a received message. | |
Public Member Functions inherited from qb::protocol::base::size_as_header< _IO_, uint16_t > | |
size_as_header ()=delete | |
Default constructor. | |
std::size_t | shiftSize () const noexcept |
Returns the size of the header. | |
std::size_t | getMessageSize () noexcept final |
Determines the size of the next complete message. | |
void | reset () noexcept final |
Resets the protocol state. | |
Public Member Functions inherited from qb::io::async::IProtocol | |
virtual | ~IProtocol ()=default |
Virtual destructor. | |
bool | ok () const noexcept |
Checks if the protocol is in a valid operational state. | |
void | not_ok () noexcept |
Marks the protocol as being in an invalid or non-operational state. | |
void | set_should_flush (bool should_flush) noexcept |
Sets the flag indicating whether the protocol should flush the input buffer after processing a message. | |
bool | should_flush () const noexcept |
Gets the flag indicating whether the protocol should flush the input buffer after processing a message. |
Additional Inherited Members | |
Static Public Member Functions inherited from qb::protocol::base::size_as_header< _IO_, uint16_t > | |
static uint16_t | Header (std::size_t size) noexcept |
Creates a size header for a message. | |
Protected Member Functions inherited from qb::io::async::AProtocol< _IO_ > | |
AProtocol ()=delete | |
Default constructor is deleted to ensure an I/O component is always associated. | |
AProtocol (_IO_ &io) noexcept | |
Constructor that associates the protocol with an I/O component. | |
virtual | ~AProtocol ()=default |
Virtual destructor. | |
virtual void | onMessage (std::size_t size) noexcept=0 |
Processes a complete message from the input buffer of the associated I/O component. | |
Protected Attributes inherited from qb::io::async::AProtocol< _IO_ > | |
_IO_ & | _io |
Reference to the I/O component instance that this protocol is associated with. |
Protocol for binary messages where the payload is preceded by a fixed-size header indicating its length.
This class implements a protocol to handle binary messages that are prefixed with a header of type _SizeHeader containing their payload size. It uses the qb::protocol::base::size_as_header protocol as its base. Upon receiving a complete message, it provides a message struct containing the raw payload data pointer and its size to the I/O component's handler.
_IO_ | The I/O component type that will use this protocol. |
_SizeHeader | The integer type of the size header (e.g., uint8_t, uint16_t). Defaults to uint16_t. |
|
inlinenoexcept |
Constructor with I/O reference.
io | Reference to the I/O object that uses this protocol |
|
inlinenoexcept |
Process a received message.
This method is called when a complete message is received. It builds a message object and passes it to the I/O object.
size | Message size |