|
qb
2.0.0.0
C++17 Actor Framework
|
Protocol for parsing null-terminated JSON messages. More...
#include <json.h>


Classes | |
| Structure representing a JSON message. More... | |
Public Member Functions | |
| json ()=delete | |
| Default constructor (deleted) | |
| json (IO_ &io) noexcept | |
| Constructor with I/O reference. | |
| void | onMessage (std::size_t size) noexcept final |
| Process a received message. | |
| Public Member Functions inherited from qb::protocol::base::byte_terminated< IO_, '\0'> | |
| byte_terminated ()=delete | |
| Default constructor (deleted) | |
| virtual | ~byte_terminated ()=default |
| Virtual destructor. | |
| std::size_t | shiftSize (std::size_t const size) const noexcept |
| Calculates the message size without the delimiter. | |
| 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 Attributes inherited from qb::protocol::base::byte_terminated< IO_, '\0'> | |
| static constexpr const std::size_t | delimiter_size |
| Delimiter size (1 byte) | |
| static constexpr const char | end |
| End character. | |
| 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. | |
| virtual | ~AProtocol ()=default |
| Virtual destructor. | |
| 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 parsing null-terminated JSON messages.
This class implements a protocol to handle JSON messages that are expected to be terminated by a NULL character (‘’\0'). It uses the qb::protocol::base::byte_terminated protocol as its base and parses the received data (excluding the terminator) as a JSON object using nlohmann::json`.
The onMessage method, when invoked by the framework, will provide a message struct containing the raw data, its size, and the parsed nlohmann::json object to the associated I/O component's handler.
| IO_ | The I/O component type (e.g., a TCP session class) that will use this protocol. It must be compatible with base::byte_terminated. |
|
inlineexplicitnoexcept |
Constructor with I/O reference.
| io | Reference to the I/O object that uses this protocol |
|
inlinefinalvirtualnoexcept |
Process a received message.
This method is called when a complete message is received. It builds a message object with the parsed JSON and passes it to the I/O object.
| size | Message size with the delimiter |
Implements qb::io::async::AProtocol< IO_ >.