Pyrogenesis  trunk
Public Member Functions | Private Member Functions | Private Attributes | List of all members
CNetServer Class Reference

Network server interface. More...

#include <NetServer.h>

Collaboration diagram for CNetServer:
Collaboration graph
[legend]

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

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.

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

Member Function Documentation

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.

bool CNetServer::SetupConnection ( const u16  port)

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

Parameters
attrsgame attributes, in the script context of scriptInterface

Member Data Documentation

CNetServerWorker* CNetServer::m_Worker
private

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