SuperTuxKart
|
Public Member Functions | |
std::vector< SocketAddress > | getBroadcastAddresses (bool ipv6) |
Returns a list of all possible broadcast addresses on this machine. | |
std::shared_ptr< ServerList > | getWANRefreshRequest () const |
Returns a WAN update-list-of-servers request. | |
std::shared_ptr< ServerList > | getLANRefreshRequest () const |
Returns a LAN update-list-of-servers request. | |
Static Public Member Functions | |
static ServersManager * | get () |
static void | deallocate () |
Private Member Functions | |
void | setWanServers (bool success, const XMLNode *input) |
void | setLanServers (const std::map< irr::core::stringw, std::shared_ptr< Server > > &servers) |
std::vector< SocketAddress > | getDefaultBroadcastAddresses () |
Sets a list of default broadcast addresses which is used in case no valid broadcast address is found. | |
void | addAllBroadcastAddresses (const SocketAddress &a, int len, std::vector< SocketAddress > *result) |
This masks various possible broadcast addresses. | |
Private Attributes | |
std::vector< SocketAddress > | m_broadcast_address |
List of broadcast addresses to use. | |
|
private |
This masks various possible broadcast addresses.
For example, in a /16 network it would first use *.*.255.255, then *.*.*.255. Also if the length of the mask is not a multiple of 8, the original value will be used, before multiple of 8 are create: /22 (*.3f.ff.ff), then /16 (*.*.ff.ff), /8 (*.*.*.ff). While this is usually an overkill, it can help in the case that the router does not forward a broadcast as expected (this problem often happens with 255.255.255.255, which is why this broadcast address creation code was added).
a | The transport address for which the broadcast addresses need to be created. |
len | Number of bits to be or'ed. |
result | Location to put address. |
std::vector< SocketAddress > ServersManager::getBroadcastAddresses | ( | bool | ipv6 | ) |
Returns a list of all possible broadcast addresses on this machine.
It queries all adapters for active IPv4 interfaces, determines their netmask to create the broadcast addresses. It will also add 'smaller' broadcast addesses, e.g. in a /16 network, it will add *.*.255.255 and *.*.*.255, since it was sometimes observed that routers would not let all broadcast addresses through. Duplicated answers (from the same server to different addersses) will be filtered out in ServersManager.
|
private |
Sets a list of default broadcast addresses which is used in case no valid broadcast address is found.
This list includes default private network addresses.
std::shared_ptr< ServerList > ServersManager::getLANRefreshRequest | ( | ) | const |
Returns a LAN update-list-of-servers request.
It uses UDP broadcasts to find LAN servers, and waits for a certain amount of time fr answers.
A simple class that uses LAN broadcasts to find local servers. It is based on XML request, but actually does not use any of the XML/HTTP based infrastructure, but implements the same interface. This way the already existing request thread can be used.
High priority for this request.
Get the downloaded XML tree.
This function is necessary, otherwise the XML- and HTTP-Request functions are called, which will cause a crash.
std::shared_ptr< ServerList > ServersManager::getWANRefreshRequest | ( | ) | const |
Returns a WAN update-list-of-servers request.
It queries the STK server for an up-to-date list of servers.
A small local class that triggers an update of the ServersManager when the request is finished.