24 #ifdef INADDR_BROADCAST 25 #undef INADDR_BROADCAST 32 #endif // endif _WIN32 37 #include <boost/asio/io_context.hpp> 38 #include <boost/asio/ip/tcp.hpp> 39 #include <boost/asio/streambuf.hpp> 40 #include <boost/asio/ssl.hpp> 42 #include <condition_variable> 100 return utils::holds_alternative<tls_socket>(
socket_);
149 typedef std::unique_ptr<boost::asio::ip::tcp::socket>
raw_socket;
150 typedef std::unique_ptr<boost::asio::ssl::stream<raw_socket::element_type>>
tls_socket;
164 using endpoint =
const boost::asio::ip::tcp::endpoint&;
177 void handle_write(
const boost::system::error_code& ec, std::size_t bytes_transferred);
180 void handle_read(
const boost::system::error_code& ec, std::size_t bytes_transferred);
void send_data(const configr_of &request)
Queues the given data to be sent to the server.
An error occurred inside the underlying network communication code (boost asio) TODO: find a short na...
std::size_t is_read_complete(const boost::system::error_code &error, std::size_t bytes_transferred)
std::condition_variable recv_queue_lock_
std::promise< void > handshake_finished_
boost::asio::ssl::context tls_context_
void handle_write(const boost::system::error_code &ec, std::size_t bytes_transferred)
bool is_sending_data() const
resolver::results_type results_type
std::size_t bytes_to_read_
boost::asio::io_context io_context_
std::size_t is_write_complete(const boost::system::error_code &error, std::size_t bytes_transferred)
void fallback_to_unencrypted()
void handle_connect(const boost::system::error_code &ec, endpoint endpoint)
std::size_t bytes_to_write() const
bool receive_data(config &result)
Receives the next pending data pack from the server, if available.
wesnothd_connection & operator=(const wesnothd_connection &)=delete
std::size_t bytes_to_write_
uint32_t handshake_response_
std::unique_ptr< boost::asio::ssl::stream< raw_socket::element_type > > tls_socket
utils::variant< raw_socket, tls_socket > any_socket
std::queue< T, std::list< T > > data_queue
A class that represents a TCP/IP connection to the wesnothd server.
bool has_data_received() const
std::mutex recv_queue_mutex_
std::size_t bytes_read() const
void handle_handshake(const boost::system::error_code &ec)
boost::asio::streambuf read_buf_
bool using_tls() const
True if connection is currently using TLS and thus is allowed to send cleartext passwords or auth tok...
boost::system::error_code last_error_
std::size_t bytes_to_read() const
void set_keepalive(int seconds)
std::size_t bytes_written() const
boost::asio::ip::tcp::resolver resolver
wesnothd_connection(const wesnothd_connection &)=delete
std::size_t bytes_written_
data_queue< config > recv_queue_
void handle_read(const boost::system::error_code &ec, std::size_t bytes_transferred)
const boost::asio::ip::tcp::endpoint & endpoint
data_queue< std::unique_ptr< boost::asio::streambuf > > send_queue_
void handle_resolve(const boost::system::error_code &ec, results_type results)
bool wait_and_receive_data(config &data)
Unlike receive_data, waits until data is available instead of returning immediately.
std::unique_ptr< boost::asio::ip::tcp::socket > raw_socket
A config object defines a single node in a WML file, with access to child nodes.
std::mutex last_error_mutex_
void wait_for_handshake()
Waits until the server handshake is complete.
std::thread worker_thread_