Pyrogenesis
trunk
|
Network server interface. More...
#include <NetServer.h>
Public Member Functions | |
CNetServer (int autostartPlayers=-1) | |
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 | UpdateGameAttributes (JS::MutableHandleValue 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.
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). |
CNetServer::~CNetServer | ( | ) |
|
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.
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.
void CNetServer::UpdateGameAttributes | ( | JS::MutableHandleValue | 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 |
|
private |