Ejemplo n.º 1
0
void xdccd::IRCConnection::on_resolved(const boost::system::error_code& err, boost::asio::ip::tcp::resolver::iterator endpoint_iterator)
{
    decltype(endpoint_iterator) end;
    boost::system::error_code error = boost::asio::error::host_not_found;

    if (err)
    {
        BOOST_LOG_TRIVIAL(error) << "Error resolving " << host << ": " << err.message();
        start_reconnect_timer();
        return;
    }

    while (endpoint_iterator != end)
    {
        if (!error)
            break;

        socket->close();
        BOOST_LOG_TRIVIAL(info) << "Trying to connect to " << host << ":" << port << " (" << (*endpoint_iterator).endpoint().address().to_string() << ") ...";
        socket->connect(*endpoint_iterator++, error);
    }

    if (error)
    {
        BOOST_LOG_TRIVIAL(error) << "Error connecting to " << host << ": " << error.message();
        start_reconnect_timer();
        return;
    }

    // Inform the bot about the successful connection
    connected_handler();

    state = connection::CONNECTED;

    // Start the async read loop
    socket->async_read_until(
            msg_buffer,
            "\r\n",
            boost::bind(&IRCConnection::read, this,
                boost::asio::placeholders::error,
                boost::asio::placeholders::bytes_transferred)
    );
}
Ejemplo n.º 2
0
/** Calls client connected handler. */
void unicomm::session_base::signal_connected(const connected_params& params)
{
  connected_handler(params);
}