Flyby SDK v1.0.2
Loading...
Searching...
No Matches
flyby::Message Class Reference

A message that is sent across the message bus. More...

#include <message.h>

Inheritance diagram for flyby::Message:
Collaboration diagram for flyby::Message:

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.

Detailed Description

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

Constructor & Destructor Documentation

◆ Message() [1/2]

flyby::Message::Message ( const std::string & msg,
const std::string & source = std::string() )
explicit

Message constructor for text messages.

Parameters
msg- the message payload text
source- the source of the message [default: empty string]

◆ Message() [2/2]

flyby::Message::Message ( const std::shared_ptr< MessageObject > & msg,
const std::string & source = std::string() )
explicit

Message constructor for object messages.

Parameters
msg- the message payload object
source- the source of the message [default: empty string]

Member Function Documentation

◆ get_payload()

std::string flyby::Message::get_payload ( ) const
nodiscard

Get the payload of the message.

Returns
The actual message payload as a string.

◆ get_source()

std::string flyby::Message::get_source ( ) const
nodiscard

Get the source of the message.

Returns
The name of the message source.

◆ get_type()

MessageType flyby::Message::get_type ( ) const
nodiscard

Get the type of the message.

Returns
The message type, including object or text.

◆ get_version()

std::string flyby::Message::get_version ( ) const
nodiscard

Get the version of the message.

Returns
The message protocol version.

◆ is_object()

bool flyby::Message::is_object ( ) const
nodiscard

Check if the message is an object type.

Returns
True if it is an object type.

◆ serialize()

std::string flyby::Message::serialize ( ) const
nodiscardoverridevirtual

Serialize the message.

Returns
The string representation of the message.

Implements flyby::SerialObject.

◆ set_payload()

void flyby::Message::set_payload ( const std::string & payload)

Set the payload of the message.

Parameters
payload- The actual message payload, either object or string.

◆ set_source()

void flyby::Message::set_source ( const std::string & source)

Set the source of the message.

Parameters
source- the name of the source application or unit.

◆ set_type()

void flyby::Message::set_type ( MessageType type)

Set the type of the message.

Parameters
type- The message type, such as object or text.

◆ set_version()

void flyby::Message::set_version ( const std::string & version)

Set the version of the message protocol.

Parameters
version- the message protocol version.

The documentation for this class was generated from the following file: