|
Flyby SDK v1.0.2
|
A message that is sent across the message bus. More...
#include <message.h>


Public Types | |
| enum | MessageType : std::uint8_t { TEXT = 0 , OBJECT } |
| The types that messages can hold. | |
Public Member Functions | |
| Message (const std::string &msg, const std::string &source=std::string()) | |
| Message constructor for text messages. | |
| Message (const std::shared_ptr< MessageObject > &msg, const std::string &source=std::string()) | |
| Message constructor for object messages. | |
| void | set_version (const std::string &version) |
| Set the version of the message protocol. | |
| void | set_source (const std::string &source) |
| Set the source of the message. | |
| void | set_type (MessageType type) |
| Set the type of the message. | |
| void | set_payload (const std::string &payload) |
| Set the payload of the message. | |
| std::string | get_version () const |
| Get the version of the message. | |
| std::string | get_source () const |
| Get the source of the message. | |
| MessageType | get_type () const |
| Get the type of the message. | |
| std::string | get_payload () const |
| Get the payload of the message. | |
| bool | is_object () const |
| Check if the message is an object type. | |
| std::string | serialize () const override |
| Serialize the message. | |
A message that is sent across the message bus.
Messages contain information about their structure, source, and version as metadata and may be composed of objects or text
|
explicit |
Message constructor for text messages.
| msg | - the message payload text |
| source | - the source of the message [default: empty string] |
|
explicit |
Message constructor for object messages.
| msg | - the message payload object |
| source | - the source of the message [default: empty string] |
|
nodiscard |
Get the payload of the message.
|
nodiscard |
Get the source of the message.
|
nodiscard |
Get the type of the message.
|
nodiscard |
Get the version of the message.
|
nodiscard |
Check if the message is an object type.
|
nodiscardoverridevirtual |
Serialize the message.
Implements flyby::SerialObject.
| void flyby::Message::set_payload | ( | const std::string & | payload | ) |
Set the payload of the message.
| payload | - The actual message payload, either object or string. |
| void flyby::Message::set_source | ( | const std::string & | source | ) |
Set the source of the message.
| source | - the name of the source application or unit. |
| void flyby::Message::set_type | ( | MessageType | type | ) |
Set the type of the message.
| type | - The message type, such as object or text. |
| void flyby::Message::set_version | ( | const std::string & | version | ) |
Set the version of the message protocol.
| version | - the message protocol version. |