libircpp
Version: 0.0.1
 All Classes Namespaces Functions Variables Enumerations Enumerator Pages
irc::connection Class Reference

#include <irc/connection.hpp>

Inherits enable_shared_from_this< connection >.

Detailed Description

IRC connection class.

Public Member Functions

template<typename F >
bsig::connection connect_on_resolve (F &&f)
 Connect to the on_resolve signal. More...
 
template<typename F >
bsig::connection connect_on_connect (F &&f)
 Connect to the on_connect signal. More...
 
template<typename F >
bsig::connection connect_on_read_msg (F &&f)
 Connect to the on_read_msg signal. More...
 
template<typename F >
bsig::connection connect_on_network_error (F &&f)
 Connect to the on_network_error signal. More...
 
 connection (boost::asio::io_service &io_service, std::string host, std::string service)
 Constructor. More...
 
void stop ()
 Disconnects from IRC server. More...
 
void async_read ()
 Requests an asynchronous buffer read from the socket. More...
 
void async_write (std::string str)
 Requests an asynchronous buffer write to the socket. More...
 

Static Public Member Functions

static std::shared_ptr
< connection
make_shared (boost::asio::io_service &io_service, std::string host, std::string service)
 Static constructor. More...
 

Constructor & Destructor Documentation

irc::connection::connection ( boost::asio::io_service &  io_service,
std::string  host,
std::string  service 
)

Constructor.

Parameters
io_serviceA reference to the ASIO io_service.
hostAn hostname to connect to.
serviceThe connection port as string.

Member Function Documentation

void irc::connection::async_read ( )

Requests an asynchronous buffer read from the socket.

void irc::connection::async_write ( std::string  str)

Requests an asynchronous buffer write to the socket.

Parameters
strData to push back to the write buffer.
template<typename F >
bsig::connection irc::connection::connect_on_connect ( F &&  f)

Connect to the on_connect signal.

This signal is triggered when connected to an IRC server.

Parameters
fA callback function with the following signature:
void f()
Returns
The connection object to disconnect from the signal.
template<typename F >
bsig::connection irc::connection::connect_on_network_error ( F &&  f)

Connect to the on_network_error signal.

This signal is triggered when there was a connection error.

Parameters
fA callback function with the following signature:
void f(const std::string& error_msg)
Returns
The connection object to disconnect from the signal.
template<typename F >
bsig::connection irc::connection::connect_on_read_msg ( F &&  f)

Connect to the on_read_msg signal.

This signal is triggered when an IRC server message was read.

Parameters
fA callback function with the following signature:
void f(const std::string& msg)
Returns
The connection object to disconnect from the signal.
template<typename F >
bsig::connection irc::connection::connect_on_resolve ( F &&  f)

Connect to the on_resolve signal.

This signal is triggered when IRC server names was resolved.

Parameters
fA callback function with the following signature:
void f()
Returns
The connection object to disconnect from the signal.
static std::shared_ptr<connection> irc::connection::make_shared ( boost::asio::io_service &  io_service,
std::string  host,
std::string  service 
)
static

Static constructor.

Parameters
io_serviceA reference to the ASIO io_service.
hostAn hostname to connect to.
serviceThe connection port as string.
Returns
A shared_ptr to the created connection.
void irc::connection::stop ( )

Disconnects from IRC server.