irccd  3.0.3
Public Types | Public Member Functions | List of all members
irccd::ctl::controller Class Reference

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)
 

Detailed Description

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.

Member Typedef Documentation

◆ connect_handler

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.

Constructor & Destructor Documentation

◆ controller()

irccd::ctl::controller::controller ( std::unique_ptr< connector connector)
noexcept

Construct the controller with its connection.

Precondition
connector != nullptr
Note
no connect attempt is done
Parameters
connectorthe abstract connector

Member Function Documentation

◆ connect()

void irccd::ctl::controller::connect ( connect_handler  handler)

Attempt to connect to the irccd daemon.

Precondition
another connect operation must not be running
handler != nullptr
Parameters
handlerthe handler

◆ get_password()

auto irccd::ctl::controller::get_password ( ) const -> const std::string &
noexcept

Get the optional password set.

Returns
the password

◆ recv()

void irccd::ctl::controller::recv ( stream::recv_handler  handler)

Request a message.

Precondition
another recv operation must not be running
handler != nullptr
Parameters
handlerthe recv handler

◆ send()

void irccd::ctl::controller::send ( nlohmann::json  message,
stream::send_handler  handler 
)

Send a message.

Precondition
another send operation must not be running
message.is_object()
handler != nullptr
Parameters
messagethe JSON message
handlerthe optional completion handler

◆ set_password()

void irccd::ctl::controller::set_password ( std::string  password)
noexcept

Set an optional password.

An empty password means no authentication (default).

Parameters
passwordthe password
Note
this must be called before connect

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