A class that represents a TCP/IP connection to the wesnothd server. More...
#include <wesnothd_connection.hpp>
Public Types | |
using | error = wesnothd_connection_error |
Public Member Functions | |
twesnothd_connection (const std::string &host, const std::string &service) | |
Constructor. More... | |
void | send_data (const configr_of &request) |
bool | receive_data (config &result) |
std::size_t | poll () |
Handle all pending asynchonous events and return. More... | |
void | cancel () |
Run asio's event loop. More... | |
bool | handshake_finished () const |
True if connected and no high-level operation is in progress. More... | |
std::size_t | bytes_to_write () const |
std::size_t | bytes_written () const |
std::size_t | bytes_to_read () const |
std::size_t | bytes_read () const |
bool | has_data_received () const |
bool | is_sending_data () const |
Private Types | |
typedef boost::asio::ip::tcp::resolver | resolver |
typedef boost::asio::ip::tcp::socket | socket |
Private Member Functions | |
void | handle_resolve (const boost::system::error_code &ec, resolver::iterator iterator) |
void | connect (resolver::iterator iterator) |
void | handle_connect (const boost::system::error_code &ec, resolver::iterator iterator) |
void | handshake () |
void | handle_handshake (const boost::system::error_code &ec) |
std::size_t | is_write_complete (const boost::system::error_code &error, std::size_t bytes_transferred) |
void | handle_write (const boost::system::error_code &ec, std::size_t bytes_transferred) |
std::size_t | is_read_complete (const boost::system::error_code &error, std::size_t bytes_transferred) |
void | handle_read (const boost::system::error_code &ec, std::size_t bytes_transferred) |
void | send () |
void | recv () |
Private Attributes | |
boost::asio::io_service | io_service_ |
resolver | resolver_ |
socket | socket_ |
bool | handshake_finished_ |
boost::asio::streambuf | read_buf_ |
union { | |
char binary [4] | |
boost::uint32_t num | |
} | handshake_response_ |
std::list< boost::asio::streambuf > | send_queue_ |
std::list< config > | recv_queue_ |
boost::uint32_t | payload_size_ |
std::size_t | bytes_to_write_ |
std::size_t | bytes_written_ |
std::size_t | bytes_to_read_ |
std::size_t | bytes_read_ |
A class that represents a TCP/IP connection to the wesnothd server.
Definition at line 40 of file wesnothd_connection.hpp.
Definition at line 43 of file wesnothd_connection.hpp.
|
private |
Definition at line 96 of file wesnothd_connection.hpp.
|
private |
Definition at line 99 of file wesnothd_connection.hpp.
twesnothd_connection::twesnothd_connection | ( | const std::string & | host, |
const std::string & | service | ||
) |
Constructor.
host | Name of the host to connect to |
service | Service identifier such as "80" or "http" |
Definition at line 33 of file wesnothd_connection.cpp.
References handle_resolve(), LOG_NW, and resolver_.
|
inline |
Definition at line 82 of file wesnothd_connection.hpp.
References bytes_read_.
Referenced by dialogs::read_wesnothd_connection_data::current().
|
inline |
Definition at line 78 of file wesnothd_connection.hpp.
References bytes_to_read_.
Referenced by dialogs::read_wesnothd_connection_data::total().
|
inline |
Definition at line 70 of file wesnothd_connection.hpp.
References bytes_to_write_.
|
inline |
Definition at line 74 of file wesnothd_connection.hpp.
References bytes_written_.
void twesnothd_connection::cancel | ( | ) |
Run asio's event loop.
Handle asynchronous events blocking until all asynchronous operations have finished
Definition at line 126 of file wesnothd_connection.cpp.
|
private |
Definition at line 61 of file wesnothd_connection.cpp.
References handle_connect(), LOG_NW, and socket_.
Referenced by handle_connect(), and handle_resolve().
|
private |
Definition at line 69 of file wesnothd_connection.cpp.
References connect(), ERR_NW, handshake(), LOG_NW, socket_, and WRN_NW.
Referenced by connect().
|
private |
Definition at line 105 of file wesnothd_connection.cpp.
References handshake_finished_, and recv().
Referenced by handshake().
|
private |
Definition at line 185 of file wesnothd_connection.cpp.
References bytes_to_read_, DBG_NW, read_buf_, read_gz(), recv(), and recv_queue_.
Referenced by recv().
|
private |
Definition at line 53 of file wesnothd_connection.cpp.
References connect().
Referenced by twesnothd_connection().
|
private |
Definition at line 145 of file wesnothd_connection.cpp.
References DBG_NW, send(), and send_queue_.
Referenced by send().
|
private |
Definition at line 92 of file wesnothd_connection.cpp.
References handle_handshake(), handshake_response_, and socket_.
Referenced by handle_connect().
|
inline |
True if connected and no high-level operation is in progress.
Definition at line 68 of file wesnothd_connection.hpp.
References handshake_finished_.
Referenced by dialogs::connect_wesnothd_connection_data::finished().
|
inline |
Definition at line 86 of file wesnothd_connection.hpp.
References recv_queue_.
Referenced by dialogs::read_wesnothd_connection_data::finished().
|
private |
Definition at line 160 of file wesnothd_connection.cpp.
References bytes_read_, bytes_to_read_, num, and read_buf_.
Referenced by recv().
|
inline |
Definition at line 90 of file wesnothd_connection.hpp.
References send_queue_.
|
private |
Definition at line 137 of file wesnothd_connection.cpp.
References bytes_to_write_, and bytes_written_.
Referenced by send().
std::size_t twesnothd_connection::poll | ( | ) |
Handle all pending asynchonous events and return.
Definition at line 227 of file wesnothd_connection.cpp.
References lg::err(), and io_service_.
Referenced by dialogs::read_wesnothd_connection_data::poll(), dialogs::connect_wesnothd_connection_data::poll(), receive_data(), and send_data().
bool twesnothd_connection::receive_data | ( | config & | result | ) |
Definition at line 238 of file wesnothd_connection.cpp.
References poll(), recv_queue_, and config::swap().
Referenced by gui2::tlobby_main::network_handler(), dialogs::network_receive_dialog(), mp::ui::receive_from_server(), ng::connect_engine::receive_from_server(), and playmp_controller::recieve_from_wesnothd().
|
private |
Definition at line 219 of file wesnothd_connection.cpp.
References handle_read(), is_read_complete(), read_buf_, and socket_.
Referenced by handle_handshake(), and handle_read().
|
private |
Definition at line 202 of file wesnothd_connection.cpp.
References bytes_to_write_, bytes_written_, handle_write(), is_write_complete(), payload_size_, send_queue_, and socket_.
Referenced by handle_write(), and send_data().
void twesnothd_connection::send_data | ( | const configr_of & | request | ) |
Definition at line 114 of file wesnothd_connection.cpp.
References poll(), send(), send_queue_, and write_gz().
Referenced by gui2::tlobby_main::close_window(), gui2::tlobby_main::do_game_join(), enter_configure_mode(), enter_connect_mode(), enter_create_mode(), enter_lobby_mode(), enter_wait_mode(), open_connection(), lobby_info::process_gamelist_diff(), gui2::tlobby_main::refresh_button_callback(), gui2::tlobby_main::send_chat_message(), gui2::tlobby_main::send_to_server(), mp::ui::send_to_server(), ng::connect_engine::send_to_server(), playmp_controller::send_to_wesnothd(), gui2::tlobby_main::show_preferences_button_callback(), mp::start_client(), gui2::tlobby_main::update_gamelist_diff(), and gui2::tlobby_main::user_dialog_callback().
char twesnothd_connection::binary[4] |
Definition at line 121 of file wesnothd_connection.hpp.
|
private |
Definition at line 140 of file wesnothd_connection.hpp.
Referenced by bytes_read(), and is_read_complete().
|
private |
Definition at line 139 of file wesnothd_connection.hpp.
Referenced by bytes_to_read(), handle_read(), and is_read_complete().
|
private |
Definition at line 137 of file wesnothd_connection.hpp.
Referenced by bytes_to_write(), is_write_complete(), and send().
|
private |
Definition at line 138 of file wesnothd_connection.hpp.
Referenced by bytes_written(), is_write_complete(), and send().
|
private |
Definition at line 102 of file wesnothd_connection.hpp.
Referenced by handle_handshake(), and handshake_finished().
union { ... } twesnothd_connection::handshake_response_ |
Referenced by handshake().
|
private |
Definition at line 95 of file wesnothd_connection.hpp.
Referenced by poll().
boost::uint32_t twesnothd_connection::num |
Definition at line 122 of file wesnothd_connection.hpp.
Referenced by is_read_complete().
|
private |
Definition at line 136 of file wesnothd_connection.hpp.
Referenced by send().
|
private |
Definition at line 104 of file wesnothd_connection.hpp.
Referenced by handle_read(), is_read_complete(), and recv().
|
private |
Definition at line 134 of file wesnothd_connection.hpp.
Referenced by handle_read(), has_data_received(), and receive_data().
|
private |
Definition at line 97 of file wesnothd_connection.hpp.
Referenced by twesnothd_connection().
|
private |
Definition at line 133 of file wesnothd_connection.hpp.
Referenced by handle_write(), is_sending_data(), send(), and send_data().
|
private |
Definition at line 100 of file wesnothd_connection.hpp.
Referenced by cancel(), connect(), handle_connect(), handshake(), recv(), and send().