Changeset View
Changeset View
Standalone View
Standalone View
source/network/NetServer.h
Show All 27 Lines | |||||
#include <vector> | #include <vector> | ||||
class CNetServerSession; | class CNetServerSession; | ||||
class CNetServerTurnManager; | class CNetServerTurnManager; | ||||
class CFsmEvent; | class CFsmEvent; | ||||
class ScriptInterface; | class ScriptInterface; | ||||
class CPlayerAssignmentMessage; | class CPlayerAssignmentMessage; | ||||
class CNetStatsTable; | class CNetStatsTable; | ||||
class CSimulationMessage; | |||||
class CNetServerWorker; | class CNetServerWorker; | ||||
enum NetServerState | enum NetServerState | ||||
{ | { | ||||
// We haven't opened the port yet, we're just setting some stuff up. | // We haven't opened the port yet, we're just setting some stuff up. | ||||
// The worker thread has not been started. | // The worker thread has not been started. | ||||
SERVER_STATE_UNCONNECTED, | SERVER_STATE_UNCONNECTED, | ||||
▲ Show 20 Lines • Show All 109 Lines • ▼ Show 20 Lines | class CNetServerWorker | ||||
NONCOPYABLE(CNetServerWorker); | NONCOPYABLE(CNetServerWorker); | ||||
public: | public: | ||||
// Public functions for CNetSession/CNetServerTurnManager to use: | // Public functions for CNetSession/CNetServerTurnManager to use: | ||||
/** | /** | ||||
* Send a message to the given network peer. | * Send a message to the given network peer. | ||||
*/ | */ | ||||
bool SendMessage(ENetPeer* peer, const CNetMessage* message); | bool SendMessage(ENetPeer* peer, const CNetMessageBuffer& message); | ||||
/** | /** | ||||
* Disconnects a player from gamesetup or session. | * Disconnects a player from gamesetup or session. | ||||
*/ | */ | ||||
void KickPlayer(const CStrW& playerName, const bool ban); | void KickPlayer(const CStrW& playerName, const bool ban); | ||||
/** | /** | ||||
* Send a message to all clients who match one of the given states. | * Send a message to all clients who match one of the given states. | ||||
*/ | */ | ||||
bool Broadcast(const CNetMessage* message, const std::vector<NetServerSessionState>& targetStates); | bool Broadcast(const CNetMessageBuffer& message, const std::vector<NetServerSessionState>& targetStates); | ||||
private: | private: | ||||
friend class CNetServer; | friend class CNetServer; | ||||
friend class CNetFileReceiveTask_ServerRejoin; | friend class CNetFileReceiveTask_ServerRejoin; | ||||
CNetServerWorker(int autostartPlayers); | CNetServerWorker(int autostartPlayers); | ||||
~CNetServerWorker(); | ~CNetServerWorker(); | ||||
▲ Show 20 Lines • Show All 51 Lines • ▼ Show 20 Lines | private: | ||||
void ClearAllPlayerReady(); | void ClearAllPlayerReady(); | ||||
void SetupSession(CNetServerSession* session); | void SetupSession(CNetServerSession* session); | ||||
bool HandleConnect(CNetServerSession* session); | bool HandleConnect(CNetServerSession* session); | ||||
void OnUserJoin(CNetServerSession* session); | void OnUserJoin(CNetServerSession* session); | ||||
void OnUserLeave(CNetServerSession* session); | void OnUserLeave(CNetServerSession* session); | ||||
static bool OnClientHandshake(void* context, CFsmEvent* event); | static bool OnClientHandshake(void* context, const CFsmEvent* event); | ||||
static bool OnAuthenticate(void* context, CFsmEvent* event); | static bool OnAuthenticate(void* context, const CFsmEvent* event); | ||||
static bool OnInGame(void* context, CFsmEvent* event); | static bool OnInGame(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 OnClearAllReady(void* context, CFsmEvent* event); | static bool OnClearAllReady(void* context, const CFsmEvent* event); | ||||
static bool OnGameSetup(void* context, CFsmEvent* event); | static bool OnGameSetup(void* context, const CFsmEvent* event); | ||||
static bool OnAssignPlayer(void* context, CFsmEvent* event); | static bool OnAssignPlayer(void* context, const CFsmEvent* event); | ||||
static bool OnStartGame(void* context, CFsmEvent* event); | static bool OnStartGame(void* context, const CFsmEvent* event); | ||||
static bool OnLoadedGame(void* context, CFsmEvent* event); | static bool OnLoadedGame(void* context, const CFsmEvent* event); | ||||
static bool OnJoinSyncingLoadedGame(void* context, CFsmEvent* event); | static bool OnJoinSyncingLoadedGame(void* context, const CFsmEvent* event); | ||||
static bool OnRejoined(void* context, CFsmEvent* event); | static bool OnRejoined(void* context, const CFsmEvent* event); | ||||
static bool OnKickPlayer(void* context, CFsmEvent* event); | static bool OnKickPlayer(void* context, const CFsmEvent* event); | ||||
static bool OnDisconnect(void* context, CFsmEvent* event); | static bool OnDisconnect(void* context, const CFsmEvent* event); | ||||
static bool OnClientPaused(void* context, CFsmEvent* event); | static bool OnClientPaused(void* context, const CFsmEvent* event); | ||||
leper: I might be missing something, but can't event be a reference? | |||||
/** | /** | ||||
* Checks if all clients have finished loading. | * Checks if all clients have finished loading. | ||||
* If so informs the clients about that and change the server state. | * If so informs the clients about that and change the server state. | ||||
* | * | ||||
* Returns if all clients finished loading. | * Returns if all clients finished loading. | ||||
*/ | */ | ||||
bool CheckGameLoadStatus(CNetServerSession* changedSession); | bool CheckGameLoadStatus(CNetServerSession* changedSession); | ||||
void ConstructPlayerAssignmentMessage(CPlayerAssignmentMessage& message); | void ConstructPlayerAssignmentMessage(CPlayerAssignmentMessage& message); | ||||
void HandleMessageReceive(const CNetMessage* message, CNetServerSession* session); | void HandleMessageReceive(const CNetMessageBuffer& message, CNetServerSession* session); | ||||
/** | /** | ||||
* Send a network warning if the connection to a client is being lost or has bad latency. | * Send a network warning if the connection to a client is being lost or has bad latency. | ||||
*/ | */ | ||||
void CheckClientConnections(); | void CheckClientConnections(); | ||||
/** | /** | ||||
* Internal script context for (de)serializing script messages, | * Internal script context for (de)serializing script messages, | ||||
▲ Show 20 Lines • Show All 87 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
I might be missing something, but can't event be a reference?