void i2p_connection::async_name_lookup(char const* name , i2p_connection::name_lookup_handler handler) { if (m_state == sam_idle && m_name_lookup.empty() && is_open()) do_name_lookup(name, handler); else m_name_lookup.push_back(std::make_pair(std::string(name), handler)); }
void i2p_connection::on_sam_connect(error_code const& ec, i2p_stream::handler_type const& h, boost::shared_ptr<i2p_stream>) { COMPLETE_ASYNC("i2p_stream::on_sam_connect"); m_state = sam_idle; if (ec) { h(ec); return; } do_name_lookup("ME", boost::bind(&i2p_connection::set_local_endpoint, this, _1, _2, h)); }
void i2p_connection::on_sam_connect(error_code const& ec, i2p_stream::handler_type const& h, boost::shared_ptr<i2p_stream>) { #if defined TORRENT_ASIO_DEBUGGING complete_async("i2p_stream::on_sam_connect"); #endif m_state = sam_idle; if (ec) { h(ec); return; } do_name_lookup("ME", boost::bind(&i2p_connection::set_local_endpoint, this, _1, _2, h)); }
void i2p_connection::on_name_lookup(error_code const& ec , name_lookup_handler handler, boost::shared_ptr<i2p_stream>) { m_state = sam_idle; std::string name = m_sam_socket->name_lookup(); if (!m_name_lookup.empty()) { std::pair<std::string, name_lookup_handler>& nl = m_name_lookup.front(); do_name_lookup(nl.first, nl.second); m_name_lookup.pop_front(); } if (ec) { handler(ec, 0); return; } handler(ec, name.c_str()); }