SuperTuxKart
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
ServersManager Class Reference

Public Member Functions

std::vector< SocketAddressgetBroadcastAddresses (bool ipv6)
 Returns a list of all possible broadcast addresses on this machine.
 
std::shared_ptr< ServerListgetWANRefreshRequest () const
 Returns a WAN update-list-of-servers request.
 
std::shared_ptr< ServerListgetLANRefreshRequest () const
 Returns a LAN update-list-of-servers request.
 

Static Public Member Functions

static ServersManagerget ()
 
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< SocketAddressgetDefaultBroadcastAddresses ()
 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< SocketAddressm_broadcast_address
 List of broadcast addresses to use.
 

Member Function Documentation

◆ addAllBroadcastAddresses()

void ServersManager::addAllBroadcastAddresses ( const SocketAddress a,
int  len,
std::vector< SocketAddress > *  result 
)
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).

Parameters
aThe transport address for which the broadcast addresses need to be created.
lenNumber of bits to be or'ed.
resultLocation to put address.

◆ getBroadcastAddresses()

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.

◆ getDefaultBroadcastAddresses()

std::vector< SocketAddress > ServersManager::getDefaultBroadcastAddresses ( )
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.

◆ getLANRefreshRequest()

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.

Precondition
request has to be executed.
Returns
get the complete result from the request reply.

This function is necessary, otherwise the XML- and HTTP-Request functions are called, which will cause a crash.

◆ getWANRefreshRequest()

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.


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