226 #endif // NETCLIENT_H
The container that holds the rules, resources and attributes of the game.
ScriptInterface & GetScriptInterface()
Get the script interface associated with this network client, which is equivalent to the one used by ...
void DestroyConnection()
Destroy the connection to the server.
Manages states, events, actions and transitions between states.
std::map< CStr, PlayerAssignment > PlayerAssignmentMap
CNetClient * g_NetClient
Global network client for the standard game.
CStr GenerateGUID()
Initialise m_GUID with a random value.
CNetClientTurnManager * m_ClientTurnManager
Turn manager associated with the current game (or NULL if we haven't started the game yet) ...
Represents a signal in the state machine that a change has occurred.
CNetClientSession * m_Session
Current network session (or NULL if not connected)
void LoadFinished()
Call when the game has started and all data files have been loaded, to signal to the server that we a...
static bool OnChat(void *context, CFsmEvent *event)
CScriptValRooted GuiPoll()
Retrieves the next queued GUI message, and removes it from the queue.
void PushGuiMessage(const CScriptValRooted &message)
Add a message to the queue, to be read by GuiPoll.
static bool OnHandshake(void *context, CFsmEvent *event)
static bool OnLoadedGame(void *context, CFsmEvent *event)
static bool OnInGame(void *context, CFsmEvent *event)
void HandleConnect()
Call when the network connection has been successfully initiated.
static bool OnAuthenticate(void *context, CFsmEvent *event)
void HandleDisconnect(u32 reason)
Call when the network connection has been lost.
void Flush()
Flush any queued outgoing network messages.
void PostPlayerAssignmentsToScript()
Push a message onto the GUI queue listing the current player assignments.
bool SendMessage(const CNetMessage *message)
Send a message to the server.
std::deque< CScriptValRooted > m_GuiMessageQueue
Queue of messages for GuiPoll.
Various declarations shared by networking code.
CNetClient(CGame *game)
Construct a client associated with the given game object.
static bool OnConnect(void *context, CFsmEvent *event)
PlayerAssignmentMap m_PlayerAssignments
Latest copy of player assignments heard from the server.
void SetAndOwnSession(CNetClientSession *session)
Take ownership of a session object, and use it for all network communication.
static bool OnPlayerAssignment(void *context, CFsmEvent *event)
u32 m_HostID
Unique-per-game identifier of this client, used to identify the sender of simulation commands...
void SetUserName(const CStrW &username)
Set the user's name that will be displayed to all players.
static bool OnJoinSyncEndCommandBatch(void *context, CFsmEvent *event)
Network server interface.
static bool OnGameSetup(void *context, CFsmEvent *event)
CStr m_GUID
Globally unique identifier to distinguish users beyond the lifetime of a single network session...
void Poll()
Poll the connection for messages from the server and process them, and send any queued messages...
std::string m_JoinSyncBuffer
Serialized game state received when joining an in-progress game.
CScriptValRooted m_GameAttributes
Latest copy of game setup attributes heard from the server.
The base class for all network messages exchanged within the game.
bool HandleMessage(CNetMessage *message)
Call when a message has been received from the network.
static bool OnJoinSyncStart(void *context, CFsmEvent *event)
bool SetupConnection(const CStr &server)
Set up a connection to the remote networked server.
Async task for receiving the initial game state when rejoining an in-progress network game...
void SendChatMessage(const std::wstring &text)
Implementation of CNetTurnManager for network clients.
static bool OnGameStart(void *context, CFsmEvent *event)
Abstraction around a SpiderMonkey JSContext.
The client end of a network session.
std::wstring TestReadGuiMessages()
Return a concatenation of all messages in the GUI queue, for test cases to easily verify the queue co...
static bool OnHandshakeResponse(void *context, CFsmEvent *event)