A network client. More...
#include <ana.hpp>


Public Member Functions | |
| virtual void | connect (connection_handler *)=0 |
| Attempt a connection to the server. | |
| virtual void | connect_through_proxy (std::string proxy_address, std::string proxy_port, connection_handler *handler, std::string user_name="", std::string password="")=0 |
| Attempt a connection to the server through a proxy. | |
| virtual void | run ()=0 |
| Run the client listener, starts listening for incoming messages. | |
| virtual operation_id | send (boost::asio::const_buffer buffer, send_handler *handler, send_type type=COPY_BUFFER)=0 |
| Send a buffer or memory portion to the server. | |
| virtual void | cancel_pending ()=0 |
| Cancel all pending network operations. | |
| virtual void | expecting_message (size_t ms_until_timeout)=0 |
| Signal the client that you are waiting for a message from the server before a given time. | |
| virtual void | set_connect_timeout (size_t ms)=0 |
| Set a timeout value for connection attempts. | |
| virtual std::string | ip_address () const =0 |
| Returns the string representing the ip address of the connected client. | |
| virtual | ~client () |
| Standard destructor. | |
Static Public Member Functions | |
| static client * | create (address address, port port) |
| Creates a client. | |
A network client.
Definition at line 626 of file ana.hpp.
| virtual ana::client::~client | ( | ) | [inline, virtual] |
| virtual void ana::client::cancel_pending | ( | ) | [pure virtual] |
Cancel all pending network operations.
Every pending operation handler will be invoked with ana::operation_aborted as the corresponding error_code, except that the error code will be boost::asio::error::operation_not_supported when run on Windows XP, Windows Server 2003, and earlier versions of Windows, unless BOOST_ASIO_ENABLE_CANCELIO is defined.
| virtual void ana::client::connect | ( | connection_handler * | ) | [pure virtual] |
Attempt a connection to the server.
| handler | : The handler of the connection event. |
Referenced by ana_network_manager::create_client_and_connect().

| virtual void ana::client::connect_through_proxy | ( | std::string | proxy_address, | |
| std::string | proxy_port, | |||
| connection_handler * | handler, | |||
| std::string | user_name = "", |
|||
| std::string | password = "" | |||
| ) | [pure virtual] |
Attempt a connection to the server through a proxy.
| handler | : The handler of the connection event. |
Referenced by ana_network_manager::create_client_and_connect().

| ana::client * ana::client::create | ( | ana::address | address, | |
| ana::port | pt | |||
| ) | [static] |
Creates a client.
| address | : The network address of the server. | |
| port | : The network port of the server. |
Definition at line 77 of file asio_client.cpp.
| virtual void ana::client::expecting_message | ( | size_t | ms_until_timeout | ) | [pure virtual] |
Signal the client that you are waiting for a message from the server before a given time.
The time parameter indicates how long you are willing to wait.
If a message is received before this time period then this call will be insignificant. However, if no such message is received, the appropriate call to handle_receive will be made with ana::timeout_error as the error_code parameter.
Use the methods described in the ana::time namespace to create time lapses.
Examples:
| virtual std::string ana::client::ip_address | ( | ) | const [pure virtual] |
Returns the string representing the ip address of the connected client.
| virtual void ana::client::run | ( | ) | [pure virtual] |
Run the client listener, starts listening for incoming messages.
Each time you call this method, a new thread will be started on the io_service object from asio. This means that it is possible to have multiple threads running the service, thus more threads will be able to run the handlers you implement.
The drawback is, however, that if you run the service on multiple threads, then you must be aware that the execution of your handlers may occur concurrently and thus you have to prevent all of the troubles arising from this concurrency.
Note that if you just call this method once, then you ensure mutual exclusion between your handlers, just make sure you don't block waiting for a call to a handler from one of your handlers, otherwise you'll always get a deadlock.
Referenced by ana_network_manager::create_client_and_connect().

| virtual operation_id ana::client::send | ( | boost::asio::const_buffer | buffer, | |
| send_handler * | handler, | |||
| send_type | type = COPY_BUFFER | |||
| ) | [pure virtual] |
Send a buffer or memory portion to the server.
Examples:
| buffer | : The buffer being sent. | |
| handler | : Handler of events resulting from this operation. | |
| send_type | : Optional, type of the send operation. Defaults to COPY_BUFFER. |
Referenced by ana_network_manager::create_client_and_connect().

| virtual void ana::client::set_connect_timeout | ( | size_t | ms | ) | [pure virtual] |
Set a timeout value for connection attempts.
If attempting to connect through a proxy this value will be used once for the whole connection attempt.
You should use the time lapse constructors in namespace ana::time:
Referenced by ana_network_manager::create_client_and_connect().

| Generated by doxygen 1.7.1 on Fri May 25 2012 01:18:01 for The Battle for Wesnoth | Gna! | Forum | Wiki | CIA | devdocs |