78 static void Trace(JSTracer *trc,
void *data)
142 void GuiPoll(JS::MutableHandleValue);
290 #endif // NETCLIENT_H The container that holds the rules, resources and attributes of the game.
Definition: Game.h:40
ScriptInterface & GetScriptInterface()
Get the script interface associated with this network client, which is equivalent to the one used by ...
Definition: NetClient.cpp:272
void DestroyConnection()
Destroy the connection to the server.
Definition: NetClient.cpp:175
Manages states, events, actions and transitions between states.
Definition: fsm.h:117
void SendAssignPlayerMessage(const int playerID, const CStr &guid)
Definition: NetClient.cpp:338
std::map< CStr, PlayerAssignment > PlayerAssignmentMap
Definition: NetHost.h:54
static bool OnRejoined(void *context, CFsmEvent *event)
Definition: NetClient.cpp:691
std::time_t m_LastConnectionCheck
Time when the server was last checked for timeouts and bad latency.
Definition: NetClient.h:284
bool m_IsLocalClient
Whether to prevent the client of the host from timing out.
Definition: NetClient.h:266
CNetClientTurnManager * m_ClientTurnManager
Turn manager associated with the current game (or NULL if we haven't started the game yet) ...
Definition: NetClient.h:257
uint16_t u16
Definition: types.h:38
Represents a signal in the state machine that a change has occurred.
Definition: fsm.h:53
virtual ~CNetClient()
Definition: NetClient.cpp:142
CNetClientSession * m_Session
Current network session (or NULL if not connected)
Definition: NetClient.h:254
Definition: NetClient.h:44
void LoadFinished()
Call when the game has started and all data files have been loaded, to signal to the server that we a...
Definition: NetClient.cpp:436
static bool OnChat(void *context, CFsmEvent *event)
Definition: NetClient.cpp:550
Definition: NetClient.h:43
void GuiPoll(JS::MutableHandleValue)
Retrieves the next queued GUI message, and removes it from the queue.
Definition: NetClient.cpp:236
void SendKickPlayerMessage(const CStrW &playerName, bool ban)
Call to kick/ban a client.
Definition: NetClient.cpp:378
std::string TestReadGuiMessages()
Return a concatenation of all messages in the GUI queue, for test cases to easily verify the queue co...
Definition: NetClient.cpp:255
static bool OnClientTimeout(void *context, CFsmEvent *event)
Definition: NetClient.cpp:728
static bool OnHandshake(void *context, CFsmEvent *event)
Definition: NetClient.cpp:495
static bool OnLoadedGame(void *context, CFsmEvent *event)
Definition: NetClient.cpp:824
static bool OnInGame(void *context, CFsmEvent *event)
Definition: NetClient.cpp:847
void HandleConnect()
Call when the network connection has been successfully initiated.
Definition: NetClient.cpp:309
static bool OnAuthenticate(void *context, CFsmEvent *event)
Definition: NetClient.cpp:526
void HandleDisconnect(u32 reason)
Call when the network connection has been lost.
Definition: NetClient.cpp:314
void Flush()
Flush any queued outgoing network messages.
Definition: NetClient.cpp:230
void PostPlayerAssignmentsToScript()
Push a message onto the GUI queue listing the current player assignments.
Definition: NetClient.cpp:277
bool SendMessage(const CNetMessage *message)
Send a message to the server.
Definition: NetClient.cpp:301
uint32_t u32
Definition: types.h:39
bool SetupConnection(const CStr &server, const u16 port)
Set up a connection to the remote networked server.
Definition: NetClient.cpp:161
JS::PersistentRootedValue m_GameAttributes
Latest copy of game setup attributes heard from the server.
Definition: NetClient.h:269
static bool OnReady(void *context, CFsmEvent *event)
Definition: NetClient.cpp:569
Various declarations shared by networking code.
void SendPausedMessage(bool pause)
Call when the client has paused or unpaused the game.
Definition: NetClient.cpp:386
Definition: NetClient.h:42
static bool OnConnect(void *context, CFsmEvent *event)
Definition: NetClient.cpp:479
PlayerAssignmentMap m_PlayerAssignments
Latest copy of player assignments heard from the server.
Definition: NetClient.h:272
Definition: NetClient.h:45
void SetAndOwnSession(CNetClientSession *session)
Take ownership of a session object, and use it for all network communication.
Definition: NetClient.cpp:169
Definition: NetClient.h:46
CGame * m_Game
Definition: NetClient.h:250
static bool OnPlayerAssignment(void *context, CFsmEvent *event)
Definition: NetClient.cpp:608
u32 m_HostID
Unique-per-game identifier of this client, used to identify the sender of simulation commands...
Definition: NetClient.h:260
void SetUserName(const CStrW &username)
Set the user's name that will be displayed to all players.
Definition: NetClient.cpp:154
CStrW m_UserName
Definition: NetClient.h:251
static bool OnJoinSyncEndCommandBatch(void *context, CFsmEvent *event)
Definition: NetClient.cpp:675
Network server interface.
Definition: NetServer.h:98
void SendRejoinedMessage()
Call when the client has rejoined a running match and finished the loading screen.
Definition: NetClient.cpp:372
static bool OnGameSetup(void *context, CFsmEvent *event)
Definition: NetClient.cpp:588
void TraceMember(JSTracer *trc)
Definition: NetClient.cpp:148
CStr m_GUID
Globally unique identifier to distinguish users beyond the lifetime of a single network session...
Definition: NetClient.h:275
void SendReadyMessage(const int status)
Definition: NetClient.cpp:353
void Poll()
Poll the connection for messages from the server and process them, and send any queued messages...
Definition: NetClient.cpp:186
std::string m_JoinSyncBuffer
Serialized game state received when joining an in-progress game.
Definition: NetClient.h:281
The base class for all network messages exchanged within the game.
Definition: NetMessage.h:32
bool HandleMessage(CNetMessage *message)
Call when a message has been received from the network.
Definition: NetClient.cpp:393
static bool OnClientsLoading(void *context, CFsmEvent *event)
Definition: NetClient.cpp:783
static bool OnJoinSyncStart(void *context, CFsmEvent *event)
Definition: NetClient.cpp:661
std::deque< JS::Heap< JS::Value > > m_GuiMessageQueue
Queue of messages for GuiPoll.
Definition: NetClient.h:278
void SendGameSetupMessage(JS::MutableHandleValue attrs, ScriptInterface &scriptInterface)
Definition: NetClient.cpp:331
Async task for receiving the initial game state when rejoining an in-progress network game...
Definition: NetClient.cpp:44
Network client.
Definition: NetClient.h:57
void SendChatMessage(const std::wstring &text)
Definition: NetClient.cpp:346
static bool OnKicked(void *context, CFsmEvent *event)
Definition: NetClient.cpp:708
Implementation of CTurnManager for network clients.
Definition: NetClientTurnManager.h:29
static bool OnGameStart(void *context, CFsmEvent *event)
Definition: NetClient.cpp:635
static void Trace(JSTracer *trc, void *data)
We assume that adding a tracing function that's only called during GC is better for performance than ...
Definition: NetClient.h:78
static bool OnClientPaused(void *context, CFsmEvent *event)
Definition: NetClient.cpp:805
void PushGuiMessage(const JS::HandleValue message)
Add a message to the queue, to be read by GuiPoll.
Definition: NetClient.cpp:248
CStr GetGUID() const
Returns the GUID of the local client.
Definition: NetClient.h:95
Definition: NetClient.h:47
static bool OnClientPerformance(void *context, CFsmEvent *event)
Definition: NetClient.cpp:752
void SendClearAllReadyMessage()
Definition: NetClient.cpp:360
Abstraction around a SpiderMonkey JSContext.
Definition: ScriptInterface.h:71
bool m_Rejoin
True if the player is currently rejoining or has already rejoined the game.
Definition: NetClient.h:263
Definition: NetClient.h:40
Definition: NetClient.h:41
CNetClient * g_NetClient
Global network client for the standard game.
Definition: NetClient.cpp:38
Definition: NetClient.h:39
void SendStartGameMessage()
Definition: NetClient.cpp:366
The client end of a network session.
Definition: NetSession.h:65
CNetClient(CGame *game, bool isLocalClient)
Construct a client associated with the given game object.
Definition: NetClient.cpp:69
void CheckServerConnection()
Locally triggers a GUI message if the connection to the server is being lost or has bad latency...
Definition: NetClient.cpp:195
static bool OnHandshakeResponse(void *context, CFsmEvent *event)
Definition: NetClient.cpp:510