irccd  3.0.3
Public Types | Public Member Functions | List of all members
irccd::daemon::irc::connection Class Reference

Abstract connection to a server. More...

#include <irc.hpp>

Public Types

using connect_handler = std::function< void(std::error_code)>
 
using recv_handler = std::function< void(std::error_code, message)>
 
using send_handler = std::function< void(std::error_code)>
 

Public Member Functions

 connection (boost::asio::io_service &service)
 
virtual ~connection ()=default
 
void use_ipv4 (bool enable=true) noexcept
 
void use_ipv6 (bool enable=true) noexcept
 
void use_ssl (bool enable=true) noexcept
 
void connect (std::string_view hostname, std::string_view service, connect_handler handler)
 
void disconnect ()
 
void recv (recv_handler handler)
 
void send (std::string_view message, send_handler handler)
 

Detailed Description

Abstract connection to a server.

Member Typedef Documentation

◆ connect_handler

using irccd::daemon::irc::connection::connect_handler = std::function<void (std::error_code)>

Handler for connecting.

◆ recv_handler

using irccd::daemon::irc::connection::recv_handler = std::function<void (std::error_code, message)>

Handler for receiving.

◆ send_handler

using irccd::daemon::irc::connection::send_handler = std::function<void (std::error_code)>

Handler for sending.

Constructor & Destructor Documentation

◆ connection()

irccd::daemon::irc::connection::connection ( boost::asio::io_service &  service)

Default constructor.

Parameters
servicethe I/O service

◆ ~connection()

virtual irccd::daemon::irc::connection::~connection ( )
virtualdefault

Virtual destructor defaulted.

Member Function Documentation

◆ connect()

void irccd::daemon::irc::connection::connect ( std::string_view  hostname,
std::string_view  service,
connect_handler  handler 
)

Connect to the host.

Precondition
handler the handler
another connect operation must not be running
ipv4 or ipv6 must be set
Parameters
hostnamethe hostname
servicethe service or port number
handlerthe non-null handler

◆ disconnect()

void irccd::daemon::irc::connection::disconnect ( )

Force disconnection.

◆ recv()

void irccd::daemon::irc::connection::recv ( recv_handler  handler)

Start receiving data.

The handler must not throw exceptions and this must be valid in the lifetime of the handler.

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

◆ send()

void irccd::daemon::irc::connection::send ( std::string_view  message,
send_handler  handler 
)

Start sending data.

The handler must not throw exceptions and this must be valid in the lifetime of the handler.

Precondition
another send operation must not be running
handler != nullptr
Parameters
messagethe raw message
handlerthe handler to call

◆ use_ipv4()

void irccd::daemon::irc::connection::use_ipv4 ( bool  enable = true)
noexcept

Enable IPv4

Parameters
enabletrue to enable

◆ use_ipv6()

void irccd::daemon::irc::connection::use_ipv6 ( bool  enable = true)
noexcept

Enable IPv6

Parameters
enabletrue to enable

◆ use_ssl()

void irccd::daemon::irc::connection::use_ssl ( bool  enable = true)
noexcept

Enable TLS.

Precondition
IRCCD_HAVE_SSL must be defined
Parameters
enabletrue to enable

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