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.

129 lines
3.5 KiB

  1. //===== Copyright c 1996-2009, Valve Corporation, All rights reserved. ======//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //===========================================================================//
  7. #ifndef INETSUPPORT_H
  8. #define INETSUPPORT_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include "tier1/interface.h"
  13. #include "keyvalues.h"
  14. #include "bitbuf.h"
  15. #include "inetchannel.h"
  16. #include "inetmsghandler.h"
  17. #include "matchmaking/imatchasync.h"
  18. class ISteamNetworkingUtils;
  19. abstract_class INetSupport : public IAppSystem
  20. {
  21. public:
  22. enum NetworkConsts_t
  23. {
  24. NC_MAX_ROUTABLE_PAYLOAD = 1200,
  25. };
  26. enum NetworkSocket_t
  27. {
  28. NS_SOCK_CLIENT = 0, // client socket
  29. NS_SOCK_SERVER, // server socket
  30. #ifdef _X360
  31. NS_SOCK_SYSTEMLINK, // X360 system link
  32. NS_SOCK_LOBBY, // X360 matchmaking lobby
  33. NS_SOCK_TEAMLINK, // X360 matchmaking inter-team link
  34. #endif
  35. };
  36. enum SteamP2PChannelId_t
  37. {
  38. // see top of net_steamsocketmgr.cpp for why we need seperate channels for client & server
  39. SP2PC_RECV_CLIENT = 0,
  40. SP2PC_RECV_SERVER,
  41. SP2PC_LOBBY
  42. };
  43. struct ServerInfo_t
  44. {
  45. netadr_t m_netAdr;
  46. netadr_t m_netAdrOnline;
  47. uint16 m_nPort;
  48. bool m_bActive; // sv.IsActive
  49. bool m_bDedicated; // sv.IsDedicated
  50. bool m_bLobbyExclusive; // Exclusive to lobby connections
  51. bool m_bGroupExclusive; // Exclusive to Steam Group
  52. bool m_bInMainMenuBkgnd; // Server is in a background map
  53. char const *m_szServerName;
  54. char const *m_szMapName;
  55. char const *m_szMapGroupName;
  56. int m_numMaxHumanPlayers;
  57. int m_numHumanPlayers;
  58. };
  59. struct ClientInfo_t
  60. {
  61. int m_nSignonState; // client signon state
  62. int m_nSocket; // client socket
  63. INetChannel *m_pNetChannel;
  64. int m_numHumanPlayers; // Number of human players on the server
  65. };
  66. public:
  67. // Get engine build number
  68. virtual int GetEngineBuildNumber() = 0;
  69. // Get server info
  70. virtual void GetServerInfo( ServerInfo_t *pServerInfo ) = 0;
  71. // Get client info
  72. virtual void GetClientInfo( ClientInfo_t *pClientInfo ) = 0;
  73. // Update a local server reservation
  74. virtual void UpdateServerReservation( uint64 uiReservation ) = 0;
  75. // Update a client reservation before connecting to a server
  76. virtual void UpdateClientReservation( uint64 uiReservation, uint64 uiMachineIdHost ) = 0;
  77. // Submit a server reservation packet
  78. virtual void ReserveServer(
  79. const ns_address &netAdrPublic, const ns_address &netAdrPrivate,
  80. uint64 nServerReservationCookie, KeyValues *pKVGameSettings,
  81. IMatchAsyncOperationCallback *pCallback, IMatchAsyncOperation **ppAsyncOperation ) = 0;
  82. // Check server reservation cookie matches cookie held by client
  83. virtual bool CheckServerReservation(
  84. const ns_address &netAdrPublic, uint64 nServerReservationCookie, uint32 uiReservationStage,
  85. IMatchAsyncOperationCallback *pCallback, IMatchAsyncOperation **ppAsyncOperation ) = 0;
  86. virtual bool ServerPing( const ns_address &netAdrPublic,
  87. IMatchAsyncOperationCallback *pCallback, IMatchAsyncOperation **ppAsyncOperation ) = 0;
  88. // When client event is fired
  89. virtual void OnMatchEvent( KeyValues *pEvent ) = 0;
  90. // Process incoming net packets on the socket
  91. virtual void ProcessSocket( int sock, IConnectionlessPacketHandler * pHandler ) = 0;
  92. // Send a network packet
  93. virtual int SendPacket (
  94. INetChannel *chan, int sock, const netadr_t &to,
  95. const void *data, int length,
  96. bf_write *pVoicePayload = NULL,
  97. bool bUseCompression = false ) = 0;
  98. virtual ISteamNetworkingUtils *GetSteamNetworkingUtils() = 0;
  99. };
  100. #define INETSUPPORT_VERSION_STRING "INETSUPPORT_003"
  101. #endif // INETSUPPORT_H