33 class CPlayerAssignmentMessage;
233 void AddPlayer(
const CStr& guid,
const CStrW& name);
321 #endif // NETSERVER_H
ScriptInterface * m_ScriptInterface
Internal script context for (de)serializing script messages, and for storing game attributes...
void StartGame()
Call from the GUI to asynchronously notify all clients that they should start loading the game...
std::map< CStr, PlayerAssignment > PlayerAssignmentMap
static bool OnClientHandshake(void *context, CFsmEvent *event)
void OnUserLeave(CNetServerSession *session)
static void * RunThread(void *data)
std::vector< std::vector< CSimulationMessage > > m_SavedCommands
A copy of all simulation commands received so far, indexed by turn number, to simplify support for re...
static bool OnJoinSyncingLoadedGame(void *context, CFsmEvent *event)
std::string m_JoinSyncFile
The latest copy of the simulation state, received from an existing client when a new client has asked...
Represents a signal in the state machine that a change has occurred.
void CheckGameLoadStatus(CNetServerSession *changedSession)
bool SetupConnection()
Begin listening for network connections.
void HandleMessageReceive(const CNetMessage *message, CNetServerSession *session)
Async task for receiving the initial game state to be forwarded to another client that is rejoining a...
bool SetupConnection()
Begin listening for network connections.
void StartGame()
Call from the GUI to notify all clients that they should start loading the game.
void AddPlayer(const CStr &guid, const CStrW &name)
void UpdateGameAttributes(const CScriptValRooted &attrs)
Call from the GUI to update the game setup attributes.
static bool OnChat(void *context, CFsmEvent *event)
static bool OnInGame(void *context, CFsmEvent *event)
CNetServer * g_NetServer
Global network server for the standard game.
A trivial wrapper around a jsval.
CNetServerWorker(int autostartPlayers)
static CStrW SanitisePlayerName(const CStrW &original)
Make a player name 'nicer' by limiting the length and removing forbidden characters etc...
struct _ENetPeer ENetPeer
A non-recursive mutual exclusion lock.
NONCOPYABLE(CNetServerWorker)
std::vector< std::string > m_GameAttributesQueue
CNetServer(int autostartPlayers=-1)
Construct a new network server.
void SetTurnLength(u32 msecs)
Set the turn length to a fixed value.
Various declarations shared by networking code.
void AssignPlayer(int playerID, const CStr &guid)
Call from the GUI to update the player assignments.
void AssignPlayer(int playerID, const CStr &guid)
Call from the GUI to update the player assignments.
std::vector< std::pair< int, CStr > > m_AssignPlayerQueue
CScriptValRooted m_GameAttributes
CStrW DeduplicatePlayerName(const CStrW &original)
Make a player name unique, if it matches any existing session's name.
void UpdateGameAttributes(const CScriptVal &attrs, ScriptInterface &scriptInterface)
Call from the GUI to update the game setup attributes.
NetServerSessionState
Server session representation of client state.
void SetupSession(CNetServerSession *session)
Network server interface.
void ConstructPlayerAssignmentMessage(CPlayerAssignmentMessage &message)
ENet connection statistics profiler table.
std::vector< bool > m_StartGameQueue
std::vector< u32 > m_TurnLengthQueue
std::vector< CNetServerSession * > m_Sessions
The base class for all network messages exchanged within the game.
void OnUserJoin(CNetServerSession *session)
CNetServerWorker * m_Worker
bool HandleConnect(CNetServerSession *session)
void SetTurnLength(u32 msecs)
Set the turn length to a fixed value.
static bool OnAuthenticate(void *context, CFsmEvent *event)
struct _ENetHost ENetHost
bool Broadcast(const CNetMessage *message)
Send a message to all clients who have completed the full connection process (i.e.
static bool OnLoadedGame(void *context, CFsmEvent *event)
bool SendMessage(ENetPeer *peer, const CNetMessage *message)
Send a message to the given network peer.
Abstraction around a SpiderMonkey JSContext.
void SendPlayerAssignments()
ScriptInterface & GetScriptInterface()
Get the script context used for game attributes.
CNetServerTurnManager * m_ServerTurnManager
PlayerAssignmentMap m_PlayerAssignments
static bool OnDisconnect(void *context, CFsmEvent *event)
Network server worker thread.
The server's end of a network session.
void RemovePlayer(const CStr &guid)
The server-side counterpart to CNetClientTurnManager.
Special message type for simulation commands.