| 1 | #ifndef GAME_CLIENT_COMPONENTS_LOCAL_SERVER_H |
| 2 | #define GAME_CLIENT_COMPONENTS_LOCAL_SERVER_H |
| 3 | |
| 4 | #include <base/types.h> |
| 5 | |
| 6 | #include <engine/shared/config.h> |
| 7 | |
| 8 | #include <game/client/component.h> |
| 9 | |
| 10 | #include <chrono> |
| 11 | |
| 12 | class CLocalServer : public CComponentInterfaces |
| 13 | { |
| 14 | public: |
| 15 | bool RunServer(const std::vector<const char *> &vpArguments); |
| 16 | void KillServer(); |
| 17 | bool IsServerRunning(); |
| 18 | bool IsStarting() const { return m_WaitingForPort; } |
| 19 | void Update(); |
| 20 | void RconAuthIfPossible(); |
| 21 | void Connect(); |
| 22 | void CancelConnect(); |
| 23 | |
| 24 | private: |
| 25 | void Reset(); |
| 26 | void WaitForPort(); |
| 27 | void OnServerStarted(); |
| 28 | |
| 29 | char m_aRconPassword[sizeof(g_Config.m_SvRconPassword)] = "" ; |
| 30 | // Port that the server reported after binding its socket, 0 until then |
| 31 | int m_Port = 0; |
| 32 | bool m_WaitingForPort = false; |
| 33 | std::chrono::nanoseconds m_StartTime{0}; |
| 34 | std::chrono::nanoseconds m_NextPortCheck{0}; |
| 35 | bool m_ConnectRequested = false; |
| 36 | |
| 37 | #if !defined(CONF_PLATFORM_ANDROID) |
| 38 | PROCESS m_Process = INVALID_PROCESS; |
| 39 | #endif |
| 40 | }; |
| 41 | |
| 42 | #endif |
| 43 | |