Pyrogenesis
13997
|
Network server worker thread. More...
#include <NetServer.h>
Public Member Functions | |
bool | SendMessage (ENetPeer *peer, const CNetMessage *message) |
Send a message to the given network peer. More... | |
bool | Broadcast (const CNetMessage *message) |
Send a message to all clients who have completed the full connection process (i.e. More... | |
Private Member Functions | |
NONCOPYABLE (CNetServerWorker) | |
CNetServerWorker (int autostartPlayers) | |
~CNetServerWorker () | |
bool | SetupConnection () |
Begin listening for network connections. More... | |
void | AssignPlayer (int playerID, const CStr &guid) |
Call from the GUI to update the player assignments. More... | |
void | StartGame () |
Call from the GUI to notify all clients that they should start loading the game. More... | |
void | UpdateGameAttributes (const CScriptValRooted &attrs) |
Call from the GUI to update the game setup attributes. More... | |
CStrW | DeduplicatePlayerName (const CStrW &original) |
Make a player name unique, if it matches any existing session's name. More... | |
ScriptInterface & | GetScriptInterface () |
Get the script context used for game attributes. More... | |
void | SetTurnLength (u32 msecs) |
Set the turn length to a fixed value. More... | |
void | AddPlayer (const CStr &guid, const CStrW &name) |
void | RemovePlayer (const CStr &guid) |
void | SendPlayerAssignments () |
void | SetupSession (CNetServerSession *session) |
bool | HandleConnect (CNetServerSession *session) |
void | OnUserJoin (CNetServerSession *session) |
void | OnUserLeave (CNetServerSession *session) |
void | CheckGameLoadStatus (CNetServerSession *changedSession) |
void | ConstructPlayerAssignmentMessage (CPlayerAssignmentMessage &message) |
void | HandleMessageReceive (const CNetMessage *message, CNetServerSession *session) |
void | Run () |
bool | RunStep () |
Static Private Member Functions | |
static CStrW | SanitisePlayerName (const CStrW &original) |
Make a player name 'nicer' by limiting the length and removing forbidden characters etc. More... | |
static bool | OnClientHandshake (void *context, CFsmEvent *event) |
static bool | OnAuthenticate (void *context, CFsmEvent *event) |
static bool | OnInGame (void *context, CFsmEvent *event) |
static bool | OnChat (void *context, CFsmEvent *event) |
static bool | OnLoadedGame (void *context, CFsmEvent *event) |
static bool | OnJoinSyncingLoadedGame (void *context, CFsmEvent *event) |
static bool | OnDisconnect (void *context, CFsmEvent *event) |
static void * | RunThread (void *data) |
Private Attributes | |
ScriptInterface * | m_ScriptInterface |
Internal script context for (de)serializing script messages, and for storing game attributes. More... | |
PlayerAssignmentMap | m_PlayerAssignments |
CScriptValRooted | m_GameAttributes |
int | m_AutostartPlayers |
ENetHost * | m_Host |
std::vector< CNetServerSession * > | m_Sessions |
CNetStatsTable * | m_Stats |
NetServerState | m_State |
CStrW | m_ServerName |
CStrW | m_WelcomeMessage |
u32 | m_NextHostID |
CNetServerTurnManager * | m_ServerTurnManager |
std::vector< std::vector < CSimulationMessage > > | m_SavedCommands |
A copy of all simulation commands received so far, indexed by turn number, to simplify support for rejoining etc. More... | |
std::string | m_JoinSyncFile |
The latest copy of the simulation state, received from an existing client when a new client has asked to rejoin the game. More... | |
pthread_t | m_WorkerThread |
CMutex | m_WorkerMutex |
bool | m_Shutdown |
std::vector< std::pair< int, CStr > > | m_AssignPlayerQueue |
std::vector< bool > | m_StartGameQueue |
std::vector< std::string > | m_GameAttributesQueue |
std::vector< u32 > | m_TurnLengthQueue |
Friends | |
class | CNetServer |
class | CNetFileReceiveTask_ServerRejoin |
Network server worker thread.
(This is run in a thread so that client/server communication is not delayed by the host player's framerate - the only delay should be the network latency.)
Thread-safety:
Definition at line 160 of file NetServer.h.
|
private |
Definition at line 111 of file NetServer.cpp.
|
private |
Definition at line 125 of file NetServer.cpp.
|
private |
Definition at line 481 of file NetServer.cpp.
|
private |
Call from the GUI to update the player assignments.
The given GUID will be (re)assigned to the given player ID. Any player currently using that ID will be unassigned. The changes will be propagated to all clients.
Definition at line 549 of file NetServer.cpp.
bool CNetServerWorker::Broadcast | ( | const CNetMessage * | message | ) |
Send a message to all clients who have completed the full connection process (i.e.
are in the pre-game or in-game states).
Definition at line 197 of file NetServer.cpp.
|
private |
Definition at line 824 of file NetServer.cpp.
|
private |
Definition at line 565 of file NetServer.cpp.
|
private |
Make a player name unique, if it matches any existing session's name.
Definition at line 890 of file NetServer.cpp.
|
private |
Get the script context used for game attributes.
Definition at line 587 of file NetServer.cpp.
|
private |
Definition at line 448 of file NetServer.cpp.
|
private |
Definition at line 392 of file NetServer.cpp.
|
private |
|
staticprivate |
Definition at line 621 of file NetServer.cpp.
|
staticprivate |
Definition at line 730 of file NetServer.cpp.
|
staticprivate |
Definition at line 598 of file NetServer.cpp.
|
staticprivate |
Definition at line 812 of file NetServer.cpp.
|
staticprivate |
Definition at line 692 of file NetServer.cpp.
|
staticprivate |
Definition at line 761 of file NetServer.cpp.
|
staticprivate |
Definition at line 746 of file NetServer.cpp.
|
private |
Definition at line 457 of file NetServer.cpp.
|
private |
Definition at line 470 of file NetServer.cpp.
|
private |
Definition at line 542 of file NetServer.cpp.
|
private |
Definition at line 228 of file NetServer.cpp.
|
private |
Definition at line 254 of file NetServer.cpp.
|
staticprivate |
Definition at line 219 of file NetServer.cpp.
|
staticprivate |
Make a player name 'nicer' by limiting the length and removing forbidden characters etc.
Definition at line 868 of file NetServer.cpp.
bool CNetServerWorker::SendMessage | ( | ENetPeer * | peer, |
const CNetMessage * | message | ||
) |
Send a message to the given network peer.
Definition at line 188 of file NetServer.cpp.
|
private |
Definition at line 580 of file NetServer.cpp.
|
private |
Set the turn length to a fixed value.
TODO: we should replace this with some adaptive lag-dependent computation.
Definition at line 592 of file NetServer.cpp.
|
private |
Begin listening for network connections.
Definition at line 157 of file NetServer.cpp.
|
private |
Definition at line 418 of file NetServer.cpp.
|
private |
Call from the GUI to notify all clients that they should start loading the game.
Definition at line 839 of file NetServer.cpp.
|
private |
Call from the GUI to update the game setup attributes.
This must be called at least once before starting the game. The changes will be propagated to all clients.
attrs | game attributes, in the script context of GetScriptInterface() |
Definition at line 856 of file NetServer.cpp.
|
friend |
Definition at line 180 of file NetServer.h.
|
friend |
Definition at line 179 of file NetServer.h.
|
private |
Definition at line 312 of file NetServer.h.
|
private |
Definition at line 270 of file NetServer.h.
|
private |
Definition at line 268 of file NetServer.h.
|
private |
Definition at line 314 of file NetServer.h.
|
private |
Definition at line 272 of file NetServer.h.
|
private |
The latest copy of the simulation state, received from an existing client when a new client has asked to rejoin the game.
Definition at line 297 of file NetServer.h.
|
private |
Definition at line 282 of file NetServer.h.
|
private |
Definition at line 266 of file NetServer.h.
|
private |
A copy of all simulation commands received so far, indexed by turn number, to simplify support for rejoining etc.
TODO: verify this doesn't use too much RAM.
Definition at line 291 of file NetServer.h.
|
private |
Internal script context for (de)serializing script messages, and for storing game attributes.
(TODO: we shouldn't bother deserializing (except for debug printing of messages), we should just forward messages blindly and efficiently.)
Definition at line 264 of file NetServer.h.
|
private |
Definition at line 279 of file NetServer.h.
|
private |
Definition at line 284 of file NetServer.h.
|
private |
Definition at line 273 of file NetServer.h.
|
private |
Definition at line 309 of file NetServer.h.
|
private |
Definition at line 313 of file NetServer.h.
|
private |
Definition at line 277 of file NetServer.h.
|
private |
Definition at line 275 of file NetServer.h.
|
private |
Definition at line 315 of file NetServer.h.
|
private |
Definition at line 280 of file NetServer.h.
|
private |
Definition at line 307 of file NetServer.h.
|
private |
Definition at line 306 of file NetServer.h.