Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes

asio_listener Class Reference

#include <asio_listener.hpp>

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

List of all members.

Public Member Functions

 asio_listener ()
virtual void set_listener_handler (ana::listener_handler *listener)
 Sets the handler for incoming messages.
virtual void run_listener ()
 Start listening for incoming messages.
virtual ~asio_listener ()

Protected Member Functions

virtual tcp::socket & socket ()=0
void wait_for_incoming_message (size_t ms_to_timeout, ana::net_id id=0)

Private Member Functions

virtual void disconnect_listener ()
virtual void set_raw_buffer_max_size (size_t size)
 Sets the size of raw buffer.
virtual void wait_raw_object (ana::serializer::bistream &bis, size_t size)
 Block the caller waiting for an incoming message of a certain amount of bytes.
void listen_one_message ()
void disconnect (boost::system::error_code error)
void handle_header (char *header, const boost::system::error_code &)
void handle_body (ana::read_buffer, const boost::system::error_code &)
void handle_partial_body (ana::read_buffer, const boost::system::error_code &, size_t accumulated, size_t last_msg_size)
void handle_timeout (const boost::system::error_code &, ana::net_id)
void handle_raw_buffer (ana::read_buffer, const boost::system::error_code &, size_t)

Private Attributes

bool disconnected_
ana::listener_handlerlistener_
char header_ [ana::HEADER_LENGTH]
size_t raw_mode_buffer_size_
ana::timernext_message_timer_

Detailed Description

Definition at line 43 of file asio_listener.hpp.


Constructor & Destructor Documentation

asio_listener::asio_listener (  ) 

Definition at line 40 of file asio_listener.cpp.

asio_listener::~asio_listener (  )  [virtual]

Definition at line 49 of file asio_listener.cpp.

References next_message_timer_.


Member Function Documentation

void asio_listener::disconnect ( boost::system::error_code  error  )  [private]

Definition at line 66 of file asio_listener.cpp.

References disconnect_listener(), disconnected_, ana::listener_handler::handle_disconnect(), and listener_.

Here is the call graph for this function:

virtual void asio_listener::disconnect_listener (  )  [inline, private, virtual]

Definition at line 59 of file asio_listener.hpp.

Referenced by disconnect().

Here is the caller graph for this function:

void asio_listener::handle_body ( ana::read_buffer  buf,
const boost::system::error_code &  ec 
) [private]
void asio_listener::handle_header ( char *  header,
const boost::system::error_code &  ec 
) [private]
void asio_listener::handle_partial_body ( ana::read_buffer  buffer,
const boost::system::error_code &  ec,
size_t  accumulated,
size_t  last_msg_size 
) [private]

Definition at line 148 of file asio_listener.cpp.

References ana::buffer(), ana::detail::ana_component::disconnect(), error(), ana::listener_handler::handle_receive(), listen_one_message(), listener_, next_message_timer_, socket(), and ana::detail::ana_component::stats_collector().

Referenced by handle_header().

Here is the call graph for this function:

Here is the caller graph for this function:

void asio_listener::handle_raw_buffer ( ana::read_buffer  buf,
const boost::system::error_code &  ec,
size_t  read_size 
) [private]

Definition at line 199 of file asio_listener.cpp.

References ana::detail::ana_component::disconnect(), ana::listener_handler::handle_receive(), listen_one_message(), listener_, next_message_timer_, and ana::detail::ana_component::stats_collector().

Referenced by listen_one_message().

Here is the call graph for this function:

Here is the caller graph for this function:

void asio_listener::handle_timeout ( const boost::system::error_code &  error_code,
ana::net_id  id 
) [private]

Definition at line 190 of file asio_listener.cpp.

References ana::listener_handler::handle_receive(), listener_, next_message_timer_, ana::operation_aborted, and ana::timeout_error.

Referenced by wait_for_incoming_message().

Here is the call graph for this function:

Here is the caller graph for this function:

void asio_listener::listen_one_message (  )  [private]
void asio_listener::run_listener (  )  [virtual]

Start listening for incoming messages.

Implements ana::detail::listener.

Definition at line 246 of file asio_listener.cpp.

References listen_one_message().

Referenced by asio_client::handle_connect(), and asio_client::handle_proxy_connection().

Here is the call graph for this function:

Here is the caller graph for this function:

void asio_listener::set_listener_handler ( ana::listener_handler listener  )  [virtual]

Sets the handler for incoming messages.

Parameters:
listener : Pointer to the listener_handler object that will handle following incoming message events.
See also:
listener_handler

Implements ana::detail::listener.

Definition at line 241 of file asio_listener.cpp.

References listener_.

void asio_listener::set_raw_buffer_max_size ( size_t  size  )  [private, virtual]

Sets the size of raw buffer.

Parameters:
size : The requested size for raw buffers.
Precondition:
: Parameter should be positive.

Implements ana::detail::listener.

Definition at line 76 of file asio_listener.cpp.

References raw_mode_buffer_size_.

virtual tcp::socket& asio_listener::socket (  )  [protected, pure virtual]

Referenced by handle_header(), handle_partial_body(), listen_one_message(), wait_for_incoming_message(), and wait_raw_object().

Here is the caller graph for this function:

void asio_listener::wait_for_incoming_message ( size_t  ms_to_timeout,
ana::net_id  id = 0 
) [protected]

Definition at line 54 of file asio_listener.cpp.

References error(), handle_timeout(), next_message_timer_, socket(), and ana::timer::wait().

Referenced by asio_server::asio_client_proxy::expecting_message(), and asio_client::expecting_message().

Here is the call graph for this function:

Here is the caller graph for this function:

void asio_listener::wait_raw_object ( ana::serializer::bistream bis,
size_t  size 
) [private, virtual]

Block the caller waiting for an incoming message of a certain amount of bytes.

Parameters:
bis : Binary stream where the data will be stored.
size : The amount of bytes trying to be read.

Implements ana::detail::listener.

Definition at line 224 of file asio_listener.cpp.

References ana::buffer(), socket(), and ana::serializer::bistream::str().

Here is the call graph for this function:


Member Data Documentation

Definition at line 83 of file asio_listener.hpp.

Referenced by disconnect().

Definition at line 85 of file asio_listener.hpp.

Referenced by listen_one_message().

Definition at line 86 of file asio_listener.hpp.

Referenced by listen_one_message(), and set_raw_buffer_max_size().


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:59 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs