irccd
3.0.3
|
Main irccdctl interface. More...
#include <controller.hpp>
Public Types | |
using | connect_handler = std::function< void(std::error_code, nlohmann::json)> |
Public Member Functions | |
controller (std::unique_ptr< connector > connector) noexcept | |
auto | get_password () const noexcept -> const std::string & |
void | set_password (std::string password) noexcept |
void | connect (connect_handler handler) |
void | recv (stream::recv_handler handler) |
void | send (nlohmann::json message, stream::send_handler handler) |
Main irccdctl interface.
This class is an easy frontend to issue commands to irccd, it uses an independant connection to perform the requests.
This class is responsible of doing initial connection, performing checks and optional authentication.
It is implemented in mind that connection are asynchronous even though this is not necessary.
using irccd::ctl::controller::connect_handler = std::function<void (std::error_code, nlohmann::json)> |
Connection completion handler.
This callback is called when connection has been completed or failed. In both case, the error code is set and the JSON object may contain the * irccd program information.
|
noexcept |
Construct the controller with its connection.
connector | the abstract connector |
void irccd::ctl::controller::connect | ( | connect_handler | handler | ) |
Attempt to connect to the irccd daemon.
handler | the handler |
|
noexcept |
Get the optional password set.
void irccd::ctl::controller::recv | ( | stream::recv_handler | handler | ) |
Request a message.
handler | the recv handler |
void irccd::ctl::controller::send | ( | nlohmann::json | message, |
stream::send_handler | handler | ||
) |
Send a message.
message | the JSON message |
handler | the optional completion handler |
|
noexcept |
Set an optional password.
An empty password means no authentication (default).
password | the password |