Emergency 20 Dokumentation  4.2.0
em5::NetworkManager Class Reference

EMERGENCY 5 network manager class. More...

#include <NetworkManager.h>

Inheritance diagram for em5::NetworkManager:
qsf::game::NetworkManager qsf::UniqueInstance< NetworkManager >

Public Member Functions

 NetworkManager ()
 Default constructor. More...
 
virtual ~NetworkManager ()
 Destructor. More...
 
virtual bool onStartup () override
 
virtual void onShutdown () override
 
void setMatchmakingUrlAndPort (const std::string &matchmakingUrl, uint16 matchmakingPort)
 Override the matchmaking url and port. More...
 
std::shared_ptr< MatchmakingClientconnectToMatchmakingServer ()
 Creates a new MatchmakingClient object and tries to connect to the master matchmaking server listening at the predefined hostname MATCHMAKING_SERVER_HOSTNAME and port MATCHMAKING_SERVER_PORT. More...
 
std::shared_ptr< MatchmakingClientgetMatchmakingClient () const
 Returns the stored MatchmakingClient object or nullptr, if there is none. More...
 
multiplayer::client::ClientcreateMultiplayerClient ()
 Creates a new MultiplayerClient object. More...
 
multiplayer::client::ClientconnectToMultiplayerHost (const multiplayer::HostEntry &hostEntry, const std::string &playerName, const std::string &sessionPassword)
 Creates a new MultiplayerClient object and tries to connect to a multiplayer host listening at the specified hostname and port. More...
 
multiplayer::client::ClientconnectToLocalMultiplayerHost (const std::string &dataPath, const MapIdentifier &mapIdentifier, const std::string &playerName, const std::string &sessionPassword)
 Creates a new MultiplayerClient object with a local host instance (This is only for testing) More...
 
multiplayer::client::ClientgetMultiplayerClient () const
 Returns the stored MultiplayerClient object or nullptr, if there is none. More...
 
void closeMultiplayerClient ()
 Closes the multiplayer client connection and destroys the instance. More...
 
multiplayer::server::HostcreateMultiplayerHost ()
 Creates a new MultiplayerHost object. More...
 
multiplayer::server::HostgetMultiplayerHost () const
 Returns the stored MultiplayerHost object or nullptr, if there is none. More...
 
void closeMultiplayerHost ()
 Closes the multiplayer host and destroys the instance. More...
 
bool isMultiplayActive () const
 Returns if a multiplay session is active (a multiplayer host or client exists) More...
 
multiplayer::SessionBasegetMultiplayerSession () const
 Returns the stored multiplayer session object or nullptr, if there is none (Can be either host or client) More...
 
UpdateCheckgetUpdateCheck ()
 Return the update check instance, and creates it if needed. More...
 
void setProxyUrlAndPort (const std::string &proxyUrl, uint16 proxyPort)
 Override the proxy url and port. More...
 
multiplayer::proxy::MultiplayerProxyClientconnectToMultiplayerProxyServer ()
 Creates a new MultiplayerProxyClient object (when not already created) and tries to connect to the proxy server (with default values for hostname and port. More...
 
multiplayer::proxy::MultiplayerProxyClientconnectToMultiplayerProxyServer (const std::string &hostname, uint16 port)
 Creates a new MultiplayerProxyClient object(when not already created) and tries to connect to the proxy server. More...
 
multiplayer::proxy::MultiplayerProxyClientgetMultiplayerProxyClient () const
 Returns the stored MultiplayerProxyClient object or nullptr, if there is none. More...
 
void closeMultiplayerProxyClient ()
 Closes the multiplayer proxy client and destroys the instance. More...
 
- Public Member Functions inherited from qsf::game::NetworkManager
 NetworkManager ()
 Default constructor. More...
 
ServercreateServer (uint16 port)
 Creates a new server object and tries to listen on the specified port. More...
 
ServergetServer () const
 Returns the previously created server object or null pointer, if there is none. More...
 
void closeServer ()
 Shuts down the server, closes all connections and destroys the instance. More...
 
ClientconnectToServer (const std::string &hostname, uint16 port)
 Creates a new client object and tries to connect to a server listening at the specified hostname and port. More...
 
ClientgetClient () const
 Returns the stored client object or null pointer, if there is none. More...
 
void closeClient ()
 Closes the client connection and destroys the instance. More...
 

Static Public Member Functions

static std::string generateCurrentGameModificationString ()
 Returns a string identifying the currently running combination of game modifications. More...
 
- Static Public Member Functions inherited from qsf::UniqueInstance< NetworkManager >
static NetworkManager * getInstance ()
 Return the global unique instance. More...
 
static NetworkManager & getInstanceSafe ()
 Return the global unique instance. More...
 

Public Attributes

boost::signals2::signal< void(multiplayer::SessionBase &)> sessionBaseInstanceCreated
 

Static Public Attributes

static const uint16 MATCHMAKING_SERVER_PORT
 
static const uint16 MULTIPLAYER_PROXY_SERVER_PORT
 

Additional Inherited Members

- Protected Member Functions inherited from qsf::UniqueInstance< NetworkManager >
 UniqueInstance ()
 Default constructor. More...
 
virtual ~UniqueInstance ()
 Destructor. More...
 

Detailed Description

EMERGENCY 5 network manager class.

Constructor & Destructor Documentation

em5::NetworkManager::NetworkManager ( )

Default constructor.

virtual em5::NetworkManager::~NetworkManager ( )
virtual

Destructor.

Reimplemented from qsf::game::NetworkManager.

Member Function Documentation

void em5::NetworkManager::closeMultiplayerClient ( )

Closes the multiplayer client connection and destroys the instance.

void em5::NetworkManager::closeMultiplayerHost ( )

Closes the multiplayer host and destroys the instance.

void em5::NetworkManager::closeMultiplayerProxyClient ( )

Closes the multiplayer proxy client and destroys the instance.

multiplayer::client::Client* em5::NetworkManager::connectToLocalMultiplayerHost ( const std::string &  dataPath,
const MapIdentifier mapIdentifier,
const std::string &  playerName,
const std::string &  sessionPassword 
)

Creates a new MultiplayerClient object with a local host instance (This is only for testing)

Parameters
[in]dataPathThe path where the local client will find the files for the game player/command recorder.
Returns
The newly created MultiplayerClient object or nullptr on error
std::shared_ptr<MatchmakingClient> em5::NetworkManager::connectToMatchmakingServer ( )

Creates a new MatchmakingClient object and tries to connect to the master matchmaking server listening at the predefined hostname MATCHMAKING_SERVER_HOSTNAME and port MATCHMAKING_SERVER_PORT.

Returns
The newly created MatchmakingClient object or nullptr on error
Note
  • A weak pointer to the returned instance is cached and reused instead of creating a fresh connection as long as it stays valid
multiplayer::client::Client* em5::NetworkManager::connectToMultiplayerHost ( const multiplayer::HostEntry hostEntry,
const std::string &  playerName,
const std::string &  sessionPassword 
)

Creates a new MultiplayerClient object and tries to connect to a multiplayer host listening at the specified hostname and port.

Parameters
[in]hostnameHost name of the multiplayer host to connect to (can be an IP address, a windows host name or a domain)
[in]portPort number of the multiplayer host to connect to
Returns
The newly created MultiplayerClient object or nullptr on error
multiplayer::proxy::MultiplayerProxyClient* em5::NetworkManager::connectToMultiplayerProxyServer ( )

Creates a new MultiplayerProxyClient object (when not already created) and tries to connect to the proxy server (with default values for hostname and port.

Returns
The newly created MultiplayerProxyClient object or nullptr on error
Note
  • A pointer to the returned instance is cached and reused instead of creating a fresh connection as long as it stays valid
multiplayer::proxy::MultiplayerProxyClient* em5::NetworkManager::connectToMultiplayerProxyServer ( const std::string &  hostname,
uint16  port 
)

Creates a new MultiplayerProxyClient object(when not already created) and tries to connect to the proxy server.

Parameters
[in]hostnameThe hostname of the proxy server
[in]portThe port of the proxy server
Returns
The newly created MultiplayerProxyClient object or nullptr on error
Note
  • A pointer to the returned instance is cached and reused instead of creating a fresh connection as long as it stays valid
multiplayer::client::Client* em5::NetworkManager::createMultiplayerClient ( )

Creates a new MultiplayerClient object.

Returns
The newly created MultiplayerClient object or nullptr on error
multiplayer::server::Host* em5::NetworkManager::createMultiplayerHost ( )

Creates a new MultiplayerHost object.

Returns
The newly created MultiplayerHost object or nullptr on error
static std::string em5::NetworkManager::generateCurrentGameModificationString ( )
static

Returns a string identifying the currently running combination of game modifications.

Returns
A string identifying the currently running combination of game modifications
std::shared_ptr<MatchmakingClient> em5::NetworkManager::getMatchmakingClient ( ) const

Returns the stored MatchmakingClient object or nullptr, if there is none.

Returns
The stored MatchmakingClient object or nullptr, if there is none
multiplayer::client::Client* em5::NetworkManager::getMultiplayerClient ( ) const

Returns the stored MultiplayerClient object or nullptr, if there is none.

Returns
The stored MultiplayerClient object or nullptr, if there is none
multiplayer::server::Host* em5::NetworkManager::getMultiplayerHost ( ) const

Returns the stored MultiplayerHost object or nullptr, if there is none.

Returns
The stored MultiplayerHost object or nullptr, if there is none
multiplayer::proxy::MultiplayerProxyClient* em5::NetworkManager::getMultiplayerProxyClient ( ) const

Returns the stored MultiplayerProxyClient object or nullptr, if there is none.

Returns
The stored MultiplayerProxyClient object or nullptr, if there is none
multiplayer::SessionBase* em5::NetworkManager::getMultiplayerSession ( ) const

Returns the stored multiplayer session object or nullptr, if there is none (Can be either host or client)

Returns
The stored multiplayer session object or nullptr, if there is none
UpdateCheck& em5::NetworkManager::getUpdateCheck ( )

Return the update check instance, and creates it if needed.

bool em5::NetworkManager::isMultiplayActive ( ) const

Returns if a multiplay session is active (a multiplayer host or client exists)

virtual void em5::NetworkManager::onShutdown ( )
overridevirtual

Reimplemented from qsf::game::NetworkManager.

virtual bool em5::NetworkManager::onStartup ( )
overridevirtual

Reimplemented from qsf::game::NetworkManager.

void em5::NetworkManager::setMatchmakingUrlAndPort ( const std::string &  matchmakingUrl,
uint16  matchmakingPort 
)

Override the matchmaking url and port.

Parameters
[in]matchmakingUrlThe new url for the matchmaking server
[in]matchmakingPortThe new port for the matchmaking server
Note
  • When this method is called changes from an update check regarding matchmaking server is ignored and always the set values are used!
void em5::NetworkManager::setProxyUrlAndPort ( const std::string &  proxyUrl,
uint16  proxyPort 
)

Override the proxy url and port.

Parameters
[in]proxyUrlThe new url for the proxy server
[in]proxyPortThe new port for the proxy server

Member Data Documentation

const uint16 em5::NetworkManager::MATCHMAKING_SERVER_PORT
static
const uint16 em5::NetworkManager::MULTIPLAYER_PROXY_SERVER_PORT
static
boost::signals2::signal<void(multiplayer::SessionBase&)> em5::NetworkManager::sessionBaseInstanceCreated

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