Node¶
-
class Node¶
Node interface.
A node is the base of all communications in Melo: it is the interface used by every parts of the application to send / receive requests and events.
The request and event handlers are directly implemented by the derived class while the send functions and address are provided by a Node::Implem.
Subclassed by melo::Browser, melo::Settings
Public Functions
-
inline const node::Address &get_address() const¶
Get node address.
- Returns:
the address of the current node.
Handle request.
This function will be called when a new request is received on the node.
If
falseis returned, the request will be aborted by the Node implementation, otherwise, the developer is responsible to complete or abort the request at some time.- Parameters:
req – [in] The received request
- Returns:
trueif the request is in progress or has been processed,falseotherwise.
Handle event.
This function will be called when a new event message is received on the node.
- Parameters:
msg – [in] The received event message
-
class Implem¶
Node implementation.
This class will provide the functions to send a request and an event to the rest of the application. It also holds the address of the node within the application.
The handler for requests and events are directly implemented by the Node itself.
Public Functions
-
inline const node::Address &get_address() const¶
Get node address.
- Returns:
the address of the current node.
Send a request to another node.
This function is used to send a request to another node and it is called by the Node::send_request() function.
Note
The request source is already checked by Node::send_request().
- Parameters:
req – [in] The request to send
- Returns:
trueif the request has been sent,falseotherwise.
Send an event.
This function is used to broadcast an event to other nodes and it is called by the Node::send_event() function.
Note
The message type and source is already checked by Node::send_event().
- Parameters:
msg – [in] The event message to broadcast
-
inline const node::Address &get_address() const¶
-
inline const node::Address &get_address() const¶
-
enum class melo::node::Type : std::uint8_t¶
Node type.
Please read the Protobuf documentation for more details.
Values:
-
enumerator kInvalid¶
Invalid node type.
-
enumerator kEvent¶
Event node.
-
enumerator kSDK¶
SDK node.
-
enumerator kPlugin¶
Plugin node.
-
enumerator kSettings¶
Settings node.
-
enumerator kBrowser¶
Browser node.
-
enumerator kPlayer¶
Player node.
-
enumerator kPlayerQueue¶
Player Queue node.
-
enumerator kPlaylist¶
Playlist node.
-
enumerator kInvalid¶
-
class Address¶
Address structure.
Public Functions
-
inline Address()¶
Create an invalid address.
-
inline explicit Address(Type type, std::string id = "")¶
Create a new address.
- Parameters:
type – [in] The type of the node
id – [in] The ID of the node
-
inline explicit Address(std::string addr)¶
Create an address from a string.
- Parameters:
addr – [in] The address string to use
-
Address(const Address &addr) = default¶
Copy an address.
- Parameters:
addr – [in] The address to copy
-
Address &operator=(const Address &addr) = default¶
Assign an address by copy.
- Parameters:
addr – [in] The address to move
-
inline Address &operator=(Address &&addr)¶
Assign an address by move.
- Parameters:
addr – [in] The address to move
-
inline const std::string_view get_id() const¶
Get node ID.
- Returns:
the ID of the current node.
-
inline const std::string &to_string() const¶
Get node address.
- Returns:
the address of the current node.
-
inline std::string to_print() const¶
Get node address as a printable string.
- Returns:
the address of the current node.
-
inline Address()¶