Classes | Typedefs | Functions | Variables

network Namespace Reference

High level network layer for config object transport. More...

Classes

struct  bandwidth_stats
struct  bandwidth_stats_output
struct  pending_statistics
struct  manager
struct  server_manager
 A server manager causes listening on a given port to occur for the duration of its lifetime. More...
struct  bandwidth_in
struct  connection_stats
struct  error
struct  statistics

Typedefs

typedef std::map< const
std::string, bandwidth_stats
bandwidth_map
typedef std::vector
< bandwidth_map
hour_stats_vector
typedef boost::shared_ptr
< bandwidth_stats
bandwidth_stats_ptr
typedef int connection
typedef boost::shared_ptr
< bandwidth_in
bandwidth_in_ptr

Functions

connection_stats get_connection_stats (connection connection_num)
pending_statistics get_pending_stats ()
void set_raw_data_only ()
size_t nconnections ()
 The number of peers we are connected to.
bool is_server ()
 If we are currently accepting connections.
connection connect (const std::string &host, int port=15000)
 Function to attempt to connect to a remote host.
connection connect (const std::string &host, int port, threading::waiter &waiter)
connection accept_connection ()
 Function to accept a connection from a remote host.
bool disconnect (connection connection_num=0)
 Function to disconnect from a certain host, or close all connections if connection_num is 0.
void queue_disconnect (connection connection_num)
 Function to queue a disconnection.
connection receive_data (config &cfg, connection connection_num, unsigned int timeout, bandwidth_in_ptr *bandwidth_in)
connection receive_data (config &cfg, connection connection_num=0, bandwidth_in_ptr *b=0)
 Function to receive data from either a certain connection, or all connections if connection_num is 0.
connection receive_data (std::vector< char > &buf, bandwidth_in_ptr *bandwidth_in)
hour_stats_vector hour_stats (24)
static bandwidth_map::iterator add_bandwidth_entry (const std::string &packet_type)
std::string get_bandwidth_stats_all ()
std::string get_bandwidth_stats ()
std::string get_bandwidth_stats (int hour)
void add_bandwidth_out (const std::string &packet_type, size_t len)
void add_bandwidth_in (const std::string &packet_type, size_t len)
void send_file (const std::string &filename, connection connection_num, const std::string &packet_type)
size_t send_data (const config &cfg, connection connection_num=0, const std::string &packet_type="unknown")
 Function to send data down a given connection, or broadcast to all peers if connection_num is 0.
void send_raw_data (const char *buf, int len, connection connection_num, const std::string &packet_type)
void process_send_queue (connection connection_num=0, size_t max_size=0)
 Function to send any data that is in a connection's send_queue, up to a maximum of 'max_size' bytes -- or the entire send queue if 'max_size' bytes is 0.
void send_data_all_except (const config &cfg, connection connection_num, const std::string &packet_type="unknown")
 Function to send data to all peers except 'connection_num'.
std::string ip_address (connection connection_num)
 Function to get the remote ip address of a socket.
statistics get_send_stats (connection handle)
 Function to see the number of bytes being processed on the current socket.
statistics get_receive_stats (connection handle)
Proxy Settings Methods

Methods to configure the connection of a client through a proxy server.

void enable_connection_through_proxy ()
 Attempt to connect through a proxy (as opposed to directly.
void set_proxy_address (const std::string &address)
 Set the address of the proxy.
void set_proxy_port (const std::string &port)
 Set the port of the proxy.
void set_proxy_user (const std::string &user)
 Set the user to authenticate with the proxy.
void set_proxy_password (const std::string &password)
 Set the password to authenticate with the proxy.

Variables

unsigned int ping_timeout = 0
 Amount of seconds after the last server ping when we assume to have timed out.
connection const null_connection = 0
const int ping_interval = 30
 Minimum interval between pings.

Detailed Description

High level network layer for config object transport.

This module provides high level network access using an API similar to sockets, but primarily for the transport of config objects. This is how the games protocols work - data is sent via config objects.

A client would create a manager object to initialize the network layer, connect(), and then send_data(). A server would create a server_manager object, then accept_connection(), and finally receive_data().


Typedef Documentation

typedef boost::shared_ptr<bandwidth_in> network::bandwidth_in_ptr

Definition at line 206 of file network.hpp.

typedef std::map<const std::string, bandwidth_stats> network::bandwidth_map

Definition at line 956 of file network.cpp.

typedef boost::shared_ptr<bandwidth_stats> network::bandwidth_stats_ptr

Definition at line 984 of file network.cpp.

typedef int network::connection

Definition at line 74 of file network.hpp.

Definition at line 957 of file network.cpp.


Function Documentation

connection network::accept_connection (  ) 

Function to accept a connection from a remote host.

If no host is attempting to connect, it will return 0 immediately. Otherwise returns the new connection.

Exceptions:
error 

A list of all the sockets which have connected, but haven't had their initial handshake received.

Definition at line 210 of file network_ana.cpp.

Referenced by BOOST_AUTO_TEST_CASE(), mp::ui::process_network(), server::run(), and WESNOTH_PARAMETERIZED_TEST_CASE().

Here is the caller graph for this function:

static bandwidth_map::iterator network::add_bandwidth_entry ( const std::string &  packet_type  )  [static]

Definition at line 962 of file network.cpp.

References hour_stats().

Here is the call graph for this function:

void network::add_bandwidth_in ( const std::string &  packet_type,
size_t  len 
)

Definition at line 268 of file network_ana.cpp.

Referenced by network::bandwidth_in::~bandwidth_in().

Here is the caller graph for this function:

void network::add_bandwidth_out ( const std::string &  packet_type,
size_t  len 
)

Definition at line 263 of file network_ana.cpp.

connection network::connect ( const std::string &  host,
int  port = 15000 
)

Function to attempt to connect to a remote host.

Returns:
The new connection on success, or 0 on failure.
Exceptions:
error 

Definition at line 200 of file network_ana.cpp.

Referenced by BOOST_AUTO_TEST_CASE(), connect(), network::server_manager::server_manager(), and WESNOTH_PARAMETERIZED_TEST_CASE().

Here is the caller graph for this function:

connection network::connect ( const std::string &  host,
int  port,
threading::waiter waiter 
)

Definition at line 205 of file network_ana.cpp.

References connect().

Here is the call graph for this function:

bool network::disconnect ( connection  connection_num = 0  ) 

Function to disconnect from a certain host, or close all connections if connection_num is 0.

Returns true if the connection was disconnected. Returns false on failure to disconnect, since the socket is in the middle of sending/receiving data. The socket will be closed when it has finished its send/receive.

Definition at line 215 of file network_ana.cpp.

Referenced by open_connection(), playsingle_controller::play_scenario(), server::run(), WESNOTH_PARAMETERIZED_TEST_CASE(), and network::manager::~manager().

Here is the caller graph for this function:

void network::enable_connection_through_proxy (  ) 

Attempt to connect through a proxy (as opposed to directly.

)

Use the set_proxy_* methods to configure the connection options.

Definition at line 113 of file network_ana.cpp.

Referenced by game_controller::game_controller().

Here is the caller graph for this function:

std::string network::get_bandwidth_stats (  ) 

Definition at line 295 of file network_ana.cpp.

References ana::stats::bytes_in(), ana::stats::bytes_out(), ana::HOURS, ana::stats::packets_in(), and ana::stats::packets_out().

Referenced by server::netstats_handler(), and server::run().

Here is the call graph for this function:

Here is the caller graph for this function:

std::string network::get_bandwidth_stats ( int  hour  ) 

Definition at line 317 of file network_ana.cpp.

std::string network::get_bandwidth_stats_all (  ) 

Definition at line 274 of file network_ana.cpp.

References ana::stats::bytes_in(), ana::stats::bytes_out(), ana::stats::packets_in(), and ana::stats::packets_out().

Referenced by server::netstats_handler().

Here is the call graph for this function:

Here is the caller graph for this function:

connection_stats network::get_connection_stats ( connection  connection_num  ) 

Definition at line 92 of file network_ana.cpp.

References ana::stats::bytes_in(), ana::stats::bytes_out(), and ana::stats::uptime().

Here is the call graph for this function:

pending_statistics network::get_pending_stats (  ) 

Definition at line 139 of file network_ana.cpp.

References network::pending_statistics::nbytes_pending_sends, and network::pending_statistics::npending_sends.

Referenced by server::netstats_handler().

Here is the caller graph for this function:

statistics network::get_receive_stats ( connection  handle  ) 

Definition at line 376 of file network_ana.cpp.

statistics network::get_send_stats ( connection  handle  ) 

Function to see the number of bytes being processed on the current socket.

Definition at line 371 of file network_ana.cpp.

hour_stats_vector network::hour_stats ( 24   ) 

Referenced by add_bandwidth_entry(), and ChatClient::parse_command().

Here is the caller graph for this function:

std::string network::ip_address ( connection  connection_num  ) 
bool network::is_server (  ) 

If we are currently accepting connections.

Definition at line 195 of file network_ana.cpp.

Referenced by mp::connect::process_network_error().

Here is the caller graph for this function:

size_t network::nconnections (  ) 
void network::process_send_queue ( connection  connection_num = 0,
size_t  max_size = 0 
)

Function to send any data that is in a connection's send_queue, up to a maximum of 'max_size' bytes -- or the entire send queue if 'max_size' bytes is 0.

Definition at line 354 of file network_ana.cpp.

Referenced by server::run().

Here is the caller graph for this function:

void network::queue_disconnect ( network::connection  sock  ) 

Function to queue a disconnection.

Next time receive_data is called, it will generate an error on the given connection (and presumably then the handling of the error will include closing the connection).

Definition at line 220 of file network_ana.cpp.

Referenced by server::kick_handler(), server::kickban_handler(), and server::process_login().

Here is the caller graph for this function:

connection network::receive_data ( config cfg,
connection  connection_num = 0,
bandwidth_in_ptr *  b = 0 
)

Function to receive data from either a certain connection, or all connections if connection_num is 0.

Will store the data received in cfg. Times out after timeout milliseconds.

Returns:
The connection that data was received from, or 0 if timeout occurred.
Exceptions:
error If an error occurred.

Definition at line 243 of file network_ana.cpp.

References receive_data().

Here is the call graph for this function:

connection network::receive_data ( std::vector< char > &  buf,
bandwidth_in_ptr *  bandwidth_in = 0 
)

Definition at line 251 of file network_ana.cpp.

connection network::receive_data ( config cfg,
connection  connection_num,
unsigned int  timeout,
bandwidth_in_ptr *  bandwidth_in = 0 
)
size_t network::send_data ( const config cfg,
connection  connection_num = 0,
const std::string &  packet_type = "unknown" 
)

Function to send data down a given connection, or broadcast to all peers if connection_num is 0.

Exceptions:
error 

Definition at line 333 of file network_ana.cpp.

References config::empty().

Referenced by BOOST_AUTO_TEST_CASE(), events::menu_handler::change_controller(), events::menu_handler::change_side_controller(), gui2::tlobby_main::close_window(), replay_network_sender::commit_and_sync(), mp::connect::connect(), events::chat_command_handler::do_details(), events::chat_command_handler::do_drop(), gui2::tlobby_main::do_game_join(), events::chat_command_handler::do_gen_room_query(), events::chat_command_handler::do_info(), events::chat_command_handler::do_register(), events::chat_command_handler::do_room_query(), events::chat_command_handler::do_room_query_noarg(), events::chat_command_handler::do_set(), enter_connect_mode(), enter_create_mode(), enter_lobby_mode(), mp::ui::handle_event(), mp::wait::join_game(), open_connection(), play_game(), playsingle_controller::play_scenario(), mp::lobby::process_event(), mp::connect::process_event(), lobby_info::process_gamelist_diff(), server::process_login(), mp::connect::process_network_connection(), mp::ui::process_network_data(), mp::connect::process_network_data(), playmp_controller::process_oos(), gui2::tlobby_main::refresh_button_callback(), mp::ui::send_chat_message(), gui2::tlobby_main::send_chat_message(), events::chat_handler::send_chat_room_message(), events::chat_handler::send_command(), events::chat_handler::send_whisper(), gui2::tlobby_main::show_preferences_button_callback(), mp::connect::start_game(), replay_network_sender::sync_non_undoable(), mp::connect::update_and_send_diff(), gui2::tlobby_main::update_gamelist_diff(), gui2::tlobby_main::user_dialog_callback(), and verify_and_get_global_variable().

Here is the call graph for this function:

Here is the caller graph for this function:

void network::send_data_all_except ( const config cfg,
connection  connection_num,
const std::string &  packet_type = "unknown" 
)

Function to send data to all peers except 'connection_num'.

Definition at line 359 of file network_ana.cpp.

Referenced by turn_info::process_network_data().

Here is the caller graph for this function:

void network::send_file ( const std::string &  filename,
connection  connection_num,
const std::string &  packet_type = "unknown" 
)

Definition at line 326 of file network_ana.cpp.

Referenced by WESNOTH_PARAMETERIZED_TEST_CASE().

Here is the caller graph for this function:

void network::send_raw_data ( const char *  buf,
int  len,
connection  connection_num,
const std::string &  packet_type = "unknown" 
)

Definition at line 346 of file network_ana.cpp.

Referenced by server::run(), and wesnothd::game::send_history().

Here is the caller graph for this function:

void network::set_proxy_address ( const std::string &  address  ) 

Set the address of the proxy.

Default: "localhost".

Parameters:
address,: Network address where the proxy server should be running.

Definition at line 117 of file network_ana.cpp.

Referenced by game_controller::game_controller().

Here is the caller graph for this function:

void network::set_proxy_password ( const std::string &  password  ) 

Set the password to authenticate with the proxy.

Default: "".

Parameters:
password,: Password to use for authentication purposes.

Definition at line 132 of file network_ana.cpp.

Referenced by game_controller::game_controller().

Here is the caller graph for this function:

void network::set_proxy_port ( const std::string &  port  ) 

Set the port of the proxy.

Default: "3128".

Parameters:
port,: Network port where the proxy server should be listening.

Definition at line 122 of file network_ana.cpp.

Referenced by game_controller::game_controller().

Here is the caller graph for this function:

void network::set_proxy_user ( const std::string &  user  ) 

Set the user to authenticate with the proxy.

Default: "".

Parameters:
user,: User name to use for authentication purposes.

Definition at line 127 of file network_ana.cpp.

Referenced by game_controller::game_controller().

Here is the caller graph for this function:

void network::set_raw_data_only (  ) 

Definition at line 161 of file network_ana.cpp.

Referenced by main(), and WESNOTH_PARAMETERIZED_TEST_CASE().

Here is the caller graph for this function:


Variable Documentation

const int network::ping_interval = 30

Minimum interval between pings.

Definition at line 303 of file network.hpp.

Referenced by check_timeout(), and server::run().

unsigned int network::ping_timeout = 0

Amount of seconds after the last server ping when we assume to have timed out.

When set to '0' ping timeout isn't checked. Gets set in preferences::manager according to the preferences file.

Definition at line 215 of file network.cpp.

Referenced by check_timeout(), and preferences::manager::manager().

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

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