Pyrogenesis HEAD
Pyrogenesis, a RTS Engine
|
Network server interface. More...
#include <NetServer.h>
Public Member Functions | |
CNetServer (bool useLobbyAuth=false) | |
Construct a new network server. More... | |
~CNetServer () | |
bool | SetupConnection (const u16 port) |
Begin listening for network connections. More... | |
void | StartGame () |
Call from the GUI to asynchronously notify all clients that they should start loading the game. More... | |
void | UpdateInitAttributes (JS::MutableHandleValue attrs, const ScriptRequest &rq) |
Call from the GUI to update the game setup attributes. More... | |
void | SetTurnLength (u32 msecs) |
Set the turn length to a fixed value. More... | |
bool | UseLobbyAuth () const |
void | OnLobbyAuth (const CStr &name, const CStr &token) |
void | SendHolePunchingMessage (const CStr &ip, u16 port) |
void | SetConnectionData (const CStr &ip, u16 port) |
bool | SetConnectionDataViaSTUN () |
bool | GetUseSTUN () const |
CStr | GetPublicIp () const |
Return the externally accessible IP. More... | |
u16 | GetPublicPort () const |
Return the externally accessible port. More... | |
u16 | GetLocalPort () const |
Return the serving port on the local machine. More... | |
bool | CheckPasswordAndIncrement (const std::string &username, const std::string &password, const std::string &salt) |
Check if password is valid. More... | |
bool | IsBanned (const std::string &username) const |
Check if user reached certain number of failed attempts. More... | |
void | SetPassword (const CStr &password) |
void | SetControllerSecret (const std::string &secret) |
Private Member Functions | |
NONCOPYABLE (CNetServer) | |
Private Attributes | |
CNetServerWorker * | m_Worker |
const bool | m_LobbyAuth |
bool | m_UseSTUN |
u16 | m_PublicPort |
CStr | m_PublicIp |
CStr | m_Password |
std::unordered_map< std::string, int > | m_FailedAttempts |
Network server interface.
Handles all the coordination between players. One person runs this object, and every player (including the host) connects their CNetClient to it.
The actual work is performed by CNetServerWorker in a separate thread.
CNetServer::CNetServer | ( | bool | useLobbyAuth = false | ) |
Construct a new network server.
once this many players are connected (intended for the command-line testing mode).
CNetServer::~CNetServer | ( | ) |
bool CNetServer::CheckPasswordAndIncrement | ( | const std::string & | username, |
const std::string & | password, | ||
const std::string & | salt | ||
) |
Check if password is valid.
If is not, increase number of failed attempts of the lobby user. This is used without established direct session with the client, to prevent brute force attacks when guessing password trying to get connection data from the host.
u16 CNetServer::GetLocalPort | ( | ) | const |
Return the serving port on the local machine.
CStr CNetServer::GetPublicIp | ( | ) | const |
Return the externally accessible IP.
u16 CNetServer::GetPublicPort | ( | ) | const |
Return the externally accessible port.
bool CNetServer::GetUseSTUN | ( | ) | const |
bool CNetServer::IsBanned | ( | const std::string & | username | ) | const |
Check if user reached certain number of failed attempts.
|
private |
void CNetServer::OnLobbyAuth | ( | const CStr & | name, |
const CStr & | token | ||
) |
void CNetServer::SendHolePunchingMessage | ( | const CStr & | ip, |
u16 | port | ||
) |
void CNetServer::SetConnectionData | ( | const CStr & | ip, |
u16 | port | ||
) |
bool CNetServer::SetConnectionDataViaSTUN | ( | ) |
void CNetServer::SetControllerSecret | ( | const std::string & | secret | ) |
void CNetServer::SetPassword | ( | const CStr & | password | ) |
void CNetServer::SetTurnLength | ( | u32 | msecs | ) |
Set the turn length to a fixed value.
TODO: we should replace this with some adapative lag-dependent computation.
bool CNetServer::SetupConnection | ( | const u16 | port | ) |
Begin listening for network connections.
This function is synchronous (it won't return until the connection is established).
void CNetServer::StartGame | ( | ) |
Call from the GUI to asynchronously notify all clients that they should start loading the game.
UpdateInitAttributes must be called at least once.
void CNetServer::UpdateInitAttributes | ( | JS::MutableHandleValue | attrs, |
const ScriptRequest & | rq | ||
) |
Call from the GUI to update the game setup attributes.
The changes won't be propagated to clients until game start.
attrs | init attributes, in the script context of rq |
bool CNetServer::UseLobbyAuth | ( | ) | const |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |