Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

116 lines
3.1 KiB

  1. //===== Copyright � 1996-2009, Valve Corporation, All rights reserved. ======//
  2. //
  3. // Purpose:
  4. //
  5. //===========================================================================//
  6. #ifndef MM_SESSION_ONLINE_HOST_H
  7. #define MM_SESSION_ONLINE_HOST_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. class CMatchSessionOnlineTeamSearch;
  12. class CMatchSessionOnlineSearch;
  13. //
  14. // CMatchSessionOnlineHost
  15. //
  16. // Implementation of an online session of a host machine
  17. //
  18. class CMatchSessionOnlineHost : public IMatchSessionInternal
  19. {
  20. // Methods of IMatchSession
  21. public:
  22. // Get an internal pointer to session system-specific data
  23. virtual KeyValues * GetSessionSystemData();
  24. // Get an internal pointer to session settings
  25. virtual KeyValues * GetSessionSettings();
  26. // Update session settings, only changing keys and values need
  27. // to be passed and they will be updated
  28. virtual void UpdateSessionSettings( KeyValues *pSettings );
  29. virtual void UpdateTeamProperties( KeyValues *pTeamProperties );
  30. // Issue a session command
  31. virtual void Command( KeyValues *pCommand );
  32. virtual uint64 GetSessionID();
  33. // Run a frame update
  34. virtual void Update();
  35. // Destroy the session object
  36. virtual void Destroy();
  37. // Debug print a session object
  38. virtual void DebugPrint();
  39. // Check if another session is joinable
  40. virtual bool IsAnotherSessionJoinable( char const *pszAnotherSessionInfo );
  41. // Process event
  42. virtual void OnEvent( KeyValues *pEvent );
  43. public:
  44. explicit CMatchSessionOnlineHost( KeyValues *pSettings );
  45. explicit CMatchSessionOnlineHost( CSysSessionClient *pSysSession, KeyValues *pExtendedSettings );
  46. ~CMatchSessionOnlineHost();
  47. protected:
  48. void InitializeGameSettings();
  49. void MigrateGameSettings();
  50. void OnRunCommand( KeyValues *pCommand );
  51. void OnRunCommand_Start();
  52. void OnRunCommand_StartDsSearchFinished();
  53. void OnRunCommand_StartListenServerStarted( uint32 externalIP );
  54. void OnRunCommand_Cancel_DsSearch();
  55. void OnRunCommand_Match();
  56. void OnRunCommand_QueueConnect( KeyValues *pCommand );
  57. void OnRunCommand_Cancel_Match();
  58. void ConnectGameServer( CDsSearcher::DsResult_t *pDsResult );
  59. void StartListenServerMap();
  60. void OnEndGameToLobby();
  61. void SetSessionActiveGameplayState( bool bActive, char const *szSecureServerAddress );
  62. void InviteTeam();
  63. //
  64. // Overrides
  65. //
  66. protected:
  67. virtual void OnGamePrepareLobbyForGame();
  68. virtual void OnGamePlayerMachinesConnected( int numMachines );
  69. protected:
  70. KeyValues *m_pSettings;
  71. KeyValues::AutoDelete m_autodelete_pSettings;
  72. KeyValues *m_pSysData;
  73. KeyValues::AutoDelete m_autodelete_pSysData;
  74. enum State_t
  75. {
  76. STATE_INIT,
  77. STATE_CREATING,
  78. STATE_LOBBY,
  79. STATE_MATCHING, // host is running matchmaking for opponents
  80. STATE_MATCHINGRESTART, // team communication failed and matching needs to restart
  81. STATE_STARTING, // host is running a dedicated search or other things before actual game server kicks in
  82. STATE_LOADING, // host is starting a server map
  83. STATE_GAME,
  84. STATE_ENDING,
  85. STATE_MIGRATE
  86. };
  87. State_t m_eState;
  88. CSysSessionHost *m_pSysSession;
  89. CDsSearcher *m_pDsSearcher;
  90. CMatchSessionOnlineTeamSearch *m_pTeamSearcher;
  91. CMatchSessionOnlineSearch *m_pMatchSearcher;
  92. };
  93. #endif