pairpal
|
Class representing a message with a type and content. More...
#include <network_message.hpp>
Public Member Functions | |
NetworkMessage (const NetworkMessageType &type) | |
Constructs a NetworkMessage with a specified type. | |
NetworkMessage (const std::string &str) | |
Constructs a NetworkMessage from a string. | |
~NetworkMessage () | |
Destructor for the NetworkMessage class. | |
auto | getType () const -> NetworkMessageType |
Gets the type of the message. | |
auto | toJson () const -> nlohmann::json |
Converts the message to a JSON object. | |
auto | toString () const -> std::string |
Converts the message to a string. | |
auto | toZmqMessage () const -> std::unique_ptr< zmq::message_t > |
Converts the message to a ZMQ message. | |
void | setUsername (const std::string &username) |
Sets the username associated with the message. | |
auto | getUsername () const -> std::string |
Gets the username associated with the message. | |
void | setPassword (const std::string &password) |
Sets the password associated with the message. | |
auto | getPassword () const -> std::string |
Gets the password associated with the message. | |
void | setTag (const std::string &tag) |
Sets the tag associated with the message. | |
auto | getTag () const -> std::string |
Gets the tag associated with the message. | |
void | setFrom (const std::string &from) |
Sets the sender of the message. | |
auto | getFrom () const -> std::string |
Gets the sender of the message. | |
void | setTo (const std::string &to) |
Sets the recipient of the message. | |
auto | getTo () const -> std::string |
Gets the recipient of the message. | |
void | setMessage (const std::string &message) |
Sets the message content. | |
auto | getMessage () const -> std::string |
Gets the message content. | |
void | setVector (const std::vector< std::string > &vector) |
Sets a vector of strings associated with the message. | |
auto | getVector () const -> std::vector< std::string > |
Gets the vector of strings associated with the message. | |
Class representing a message with a type and content.
|
explicit |
Constructs a NetworkMessage with a specified type.
type | The type of the message. |
|
explicit |
Constructs a NetworkMessage from a string.
str | The string containing the message data. |
|
nodiscard |
Gets the sender of the message.
|
nodiscard |
Gets the message content.
|
nodiscard |
Gets the password associated with the message.
|
nodiscard |
Gets the tag associated with the message.
|
nodiscard |
Gets the recipient of the message.
|
nodiscard |
Gets the type of the message.
|
nodiscard |
Gets the username associated with the message.
|
nodiscard |
Gets the vector of strings associated with the message.
void NetworkMessage::setFrom | ( | const std::string & | from | ) |
Sets the sender of the message.
from | The sender to set. |
void NetworkMessage::setMessage | ( | const std::string & | message | ) |
Sets the message content.
message | The message content to set. |
void NetworkMessage::setPassword | ( | const std::string & | password | ) |
Sets the password associated with the message.
password | The password to set. |
void NetworkMessage::setTag | ( | const std::string & | tag | ) |
Sets the tag associated with the message.
tag | The tag to set. |
void NetworkMessage::setTo | ( | const std::string & | to | ) |
Sets the recipient of the message.
to | The recipient to set. |
void NetworkMessage::setUsername | ( | const std::string & | username | ) |
Sets the username associated with the message.
username | The username to set. |
void NetworkMessage::setVector | ( | const std::vector< std::string > & | vector | ) |
Sets a vector of strings associated with the message.
vector | The vector of strings to set. |
|
nodiscard |
Converts the message to a JSON object.
|
nodiscard |
Converts the message to a string.
|
nodiscard |
Converts the message to a ZMQ message.