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


Classes | |
| Structure representing a MessagePack encoded JSON message. More... | |
Public Member Functions | |
| json_packed ()=delete | |
| Default constructor (deleted) | |
| json_packed (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, MessagePack encoded JSON messages.
This class implements a protocol to handle messages that are MessagePack encoded JSON, terminated by a NULL character (‘’\0'). It uses base::byte_terminated for framing and then deserializes the MessagePack data into an nlohmann::json` object.
The onMessage method provides a message struct containing the raw MessagePack data, its size, and the deserialized nlohmann::json object to the I/O component's handler.
| IO_ | The I/O component type 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 JSON parsed from MessagePack format and passes it to the I/O object.
| size | Message size with the delimiter |
Implements qb::io::async::AProtocol< IO_ >.