Changeset View
Changeset View
Standalone View
Standalone View
source/network/NetClient.h
Show All 12 Lines | |||||
* | * | ||||
* You should have received a copy of the GNU General Public License | * You should have received a copy of the GNU General Public License | ||||
* along with 0 A.D. If not, see <http://www.gnu.org/licenses/>. | * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>. | ||||
*/ | */ | ||||
#ifndef NETCLIENT_H | #ifndef NETCLIENT_H | ||||
#define NETCLIENT_H | #define NETCLIENT_H | ||||
#include "network/fsm.h" | #include "network/Fsm.h" | ||||
#include "network/NetFileTransfer.h" | #include "network/NetFileTransfer.h" | ||||
#include "network/NetHost.h" | #include "network/NetHost.h" | ||||
#include "scriptinterface/ScriptVal.h" | #include "scriptinterface/ScriptVal.h" | ||||
#include "ps/CStr.h" | #include "ps/CStr.h" | ||||
#include <deque> | #include <deque> | ||||
▲ Show 20 Lines • Show All 131 Lines • ▼ Show 20 Lines | public: | ||||
*/ | */ | ||||
ScriptInterface& GetScriptInterface(); | ScriptInterface& GetScriptInterface(); | ||||
/** | /** | ||||
* Send a message to the server. | * Send a message to the server. | ||||
* @param message message to send | * @param message message to send | ||||
* @return true on success | * @return true on success | ||||
*/ | */ | ||||
bool SendMessage(const CNetMessage* message); | bool SendMessage(const CNetMessageBuffer& message); | ||||
/** | /** | ||||
* Call when the network connection has been successfully initiated. | * Call when the network connection has been successfully initiated. | ||||
*/ | */ | ||||
void HandleConnect(); | void HandleConnect(); | ||||
/** | /** | ||||
* Call when the network connection has been lost. | * Call when the network connection has been lost. | ||||
*/ | */ | ||||
void HandleDisconnect(u32 reason); | void HandleDisconnect(u32 reason); | ||||
/** | /** | ||||
* Call when a message has been received from the network. | * Call when a message has been received from the network. | ||||
*/ | */ | ||||
bool HandleMessage(CNetMessage* message); | bool HandleMessage(const CNetMessageBuffer& message); | ||||
/** | /** | ||||
* Call when the game has started and all data files have been loaded, | * Call when the game has started and all data files have been loaded, | ||||
* to signal to the server that we are ready to begin the game. | * to signal to the server that we are ready to begin the game. | ||||
*/ | */ | ||||
void LoadFinished(); | void LoadFinished(); | ||||
void SendGameSetupMessage(JS::MutableHandleValue attrs, ScriptInterface& scriptInterface); | void SendGameSetupMessage(JS::MutableHandleValue attrs, ScriptInterface& scriptInterface); | ||||
Show All 21 Lines | public: | ||||
/** | /** | ||||
* Call when the client has paused or unpaused the game. | * Call when the client has paused or unpaused the game. | ||||
*/ | */ | ||||
void SendPausedMessage(bool pause); | void SendPausedMessage(bool pause); | ||||
private: | private: | ||||
// Net message / FSM transition handlers | // Net message / FSM transition handlers | ||||
static bool OnConnect(void* context, CFsmEvent* event); | static bool OnConnect(void* context, const CFsmEvent& event); | ||||
static bool OnHandshake(void* context, CFsmEvent* event); | static bool OnHandshake(void* context, const CFsmEvent& event); | ||||
static bool OnHandshakeResponse(void* context, CFsmEvent* event); | static bool OnHandshakeResponse(void* context, const CFsmEvent& event); | ||||
static bool OnAuthenticate(void* context, CFsmEvent* event); | static bool OnAuthenticate(void* context, const CFsmEvent& event); | ||||
static bool OnChat(void* context, CFsmEvent* event); | static bool OnChat(void* context, const CFsmEvent& event); | ||||
static bool OnReady(void* context, CFsmEvent* event); | static bool OnReady(void* context, const CFsmEvent& event); | ||||
static bool OnGameSetup(void* context, CFsmEvent* event); | static bool OnGameSetup(void* context, const CFsmEvent& event); | ||||
static bool OnPlayerAssignment(void* context, CFsmEvent* event); | static bool OnPlayerAssignment(void* context, const CFsmEvent& event); | ||||
static bool OnInGame(void* context, CFsmEvent* event); | static bool OnInGame(void* context, const CFsmEvent& event); | ||||
static bool OnGameStart(void* context, CFsmEvent* event); | static bool OnGameStart(void* context, const CFsmEvent& event); | ||||
static bool OnJoinSyncStart(void* context, CFsmEvent* event); | static bool OnJoinSyncStart(void* context, const CFsmEvent& event); | ||||
static bool OnJoinSyncEndCommandBatch(void* context, CFsmEvent* event); | static bool OnJoinSyncEndCommandBatch(void* context, const CFsmEvent& event); | ||||
static bool OnRejoined(void* context, CFsmEvent* event); | static bool OnRejoined(void* context, const CFsmEvent& event); | ||||
static bool OnKicked(void* context, CFsmEvent* event); | static bool OnKicked(void* context, const CFsmEvent& event); | ||||
static bool OnClientTimeout(void* context, CFsmEvent* event); | static bool OnClientTimeout(void* context, const CFsmEvent& event); | ||||
static bool OnClientPerformance(void* context, CFsmEvent* event); | static bool OnClientPerformance(void* context, const CFsmEvent& event); | ||||
static bool OnClientsLoading(void* context, CFsmEvent* event); | static bool OnClientsLoading(void* context, const CFsmEvent& event); | ||||
static bool OnClientPaused(void* context, CFsmEvent* event); | static bool OnClientPaused(void* context, const CFsmEvent& event); | ||||
static bool OnLoadedGame(void* context, CFsmEvent* event); | static bool OnLoadedGame(void* context, const CFsmEvent& event); | ||||
/** | /** | ||||
* Take ownership of a session object, and use it for all network communication. | * Take ownership of a session object, and use it for all network communication. | ||||
*/ | */ | ||||
void SetAndOwnSession(CNetClientSession* session); | void SetAndOwnSession(CNetClientSession* session); | ||||
/** | /** | ||||
* Push a message onto the GUI queue listing the current player assignments. | * Push a message onto the GUI queue listing the current player assignments. | ||||
▲ Show 20 Lines • Show All 44 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator