Public Member Functions | Private Member Functions | Private Attributes

asio_client Class Reference

#include <asio_client.hpp>

Inheritance diagram for asio_client:
Inheritance graph
[legend]
Collaboration diagram for asio_client:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 asio_client (std::string address, ana::port port)
 Standard constructor.
virtual ~asio_client ()

Private Member Functions

virtual void connect (ana::connection_handler *)
virtual void connect_through_proxy (std::string proxy_address, std::string proxy_port, ana::connection_handler *handler, std::string user_name="", std::string password="")
virtual void run ()
virtual ana::operation_id send (boost::asio::const_buffer, ana::send_handler *, ana::send_type)
virtual void disconnect ()
 Disconnect the component.
virtual void disconnect_listener ()
virtual void handle_proxy_connection (const boost::system::error_code &, ana::connection_handler *, ana::timer *)
virtual tcp::socket & socket ()
virtual void log_receive (ana::read_buffer buffer)
virtual const ana::statsget_stats (ana::stat_type type) const
virtual ana::stats_collector & stats_collector ()
 Get associated stats_collector object.
virtual ana::timercreate_timer ()
virtual void cancel_pending ()
virtual void set_connect_timeout (size_t ms)
virtual void expecting_message (size_t ms_until_timeout)
virtual std::string ip_address () const
void handle_connect (const boost::system::error_code &ec, tcp::resolver::iterator endpoint_iterator, ana::connection_handler *, ana::timer *)
void inform_connection_result (ana::connection_handler *, ana::error_code)
void handle_timeout (const boost::system::error_code &ec, ana::connection_handler *, ana::timer *)
ana::timerstart_connection_timer (ana::connection_handler *)
 asio_client (const asio_client &other)
asio_clientoperator= (const asio_client &other)

Private Attributes

boost::asio::io_service io_service_
std::list< boost::thread * > io_threads_
boost::asio::io_service::work work_
tcp::socket socket_
std::string address_
ana::port port_
size_t connect_timeout_ms_
proxy_connectionproxy_
bool use_proxy_
ana::stats_collector stats_collector_
ana::operation_id last_valid_operation_id_
boost::mutex connection_informed_mutex_
bool connection_informed_

Detailed Description

Definition at line 50 of file asio_client.hpp.


Constructor & Destructor Documentation

asio_client::asio_client ( std::string  address,
ana::port  port 
)

Standard constructor.

Parameters:
address : Address to try to connect to. The server should be there.
port : port to use for the connection. The server should have opened it.

Definition at line 44 of file asio_client.cpp.

asio_client::~asio_client (  )  [virtual]

Definition at line 62 of file asio_client.cpp.

References disconnect_listener(), and io_threads_.

Here is the call graph for this function:

asio_client::asio_client ( const asio_client other  )  [private]

Member Function Documentation

void asio_client::cancel_pending (  )  [private, virtual]

Definition at line 257 of file asio_client.cpp.

References socket_.

Referenced by handle_timeout().

Here is the caller graph for this function:

void asio_client::connect ( ana::connection_handler handler  )  [private, virtual]

Definition at line 183 of file asio_client.cpp.

References address_, error(), ana::generic_error, handle_connect(), inform_connection_result(), io_service_, port_, socket_, and start_connection_timer().

Here is the call graph for this function:

void asio_client::connect_through_proxy ( std::string  proxy_address,
std::string  proxy_port,
ana::connection_handler handler,
std::string  user_name = "",
std::string  password = "" 
) [private, virtual]
virtual ana::timer* asio_client::create_timer (  )  [inline, private, virtual]

Definition at line 98 of file asio_client.hpp.

References io_service_.

virtual void asio_client::disconnect (  )  [inline, private, virtual]

Disconnect the component.

Implements ana::detail::ana_component.

Definition at line 82 of file asio_client.hpp.

References disconnect_listener().

Here is the call graph for this function:

void asio_client::disconnect_listener (  )  [private, virtual]

Definition at line 277 of file asio_client.cpp.

References io_service_.

Referenced by disconnect(), and ~asio_client().

Here is the caller graph for this function:

void asio_client::expecting_message ( size_t  ms_until_timeout  )  [private, virtual]

Definition at line 267 of file asio_client.cpp.

References asio_listener::wait_for_incoming_message().

Here is the call graph for this function:

const ana::stats * asio_client::get_stats ( ana::stat_type  type  )  const [private, virtual]

Definition at line 247 of file asio_client.cpp.

References stats_collector_.

void asio_client::handle_connect ( const boost::system::error_code &  ec,
tcp::resolver::iterator  endpoint_iterator,
ana::connection_handler handler,
ana::timer timer 
) [private]

Definition at line 107 of file asio_client.cpp.

References error(), ana::detail::ana_component::header_mode(), inform_connection_result(), asio_listener::run_listener(), and socket_.

Referenced by connect().

Here is the call graph for this function:

Here is the caller graph for this function:

void asio_client::handle_proxy_connection ( const boost::system::error_code &  ec,
ana::connection_handler handler,
ana::timer timer 
) [private, virtual]

Definition at line 88 of file asio_client.cpp.

References ana::detail::ana_component::header_mode(), inform_connection_result(), proxy_, and asio_listener::run_listener().

Here is the call graph for this function:

void asio_client::handle_timeout ( const boost::system::error_code &  ec,
ana::connection_handler handler,
ana::timer timer 
) [private]

Definition at line 150 of file asio_client.cpp.

References cancel_pending(), inform_connection_result(), and ana::operation_aborted.

Referenced by start_connection_timer().

Here is the call graph for this function:

Here is the caller graph for this function:

void asio_client::inform_connection_result ( ana::connection_handler handler,
ana::error_code  ec 
) [private]

Definition at line 139 of file asio_client.cpp.

References connection_informed_, connection_informed_mutex_, and ana::connection_handler::handle_connect().

Referenced by connect(), handle_connect(), handle_proxy_connection(), and handle_timeout().

Here is the call graph for this function:

Here is the caller graph for this function:

std::string asio_client::ip_address (  )  const [private, virtual]

Definition at line 272 of file asio_client.cpp.

References socket_.

void asio_client::log_receive ( ana::read_buffer  buffer  )  [private, virtual]

Definition at line 242 of file asio_client.cpp.

References stats_collector_.

asio_client& asio_client::operator= ( const asio_client other  )  [private]
void asio_client::run (  )  [private, virtual]

Definition at line 82 of file asio_client.cpp.

References io_service_, and io_threads_.

ana::operation_id asio_client::send ( boost::asio::const_buffer  buffer,
ana::send_handler handler,
ana::send_type  copy_buffer 
) [private, virtual]

Definition at line 227 of file asio_client.cpp.

References last_valid_operation_id_, and socket_.

void asio_client::set_connect_timeout ( size_t  ms  )  [private, virtual]

Definition at line 262 of file asio_client.cpp.

References connect_timeout_ms_.

tcp::socket & asio_client::socket (  )  [private, virtual]

Definition at line 102 of file asio_client.cpp.

References socket_.

ana::timer * asio_client::start_connection_timer ( ana::connection_handler handler  )  [private]

Definition at line 163 of file asio_client.cpp.

References connect_timeout_ms_, ana::detail::timed_sender::create_timer(), error(), handle_timeout(), and ana::timer::wait().

Referenced by connect(), and connect_through_proxy().

Here is the call graph for this function:

Here is the caller graph for this function:

ana::stats_collector & asio_client::stats_collector (  )  [private, virtual]

Get associated stats_collector object.

Returns:
A pointer to the associated stats_collector object, NULL if not keeping stats.
See also:
stats_collector.

Implements ana::detail::ana_component.

Definition at line 252 of file asio_client.cpp.

References stats_collector_.


Member Data Documentation

std::string asio_client::address_ [private]

Definition at line 132 of file asio_client.hpp.

Referenced by connect(), and connect_through_proxy().

Definition at line 135 of file asio_client.hpp.

Referenced by set_connect_timeout(), and start_connection_timer().

Definition at line 144 of file asio_client.hpp.

Referenced by inform_connection_result().

Definition at line 143 of file asio_client.hpp.

Referenced by inform_connection_result().

boost::asio::io_service asio_client::io_service_ [private]

Definition at line 126 of file asio_client.hpp.

Referenced by connect(), create_timer(), disconnect_listener(), and run().

std::list<boost::thread*> asio_client::io_threads_ [private]

Definition at line 127 of file asio_client.hpp.

Referenced by run(), and ~asio_client().

Definition at line 141 of file asio_client.hpp.

Referenced by send().

Definition at line 133 of file asio_client.hpp.

Referenced by connect(), and connect_through_proxy().

Definition at line 137 of file asio_client.hpp.

Referenced by connect_through_proxy(), and handle_proxy_connection().

tcp::socket asio_client::socket_ [private]
ana::stats_collector asio_client::stats_collector_ [private]

Definition at line 140 of file asio_client.hpp.

Referenced by get_stats(), log_receive(), and stats_collector().

bool asio_client::use_proxy_ [private]

Definition at line 138 of file asio_client.hpp.

Referenced by connect_through_proxy().

boost::asio::io_service::work asio_client::work_ [private]

Definition at line 128 of file asio_client.hpp.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated by doxygen 1.7.1 on Thu May 24 2012 01:12:57 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs