The Battle for Wesnoth  1.15.2+dev
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
server_base Class Referenceabstract

#include <server_base.hpp>

Inheritance diagram for server_base:
Inheritance graph

Public Member Functions

 server_base (unsigned short port, bool keep_alive)
 
virtual ~server_base ()
 
void run ()
 

Protected Member Functions

void setup_acceptor (boost::asio::ip::tcp::acceptor &acceptor, boost::asio::ip::tcp::endpoint endpoint)
 
void start_server ()
 
void serve (boost::asio::ip::tcp::acceptor &acceptor)
 
void accept_connection (boost::asio::ip::tcp::acceptor &acceptor, const boost::system::error_code &error, socket_ptr socket)
 
void serverside_handshake (socket_ptr socket)
 
void handle_handshake (const boost::system::error_code &error, socket_ptr socket, boost::shared_array< char > buf)
 
virtual void handle_new_client (socket_ptr socket)=0
 
virtual bool accepting_connections () const
 
virtual std::string is_ip_banned (const std::string &)
 
virtual bool ip_exceeds_connection_limit (const std::string &) const
 
void read_from_fifo ()
 
virtual void handle_read_from_fifo (const boost::system::error_code &error, std::size_t bytes_transferred)=0
 
virtual void handle_sighup (const boost::system::error_code &error, int signal_number)=0
 
void handle_termination (const boost::system::error_code &error, int signal_number)
 

Protected Attributes

unsigned short port_
 
bool keep_alive_
 
boost::asio::io_service io_service_
 
boost::asio::ip::tcp::acceptor acceptor_v6_
 
boost::asio::ip::tcp::acceptor acceptor_v4_
 
union {
   uint32_t   connection_num
 
   char   buf [4]
 
handshake_response_
 
boost::asio::posix::stream_descriptor input_
 
std::string fifo_path_
 
boost::asio::streambuf admin_cmd_
 
boost::asio::signal_set sighup_
 
boost::asio::signal_set sigs_
 

Detailed Description

Definition at line 37 of file server_base.hpp.

Constructor & Destructor Documentation

◆ server_base()

server_base::server_base ( unsigned short  port,
bool  keep_alive 
)

Definition at line 33 of file server_base.cpp.

◆ ~server_base()

virtual server_base::~server_base ( )
inlinevirtual

Definition at line 41 of file server_base.hpp.

Member Function Documentation

◆ accept_connection()

void server_base::accept_connection ( boost::asio::ip::tcp::acceptor &  acceptor,
const boost::system::error_code &  error,
socket_ptr  socket 
)
protected

◆ accepting_connections()

virtual bool server_base::accepting_connections ( ) const
inlineprotectedvirtual

Reimplemented in wesnothd::server.

Definition at line 64 of file server_base.hpp.

Referenced by accept_connection().

◆ handle_handshake()

void server_base::handle_handshake ( const boost::system::error_code &  error,
socket_ptr  socket,
boost::shared_array< char >  buf 
)
protected

Definition at line 124 of file server_base.cpp.

References check_error(), client_address(), ERR_SERVER, and handshake_response_.

Referenced by serverside_handshake().

◆ handle_new_client()

virtual void server_base::handle_new_client ( socket_ptr  socket)
protectedpure virtual

Implemented in campaignd::server, and wesnothd::server.

◆ handle_read_from_fifo()

virtual void server_base::handle_read_from_fifo ( const boost::system::error_code &  error,
std::size_t  bytes_transferred 
)
protectedpure virtual

Implemented in wesnothd::server, and campaignd::server.

Referenced by read_from_fifo().

◆ handle_sighup()

virtual void server_base::handle_sighup ( const boost::system::error_code &  error,
int  signal_number 
)
protectedpure virtual

Implemented in wesnothd::server, and campaignd::server.

Referenced by start_server().

◆ handle_termination()

void server_base::handle_termination ( const boost::system::error_code &  error,
int  signal_number 
)
protected

Definition at line 168 of file server_base.cpp.

References lexical_cast(), and LOG_SERVER.

Referenced by start_server().

◆ ip_exceeds_connection_limit()

virtual bool server_base::ip_exceeds_connection_limit ( const std::string &  ) const
inlineprotectedvirtual

Reimplemented in wesnothd::server.

Definition at line 66 of file server_base.hpp.

◆ is_ip_banned()

virtual std::string server_base::is_ip_banned ( const std::string &  )
inlineprotectedvirtual

Reimplemented in wesnothd::server.

Definition at line 65 of file server_base.hpp.

◆ read_from_fifo()

void server_base::read_from_fifo ( )
protected

◆ run()

void server_base::run ( )

Definition at line 180 of file server_base.cpp.

References e, io_service_, LOG_SERVER, and game::error::what().

Referenced by main().

◆ serve()

void server_base::serve ( boost::asio::ip::tcp::acceptor &  acceptor)
protected

Definition at line 78 of file server_base.cpp.

References accept_connection(), error(), and io_service_.

Referenced by accept_connection(), and start_server().

◆ serverside_handshake()

void server_base::serverside_handshake ( socket_ptr  socket)
protected

Definition at line 115 of file server_base.cpp.

References handle_handshake().

Referenced by accept_connection().

◆ setup_acceptor()

void server_base::setup_acceptor ( boost::asio::ip::tcp::acceptor &  acceptor,
boost::asio::ip::tcp::endpoint  endpoint 
)
protected

Definition at line 47 of file server_base.cpp.

References keep_alive_.

Referenced by start_server().

◆ start_server()

void server_base::start_server ( )
protected

Member Data Documentation

◆ acceptor_v4_

boost::asio::ip::tcp::acceptor server_base::acceptor_v4_
protected

◆ acceptor_v6_

boost::asio::ip::tcp::acceptor server_base::acceptor_v6_
protected

◆ admin_cmd_

boost::asio::streambuf server_base::admin_cmd_
protected

◆ buf

char server_base::buf[4]

Definition at line 57 of file server_base.hpp.

◆ connection_num

uint32_t server_base::connection_num

Definition at line 56 of file server_base.hpp.

◆ fifo_path_

std::string server_base::fifo_path_
protected

Definition at line 70 of file server_base.hpp.

Referenced by campaignd::server::load_config().

◆ handshake_response_

union { ... } server_base::handshake_response_

Referenced by handle_handshake(), and start_server().

◆ input_

boost::asio::posix::stream_descriptor server_base::input_
protected

◆ io_service_

boost::asio::io_service server_base::io_service_
protected

Definition at line 47 of file server_base.hpp.

Referenced by run(), and serve().

◆ keep_alive_

bool server_base::keep_alive_
protected

Definition at line 46 of file server_base.hpp.

Referenced by accept_connection(), and setup_acceptor().

◆ port_

unsigned short server_base::port_
protected

◆ sighup_

boost::asio::signal_set server_base::sighup_
protected

◆ sigs_

boost::asio::signal_set server_base::sigs_
protected

Definition at line 78 of file server_base.hpp.

Referenced by start_server().


The documentation for this class was generated from the following files: