Pyrogenesis
13997
|
Network server interface. More...
#include <NetServer.h>
Public Member Functions | |
CNetServer (int autostartPlayers=-1) | |
Construct a new network server. More... | |
~CNetServer () | |
bool | SetupConnection () |
Begin listening for network connections. More... | |
void | AssignPlayer (int playerID, const CStr &guid) |
Call from the GUI to update the player assignments. More... | |
void | StartGame () |
Call from the GUI to asynchronously notify all clients that they should start loading the game. More... | |
void | UpdateGameAttributes (const CScriptVal &attrs, ScriptInterface &scriptInterface) |
Call from the GUI to update the game setup attributes. More... | |
void | SetTurnLength (u32 msecs) |
Set the turn length to a fixed value. More... | |
Private Member Functions | |
NONCOPYABLE (CNetServer) | |
Private Attributes | |
CNetServerWorker * | m_Worker |
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.
Definition at line 97 of file NetServer.h.
CNetServer::CNetServer | ( | int | autostartPlayers = -1 | ) |
Construct a new network server.
autostartPlayers | if positive then StartGame will be called automatically once this many players are connected (intended for the command-line testing mode). |
Definition at line 918 of file NetServer.cpp.
CNetServer::~CNetServer | ( | ) |
Definition at line 923 of file NetServer.cpp.
void CNetServer::AssignPlayer | ( | int | playerID, |
const CStr & | guid | ||
) |
Call from the GUI to update the player assignments.
The given GUID will be (re)assigned to the given player ID. Any player currently using that ID will be unassigned. The changes will be asynchronously propagated to all clients.
Definition at line 933 of file NetServer.cpp.
|
private |
void CNetServer::SetTurnLength | ( | u32 | msecs | ) |
Set the turn length to a fixed value.
TODO: we should replace this with some adapative lag-dependent computation.
Definition at line 955 of file NetServer.cpp.
bool CNetServer::SetupConnection | ( | ) |
Begin listening for network connections.
This function is synchronous (it won't return until the connection is established).
Definition at line 928 of file NetServer.cpp.
void CNetServer::StartGame | ( | ) |
Call from the GUI to asynchronously notify all clients that they should start loading the game.
Definition at line 939 of file NetServer.cpp.
void CNetServer::UpdateGameAttributes | ( | const CScriptVal & | attrs, |
ScriptInterface & | scriptInterface | ||
) |
Call from the GUI to update the game setup attributes.
This must be called at least once before starting the game. The changes will be asynchronously propagated to all clients.
attrs | game attributes, in the script context of scriptInterface |
Definition at line 945 of file NetServer.cpp.
|
private |
Definition at line 145 of file NetServer.h.