Pyrogenesis  13997
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Private Member Functions | Private Attributes | List of all members
CNetServer Class Reference

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

CNetServerWorkerm_Worker
 

Detailed Description

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.

Constructor & Destructor Documentation

CNetServer::CNetServer ( int  autostartPlayers = -1)

Construct a new network server.

Parameters
autostartPlayersif 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.

Member Function Documentation

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.

CNetServer::NONCOPYABLE ( 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.

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).

Returns
true on success, false on error (e.g. port already in use)

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.

Parameters
attrsgame attributes, in the script context of scriptInterface

Definition at line 945 of file NetServer.cpp.

Member Data Documentation

CNetServerWorker* CNetServer::m_Worker
private

Definition at line 145 of file NetServer.h.


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