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.

668 lines
35 KiB

  1. //====== Copyright � 1996-2008, Valve Corporation, All rights reserved. =======
  2. //
  3. // Purpose: interface to steam managing game server/client match making
  4. //
  5. //=============================================================================
  6. #ifndef ISTEAMMATCHMAKING
  7. #define ISTEAMMATCHMAKING
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "steamtypes.h"
  12. #include "steamclientpublic.h"
  13. #include "matchmakingtypes.h"
  14. #include "isteamclient.h"
  15. #include "isteamfriends.h"
  16. // lobby type description
  17. enum ELobbyType
  18. {
  19. k_ELobbyTypePrivate = 0, // only way to join the lobby is to invite to someone else
  20. k_ELobbyTypeFriendsOnly = 1, // shows for friends or invitees, but not in lobby list
  21. k_ELobbyTypePublic = 2, // visible for friends and in lobby list
  22. k_ELobbyTypeInvisible = 3, // returned by search, but not visible to other friends
  23. // useful if you want a user in two lobbies, for example matching groups together
  24. // a user can be in only one regular lobby, and up to two invisible lobbies
  25. };
  26. // lobby search filter tools
  27. enum ELobbyComparison
  28. {
  29. k_ELobbyComparisonEqualToOrLessThan = -2,
  30. k_ELobbyComparisonLessThan = -1,
  31. k_ELobbyComparisonEqual = 0,
  32. k_ELobbyComparisonGreaterThan = 1,
  33. k_ELobbyComparisonEqualToOrGreaterThan = 2,
  34. k_ELobbyComparisonNotEqual = 3,
  35. };
  36. // lobby search distance. Lobby results are sorted from closest to farthest.
  37. enum ELobbyDistanceFilter
  38. {
  39. k_ELobbyDistanceFilterClose, // only lobbies in the same immediate region will be returned
  40. k_ELobbyDistanceFilterDefault, // only lobbies in the same region or near by regions
  41. k_ELobbyDistanceFilterFar, // for games that don't have many latency requirements, will return lobbies about half-way around the globe
  42. k_ELobbyDistanceFilterWorldwide, // no filtering, will match lobbies as far as India to NY (not recommended, expect multiple seconds of latency between the clients)
  43. };
  44. // maximum number of characters a lobby metadata key can be
  45. #define k_nMaxLobbyKeyLength 255
  46. //-----------------------------------------------------------------------------
  47. // Purpose: Functions for match making services for clients to get to favorites
  48. // and to operate on game lobbies.
  49. //-----------------------------------------------------------------------------
  50. class ISteamMatchmaking
  51. {
  52. public:
  53. // game server favorites storage
  54. // saves basic details about a multiplayer game server locally
  55. // returns the number of favorites servers the user has stored
  56. virtual int GetFavoriteGameCount() = 0;
  57. // returns the details of the game server
  58. // iGame is of range [0,GetFavoriteGameCount())
  59. // *pnIP, *pnConnPort are filled in the with IP:port of the game server
  60. // *punFlags specify whether the game server was stored as an explicit favorite or in the history of connections
  61. // *pRTime32LastPlayedOnServer is filled in the with the Unix time the favorite was added
  62. virtual bool GetFavoriteGame( int iGame, AppId_t *pnAppID, uint32 *pnIP, uint16 *pnConnPort, uint16 *pnQueryPort, uint32 *punFlags, uint32 *pRTime32LastPlayedOnServer ) = 0;
  63. // adds the game server to the local list; updates the time played of the server if it already exists in the list
  64. virtual int AddFavoriteGame( AppId_t nAppID, uint32 nIP, uint16 nConnPort, uint16 nQueryPort, uint32 unFlags, uint32 rTime32LastPlayedOnServer ) =0;
  65. // removes the game server from the local storage; returns true if one was removed
  66. virtual bool RemoveFavoriteGame( AppId_t nAppID, uint32 nIP, uint16 nConnPort, uint16 nQueryPort, uint32 unFlags ) = 0;
  67. ///////
  68. // Game lobby functions
  69. // Get a list of relevant lobbies
  70. // this is an asynchronous request
  71. // results will be returned by LobbyMatchList_t callback & call result, with the number of lobbies found
  72. // this will never return lobbies that are full
  73. // to add more filter, the filter calls below need to be call before each and every RequestLobbyList() call
  74. // use the CCallResult<> object in steam_api.h to match the SteamAPICall_t call result to a function in an object, e.g.
  75. /*
  76. class CMyLobbyListManager
  77. {
  78. CCallResult<CMyLobbyListManager, LobbyMatchList_t> m_CallResultLobbyMatchList;
  79. void FindLobbies()
  80. {
  81. // SteamMatchmaking()->AddRequestLobbyListFilter*() functions would be called here, before RequestLobbyList()
  82. SteamAPICall_t hSteamAPICall = SteamMatchmaking()->RequestLobbyList();
  83. m_CallResultLobbyMatchList.Set( hSteamAPICall, this, &CMyLobbyListManager::OnLobbyMatchList );
  84. }
  85. void OnLobbyMatchList( LobbyMatchList_t *pLobbyMatchList, bool bIOFailure )
  86. {
  87. // lobby list has be retrieved from Steam back-end, use results
  88. }
  89. }
  90. */
  91. //
  92. virtual SteamAPICall_t RequestLobbyList() = 0;
  93. // filters for lobbies
  94. // this needs to be called before RequestLobbyList() to take effect
  95. // these are cleared on each call to RequestLobbyList()
  96. virtual void AddRequestLobbyListStringFilter( const char *pchKeyToMatch, const char *pchValueToMatch, ELobbyComparison eComparisonType ) = 0;
  97. // numerical comparison
  98. virtual void AddRequestLobbyListNumericalFilter( const char *pchKeyToMatch, int nValueToMatch, ELobbyComparison eComparisonType ) = 0;
  99. // returns results closest to the specified value. Multiple near filters can be added, with early filters taking precedence
  100. virtual void AddRequestLobbyListNearValueFilter( const char *pchKeyToMatch, int nValueToBeCloseTo ) = 0;
  101. // returns only lobbies with the specified number of slots available
  102. virtual void AddRequestLobbyListFilterSlotsAvailable( int nSlotsAvailable ) = 0;
  103. // sets the distance for which we should search for lobbies (based on users IP address to location map on the Steam backed)
  104. virtual void AddRequestLobbyListDistanceFilter( ELobbyDistanceFilter eLobbyDistanceFilter ) = 0;
  105. // sets how many results to return, the lower the count the faster it is to download the lobby results & details to the client
  106. virtual void AddRequestLobbyListResultCountFilter( int cMaxResults ) = 0;
  107. virtual void AddRequestLobbyListCompatibleMembersFilter( CSteamID steamIDLobby ) = 0;
  108. // returns the CSteamID of a lobby, as retrieved by a RequestLobbyList call
  109. // should only be called after a LobbyMatchList_t callback is received
  110. // iLobby is of the range [0, LobbyMatchList_t::m_nLobbiesMatching)
  111. // the returned CSteamID::IsValid() will be false if iLobby is out of range
  112. virtual CSteamID GetLobbyByIndex( int iLobby ) = 0;
  113. // Create a lobby on the Steam servers.
  114. // If private, then the lobby will not be returned by any RequestLobbyList() call; the CSteamID
  115. // of the lobby will need to be communicated via game channels or via InviteUserToLobby()
  116. // this is an asynchronous request
  117. // results will be returned by LobbyCreated_t callback and call result; lobby is joined & ready to use at this point
  118. // a LobbyEnter_t callback will also be received (since the local user is joining their own lobby)
  119. virtual SteamAPICall_t CreateLobby( ELobbyType eLobbyType, int cMaxMembers ) = 0;
  120. // Joins an existing lobby
  121. // this is an asynchronous request
  122. // results will be returned by LobbyEnter_t callback & call result, check m_EChatRoomEnterResponse to see if was successful
  123. // lobby metadata is available to use immediately on this call completing
  124. virtual SteamAPICall_t JoinLobby( CSteamID steamIDLobby ) = 0;
  125. // Leave a lobby; this will take effect immediately on the client side
  126. // other users in the lobby will be notified by a LobbyChatUpdate_t callback
  127. virtual void LeaveLobby( CSteamID steamIDLobby ) = 0;
  128. // Invite another user to the lobby
  129. // the target user will receive a LobbyInvite_t callback
  130. // will return true if the invite is successfully sent, whether or not the target responds
  131. // returns false if the local user is not connected to the Steam servers
  132. // if the other user clicks the join link, a GameLobbyJoinRequested_t will be posted if the user is in-game,
  133. // or if the game isn't running yet the game will be launched with the parameter +connect_lobby <64-bit lobby id>
  134. virtual bool InviteUserToLobby( CSteamID steamIDLobby, CSteamID steamIDInvitee ) = 0;
  135. // Lobby iteration, for viewing details of users in a lobby
  136. // only accessible if the lobby user is a member of the specified lobby
  137. // persona information for other lobby members (name, avatar, etc.) will be asynchronously received
  138. // and accessible via ISteamFriends interface
  139. // returns the number of users in the specified lobby
  140. virtual int GetNumLobbyMembers( CSteamID steamIDLobby ) = 0;
  141. // returns the CSteamID of a user in the lobby
  142. // iMember is of range [0,GetNumLobbyMembers())
  143. // note that the current user must be in a lobby to retrieve CSteamIDs of other users in that lobby
  144. virtual CSteamID GetLobbyMemberByIndex( CSteamID steamIDLobby, int iMember ) = 0;
  145. // Get data associated with this lobby
  146. // takes a simple key, and returns the string associated with it
  147. // "" will be returned if no value is set, or if steamIDLobby is invalid
  148. virtual const char *GetLobbyData( CSteamID steamIDLobby, const char *pchKey ) = 0;
  149. // Sets a key/value pair in the lobby metadata
  150. // each user in the lobby will be broadcast this new value, and any new users joining will receive any existing data
  151. // this can be used to set lobby names, map, etc.
  152. // to reset a key, just set it to ""
  153. // other users in the lobby will receive notification of the lobby data change via a LobbyDataUpdate_t callback
  154. virtual bool SetLobbyData( CSteamID steamIDLobby, const char *pchKey, const char *pchValue ) = 0;
  155. // returns the number of metadata keys set on the specified lobby
  156. virtual int GetLobbyDataCount( CSteamID steamIDLobby ) = 0;
  157. // returns a lobby metadata key/values pair by index, of range [0, GetLobbyDataCount())
  158. virtual bool GetLobbyDataByIndex( CSteamID steamIDLobby, int iLobbyData, char *pchKey, int cchKeyBufferSize, char *pchValue, int cchValueBufferSize ) = 0;
  159. // removes a metadata key from the lobby
  160. virtual bool DeleteLobbyData( CSteamID steamIDLobby, const char *pchKey ) = 0;
  161. // Gets per-user metadata for someone in this lobby
  162. virtual const char *GetLobbyMemberData( CSteamID steamIDLobby, CSteamID steamIDUser, const char *pchKey ) = 0;
  163. // Sets per-user metadata (for the local user implicitly)
  164. virtual void SetLobbyMemberData( CSteamID steamIDLobby, const char *pchKey, const char *pchValue ) = 0;
  165. // Broadcasts a chat message to the all the users in the lobby
  166. // users in the lobby (including the local user) will receive a LobbyChatMsg_t callback
  167. // returns true if the message is successfully sent
  168. // pvMsgBody can be binary or text data, up to 4k
  169. // if pvMsgBody is text, cubMsgBody should be strlen( text ) + 1, to include the null terminator
  170. virtual bool SendLobbyChatMsg( CSteamID steamIDLobby, const void *pvMsgBody, int cubMsgBody ) = 0;
  171. // Get a chat message as specified in a LobbyChatMsg_t callback
  172. // iChatID is the LobbyChatMsg_t::m_iChatID value in the callback
  173. // *pSteamIDUser is filled in with the CSteamID of the member
  174. // *pvData is filled in with the message itself
  175. // return value is the number of bytes written into the buffer
  176. virtual int GetLobbyChatEntry( CSteamID steamIDLobby, int iChatID, CSteamID *pSteamIDUser, void *pvData, int cubData, EChatEntryType *peChatEntryType ) = 0;
  177. // Refreshes metadata for a lobby you're not necessarily in right now
  178. // you never do this for lobbies you're a member of, only if your
  179. // this will send down all the metadata associated with a lobby
  180. // this is an asynchronous call
  181. // returns false if the local user is not connected to the Steam servers
  182. // results will be returned by a LobbyDataUpdate_t callback
  183. // if the specified lobby doesn't exist, LobbyDataUpdate_t::m_bSuccess will be set to false
  184. virtual bool RequestLobbyData( CSteamID steamIDLobby ) = 0;
  185. // sets the game server associated with the lobby
  186. // usually at this point, the users will join the specified game server
  187. // either the IP/Port or the steamID of the game server has to be valid, depending on how you want the clients to be able to connect
  188. virtual void SetLobbyGameServer( CSteamID steamIDLobby, uint32 unGameServerIP, uint16 unGameServerPort, CSteamID steamIDGameServer ) = 0;
  189. // returns the details of a game server set in a lobby - returns false if there is no game server set, or that lobby doesn't exist
  190. virtual bool GetLobbyGameServer( CSteamID steamIDLobby, uint32 *punGameServerIP, uint16 *punGameServerPort, CSteamID *psteamIDGameServer ) = 0;
  191. // set the limit on the # of users who can join the lobby
  192. virtual bool SetLobbyMemberLimit( CSteamID steamIDLobby, int cMaxMembers ) = 0;
  193. // returns the current limit on the # of users who can join the lobby; returns 0 if no limit is defined
  194. virtual int GetLobbyMemberLimit( CSteamID steamIDLobby ) = 0;
  195. // updates which type of lobby it is
  196. // only lobbies that are k_ELobbyTypePublic or k_ELobbyTypeInvisible, and are set to joinable, will be returned by RequestLobbyList() calls
  197. virtual bool SetLobbyType( CSteamID steamIDLobby, ELobbyType eLobbyType ) = 0;
  198. // sets whether or not a lobby is joinable - defaults to true for a new lobby
  199. // if set to false, no user can join, even if they are a friend or have been invited
  200. virtual bool SetLobbyJoinable( CSteamID steamIDLobby, bool bLobbyJoinable ) = 0;
  201. // returns the current lobby owner
  202. // you must be a member of the lobby to access this
  203. // there always one lobby owner - if the current owner leaves, another user will become the owner
  204. // it is possible (bur rare) to join a lobby just as the owner is leaving, thus entering a lobby with self as the owner
  205. virtual CSteamID GetLobbyOwner( CSteamID steamIDLobby ) = 0;
  206. // changes who the lobby owner is
  207. // you must be the lobby owner for this to succeed, and steamIDNewOwner must be in the lobby
  208. // after completion, the local user will no longer be the owner
  209. virtual bool SetLobbyOwner( CSteamID steamIDLobby, CSteamID steamIDNewOwner ) = 0;
  210. // link two lobbies for the purposes of checking player compatibility
  211. // you must be the lobby owner of both lobbies
  212. virtual bool SetLinkedLobby( CSteamID steamIDLobby, CSteamID steamIDLobbyDependent ) = 0;
  213. #ifdef _PS3
  214. // changes who the lobby owner is
  215. // you must be the lobby owner for this to succeed, and steamIDNewOwner must be in the lobby
  216. // after completion, the local user will no longer be the owner
  217. virtual void CheckForPSNGameBootInvite( unsigned int iGameBootAttributes ) = 0;
  218. #endif
  219. };
  220. #define STEAMMATCHMAKING_INTERFACE_VERSION "SteamMatchMaking009"
  221. //-----------------------------------------------------------------------------
  222. // Callback interfaces for server list functions (see ISteamMatchmakingServers below)
  223. //
  224. // The idea here is that your game code implements objects that implement these
  225. // interfaces to receive callback notifications after calling asynchronous functions
  226. // inside the ISteamMatchmakingServers() interface below.
  227. //
  228. // This is different than normal Steam callback handling due to the potentially
  229. // large size of server lists.
  230. //-----------------------------------------------------------------------------
  231. //-----------------------------------------------------------------------------
  232. // Typedef for handle type you will receive when requesting server list.
  233. //-----------------------------------------------------------------------------
  234. typedef void* HServerListRequest;
  235. //-----------------------------------------------------------------------------
  236. // Purpose: Callback interface for receiving responses after a server list refresh
  237. // or an individual server update.
  238. //
  239. // Since you get these callbacks after requesting full list refreshes you will
  240. // usually implement this interface inside an object like CServerBrowser. If that
  241. // object is getting destructed you should use ISteamMatchMakingServers()->CancelQuery()
  242. // to cancel any in-progress queries so you don't get a callback into the destructed
  243. // object and crash.
  244. //-----------------------------------------------------------------------------
  245. class ISteamMatchmakingServerListResponse
  246. {
  247. public:
  248. // Server has responded ok with updated data
  249. virtual void ServerResponded( HServerListRequest hRequest, int iServer ) = 0;
  250. // Server has failed to respond
  251. virtual void ServerFailedToRespond( HServerListRequest hRequest, int iServer ) = 0;
  252. // A list refresh you had initiated is now 100% completed
  253. virtual void RefreshComplete( HServerListRequest hRequest, EMatchMakingServerResponse response ) = 0;
  254. };
  255. //-----------------------------------------------------------------------------
  256. // Purpose: Callback interface for receiving responses after pinging an individual server
  257. //
  258. // These callbacks all occur in response to querying an individual server
  259. // via the ISteamMatchmakingServers()->PingServer() call below. If you are
  260. // destructing an object that implements this interface then you should call
  261. // ISteamMatchmakingServers()->CancelServerQuery() passing in the handle to the query
  262. // which is in progress. Failure to cancel in progress queries when destructing
  263. // a callback handler may result in a crash when a callback later occurs.
  264. //-----------------------------------------------------------------------------
  265. class ISteamMatchmakingPingResponse
  266. {
  267. public:
  268. // Server has responded successfully and has updated data
  269. virtual void ServerResponded( gameserveritem_t &server ) = 0;
  270. // Server failed to respond to the ping request
  271. virtual void ServerFailedToRespond() = 0;
  272. };
  273. //-----------------------------------------------------------------------------
  274. // Purpose: Callback interface for receiving responses after requesting details on
  275. // who is playing on a particular server.
  276. //
  277. // These callbacks all occur in response to querying an individual server
  278. // via the ISteamMatchmakingServers()->PlayerDetails() call below. If you are
  279. // destructing an object that implements this interface then you should call
  280. // ISteamMatchmakingServers()->CancelServerQuery() passing in the handle to the query
  281. // which is in progress. Failure to cancel in progress queries when destructing
  282. // a callback handler may result in a crash when a callback later occurs.
  283. //-----------------------------------------------------------------------------
  284. class ISteamMatchmakingPlayersResponse
  285. {
  286. public:
  287. // Got data on a new player on the server -- you'll get this callback once per player
  288. // on the server which you have requested player data on.
  289. virtual void AddPlayerToList( const char *pchName, int nScore, float flTimePlayed ) = 0;
  290. // The server failed to respond to the request for player details
  291. virtual void PlayersFailedToRespond() = 0;
  292. // The server has finished responding to the player details request
  293. // (ie, you won't get anymore AddPlayerToList callbacks)
  294. virtual void PlayersRefreshComplete() = 0;
  295. };
  296. //-----------------------------------------------------------------------------
  297. // Purpose: Callback interface for receiving responses after requesting rules
  298. // details on a particular server.
  299. //
  300. // These callbacks all occur in response to querying an individual server
  301. // via the ISteamMatchmakingServers()->ServerRules() call below. If you are
  302. // destructing an object that implements this interface then you should call
  303. // ISteamMatchmakingServers()->CancelServerQuery() passing in the handle to the query
  304. // which is in progress. Failure to cancel in progress queries when destructing
  305. // a callback handler may result in a crash when a callback later occurs.
  306. //-----------------------------------------------------------------------------
  307. class ISteamMatchmakingRulesResponse
  308. {
  309. public:
  310. // Got data on a rule on the server -- you'll get one of these per rule defined on
  311. // the server you are querying
  312. virtual void RulesResponded( const char *pchRule, const char *pchValue ) = 0;
  313. // The server failed to respond to the request for rule details
  314. virtual void RulesFailedToRespond() = 0;
  315. // The server has finished responding to the rule details request
  316. // (ie, you won't get anymore RulesResponded callbacks)
  317. virtual void RulesRefreshComplete() = 0;
  318. };
  319. //-----------------------------------------------------------------------------
  320. // Typedef for handle type you will receive when querying details on an individual server.
  321. //-----------------------------------------------------------------------------
  322. typedef int HServerQuery;
  323. const int HSERVERQUERY_INVALID = 0xffffffff;
  324. //-----------------------------------------------------------------------------
  325. // Purpose: Functions for match making services for clients to get to game lists and details
  326. //-----------------------------------------------------------------------------
  327. class ISteamMatchmakingServers
  328. {
  329. public:
  330. // Request a new list of servers of a particular type. These calls each correspond to one of the EMatchMakingType values.
  331. // Each call allocates a new asynchronous request object.
  332. // Request object must be released by calling ReleaseRequest( hServerListRequest )
  333. virtual HServerListRequest RequestInternetServerList( AppId_t iApp, MatchMakingKeyValuePair_t **ppchFilters, uint32 nFilters, ISteamMatchmakingServerListResponse *pRequestServersResponse ) = 0;
  334. virtual HServerListRequest RequestLANServerList( AppId_t iApp, ISteamMatchmakingServerListResponse *pRequestServersResponse ) = 0;
  335. virtual HServerListRequest RequestFriendsServerList( AppId_t iApp, MatchMakingKeyValuePair_t **ppchFilters, uint32 nFilters, ISteamMatchmakingServerListResponse *pRequestServersResponse ) = 0;
  336. virtual HServerListRequest RequestFavoritesServerList( AppId_t iApp, MatchMakingKeyValuePair_t **ppchFilters, uint32 nFilters, ISteamMatchmakingServerListResponse *pRequestServersResponse ) = 0;
  337. virtual HServerListRequest RequestHistoryServerList( AppId_t iApp, MatchMakingKeyValuePair_t **ppchFilters, uint32 nFilters, ISteamMatchmakingServerListResponse *pRequestServersResponse ) = 0;
  338. virtual HServerListRequest RequestSpectatorServerList( AppId_t iApp, MatchMakingKeyValuePair_t **ppchFilters, uint32 nFilters, ISteamMatchmakingServerListResponse *pRequestServersResponse ) = 0;
  339. // Releases the asynchronous request object and cancels any pending query on it if there's a pending query in progress.
  340. // RefreshComplete callback is not posted when request is released.
  341. virtual void ReleaseRequest( HServerListRequest hServerListRequest ) = 0;
  342. /* the filters that are available in the ppchFilters params are:
  343. "map" - map the server is running, as set in the dedicated server api
  344. "dedicated" - reports bDedicated from the API
  345. "secure" - VAC-enabled
  346. "full" - not full
  347. "empty" - not empty
  348. "noplayers" - is empty
  349. "proxy" - a relay server
  350. */
  351. // Get details on a given server in the list, you can get the valid range of index
  352. // values by calling GetServerCount(). You will also receive index values in
  353. // ISteamMatchmakingServerListResponse::ServerResponded() callbacks
  354. virtual gameserveritem_t *GetServerDetails( HServerListRequest hRequest, int iServer ) = 0;
  355. // Cancel an request which is operation on the given list type. You should call this to cancel
  356. // any in-progress requests before destructing a callback object that may have been passed
  357. // to one of the above list request calls. Not doing so may result in a crash when a callback
  358. // occurs on the destructed object.
  359. // Canceling a query does not release the allocated request handle.
  360. // The request handle must be released using ReleaseRequest( hRequest )
  361. virtual void CancelQuery( HServerListRequest hRequest ) = 0;
  362. // Ping every server in your list again but don't update the list of servers
  363. // Query callback installed when the server list was requested will be used
  364. // again to post notifications and RefreshComplete, so the callback must remain
  365. // valid until another RefreshComplete is called on it or the request
  366. // is released with ReleaseRequest( hRequest )
  367. virtual void RefreshQuery( HServerListRequest hRequest ) = 0;
  368. // Returns true if the list is currently refreshing its server list
  369. virtual bool IsRefreshing( HServerListRequest hRequest ) = 0;
  370. // How many servers in the given list, GetServerDetails above takes 0... GetServerCount() - 1
  371. virtual int GetServerCount( HServerListRequest hRequest ) = 0;
  372. // Refresh a single server inside of a query (rather than all the servers )
  373. virtual void RefreshServer( HServerListRequest hRequest, int iServer ) = 0;
  374. //-----------------------------------------------------------------------------
  375. // Queries to individual servers directly via IP/Port
  376. //-----------------------------------------------------------------------------
  377. // Request updated ping time and other details from a single server
  378. virtual HServerQuery PingServer( uint32 unIP, uint16 usPort, ISteamMatchmakingPingResponse *pRequestServersResponse ) = 0;
  379. // Request the list of players currently playing on a server
  380. virtual HServerQuery PlayerDetails( uint32 unIP, uint16 usPort, ISteamMatchmakingPlayersResponse *pRequestServersResponse ) = 0;
  381. // Request the list of rules that the server is running (See ISteamGameServer::SetKeyValue() to set the rules server side)
  382. virtual HServerQuery ServerRules( uint32 unIP, uint16 usPort, ISteamMatchmakingRulesResponse *pRequestServersResponse ) = 0;
  383. // Cancel an outstanding Ping/Players/Rules query from above. You should call this to cancel
  384. // any in-progress requests before destructing a callback object that may have been passed
  385. // to one of the above calls to avoid crashing when callbacks occur.
  386. virtual void CancelServerQuery( HServerQuery hServerQuery ) = 0;
  387. };
  388. #define STEAMMATCHMAKINGSERVERS_INTERFACE_VERSION "SteamMatchMakingServers002"
  389. // game server flags
  390. const uint32 k_unFavoriteFlagNone = 0x00;
  391. const uint32 k_unFavoriteFlagFavorite = 0x01; // this game favorite entry is for the favorites list
  392. const uint32 k_unFavoriteFlagHistory = 0x02; // this game favorite entry is for the history list
  393. //-----------------------------------------------------------------------------
  394. // Purpose: Used in ChatInfo messages - fields specific to a chat member - must fit in a uint32
  395. //-----------------------------------------------------------------------------
  396. enum EChatMemberStateChange
  397. {
  398. // Specific to joining / leaving the chatroom
  399. k_EChatMemberStateChangeEntered = 0x0001, // This user has joined or is joining the chat room
  400. k_EChatMemberStateChangeLeft = 0x0002, // This user has left or is leaving the chat room
  401. k_EChatMemberStateChangeDisconnected = 0x0004, // User disconnected without leaving the chat first
  402. k_EChatMemberStateChangeKicked = 0x0008, // User kicked
  403. k_EChatMemberStateChangeBanned = 0x0010, // User kicked and banned
  404. };
  405. // returns true of the flags indicate that a user has been removed from the chat
  406. #define BChatMemberStateChangeRemoved( rgfChatMemberStateChangeFlags ) ( rgfChatMemberStateChangeFlags & ( k_EChatMemberStateChangeDisconnected | k_EChatMemberStateChangeLeft | k_EChatMemberStateChangeKicked | k_EChatMemberStateChangeBanned ) )
  407. //-----------------------------------------------------------------------------
  408. // Callbacks for ISteamMatchmaking (which go through the regular Steam callback registration system)
  409. #pragma pack( push, 8 )
  410. //-----------------------------------------------------------------------------
  411. // Purpose: a server was added/removed from the favorites list, you should refresh now
  412. //-----------------------------------------------------------------------------
  413. struct FavoritesListChanged_t
  414. {
  415. enum { k_iCallback = k_iSteamMatchmakingCallbacks + 2 };
  416. uint32 m_nIP; // an IP of 0 means reload the whole list, any other value means just one server
  417. uint32 m_nQueryPort;
  418. uint32 m_nConnPort;
  419. uint32 m_nAppID;
  420. uint32 m_nFlags;
  421. bool m_bAdd; // true if this is adding the entry, otherwise it is a remove
  422. };
  423. //-----------------------------------------------------------------------------
  424. // Purpose: Someone has invited you to join a Lobby
  425. // normally you don't need to do anything with this, since
  426. // the Steam UI will also display a '<user> has invited you to the lobby, join?' dialog
  427. //
  428. // if the user outside a game chooses to join, your game will be launched with the parameter "+connect_lobby <64-bit lobby id>",
  429. // or with the callback GameLobbyJoinRequested_t if they're already in-game
  430. //-----------------------------------------------------------------------------
  431. struct LobbyInvite_t
  432. {
  433. enum { k_iCallback = k_iSteamMatchmakingCallbacks + 3 };
  434. uint64 m_ulSteamIDUser; // Steam ID of the person making the invite
  435. uint64 m_ulSteamIDLobby; // Steam ID of the Lobby
  436. uint64 m_ulGameID; // GameID of the Lobby
  437. };
  438. //-----------------------------------------------------------------------------
  439. // Purpose: Sent on entering a lobby, or on failing to enter
  440. // m_EChatRoomEnterResponse will be set to k_EChatRoomEnterResponseSuccess on success,
  441. // or a higher value on failure (see enum EChatRoomEnterResponse)
  442. //-----------------------------------------------------------------------------
  443. struct LobbyEnter_t
  444. {
  445. enum { k_iCallback = k_iSteamMatchmakingCallbacks + 4 };
  446. uint64 m_ulSteamIDLobby; // SteamID of the Lobby you have entered
  447. uint32 m_rgfChatPermissions; // Permissions of the current user
  448. bool m_bLocked; // If true, then only invited users may join
  449. uint32 m_EChatRoomEnterResponse; // EChatRoomEnterResponse
  450. };
  451. //-----------------------------------------------------------------------------
  452. // Purpose: The lobby metadata has changed
  453. // if m_ulSteamIDMember is the steamID of a lobby member, use GetLobbyMemberData() to access per-user details
  454. // if m_ulSteamIDMember == m_ulSteamIDLobby, use GetLobbyData() to access lobby metadata
  455. //-----------------------------------------------------------------------------
  456. struct LobbyDataUpdate_t
  457. {
  458. enum { k_iCallback = k_iSteamMatchmakingCallbacks + 5 };
  459. uint64 m_ulSteamIDLobby; // steamID of the Lobby
  460. uint64 m_ulSteamIDMember; // steamID of the member whose data changed, or the room itself
  461. uint8 m_bSuccess; // true if we lobby data was successfully changed;
  462. // will only be false if RequestLobbyData() was called on a lobby that no longer exists
  463. };
  464. //-----------------------------------------------------------------------------
  465. // Purpose: The lobby chat room state has changed
  466. // this is usually sent when a user has joined or left the lobby
  467. //-----------------------------------------------------------------------------
  468. struct LobbyChatUpdate_t
  469. {
  470. enum { k_iCallback = k_iSteamMatchmakingCallbacks + 6 };
  471. uint64 m_ulSteamIDLobby; // Lobby ID
  472. uint64 m_ulSteamIDUserChanged; // user who's status in the lobby just changed - can be recipient
  473. uint64 m_ulSteamIDMakingChange; // Chat member who made the change (different from SteamIDUserChange if kicking, muting, etc.)
  474. // for example, if one user kicks another from the lobby, this will be set to the id of the user who initiated the kick
  475. uint32 m_rgfChatMemberStateChange; // bitfield of EChatMemberStateChange values
  476. };
  477. //-----------------------------------------------------------------------------
  478. // Purpose: A chat message for this lobby has been sent
  479. // use GetLobbyChatEntry( m_iChatID ) to retrieve the contents of this message
  480. //-----------------------------------------------------------------------------
  481. struct LobbyChatMsg_t
  482. {
  483. enum { k_iCallback = k_iSteamMatchmakingCallbacks + 7 };
  484. uint64 m_ulSteamIDLobby; // the lobby id this is in
  485. uint64 m_ulSteamIDUser; // steamID of the user who has sent this message
  486. uint8 m_eChatEntryType; // type of message
  487. uint32 m_iChatID; // index of the chat entry to lookup
  488. };
  489. //-----------------------------------------------------------------------------
  490. // Purpose: A game created a game for all the members of the lobby to join,
  491. // as triggered by a SetLobbyGameServer()
  492. // it's up to the individual clients to take action on this; the usual
  493. // game behavior is to leave the lobby and connect to the specified game server
  494. //-----------------------------------------------------------------------------
  495. struct LobbyGameCreated_t
  496. {
  497. enum { k_iCallback = k_iSteamMatchmakingCallbacks + 9 };
  498. uint64 m_ulSteamIDLobby; // the lobby we were in
  499. uint64 m_ulSteamIDGameServer; // the new game server that has been created or found for the lobby members
  500. uint32 m_unIP; // IP & Port of the game server (if any)
  501. uint16 m_usPort;
  502. };
  503. //-----------------------------------------------------------------------------
  504. // Purpose: Number of matching lobbies found
  505. // iterate the returned lobbies with GetLobbyByIndex(), from values 0 to m_nLobbiesMatching-1
  506. //-----------------------------------------------------------------------------
  507. struct LobbyMatchList_t
  508. {
  509. enum { k_iCallback = k_iSteamMatchmakingCallbacks + 10 };
  510. uint32 m_nLobbiesMatching; // Number of lobbies that matched search criteria and we have SteamIDs for
  511. };
  512. //-----------------------------------------------------------------------------
  513. // Purpose: posted if a user is forcefully removed from a lobby
  514. // can occur if a user loses connection to Steam
  515. //-----------------------------------------------------------------------------
  516. struct LobbyKicked_t
  517. {
  518. enum { k_iCallback = k_iSteamMatchmakingCallbacks + 12 };
  519. uint64 m_ulSteamIDLobby; // Lobby
  520. uint64 m_ulSteamIDAdmin; // User who kicked you - possibly the ID of the lobby itself
  521. uint8 m_bKickedDueToDisconnect; // true if you were kicked from the lobby due to the user losing connection to Steam (currently always true)
  522. };
  523. //-----------------------------------------------------------------------------
  524. // Purpose: Result of our request to create a Lobby
  525. // m_eResult == k_EResultOK on success
  526. // at this point, the lobby has been joined and is ready for use
  527. // a LobbyEnter_t callback will also be received (since the local user is joining their own lobby)
  528. //-----------------------------------------------------------------------------
  529. struct LobbyCreated_t
  530. {
  531. enum { k_iCallback = k_iSteamMatchmakingCallbacks + 13 };
  532. EResult m_eResult; // k_EResultOK - the lobby was successfully created
  533. // k_EResultNoConnection - your Steam client doesn't have a connection to the back-end
  534. // k_EResultTimeout - you the message to the Steam servers, but it didn't respond
  535. // k_EResultFail - the server responded, but with an unknown internal error
  536. // k_EResultAccessDenied - your game isn't set to allow lobbies, or your client does haven't rights to play the game
  537. // k_EResultLimitExceeded - your game client has created too many lobbies
  538. uint64 m_ulSteamIDLobby; // chat room, zero if failed
  539. };
  540. // used by now obsolete RequestFriendsLobbiesResponse_t
  541. // enum { k_iCallback = k_iSteamMatchmakingCallbacks + 14 };
  542. //-----------------------------------------------------------------------------
  543. // Purpose: Result of CheckForPSNGameBootInvite
  544. // m_eResult == k_EResultOK on success
  545. // at this point, the local user may not have finishing joining this lobby;
  546. // game code should wait until the subsequent LobbyEnter_t callback is received
  547. //-----------------------------------------------------------------------------
  548. struct PSNGameBootInviteResult_t
  549. {
  550. enum { k_iCallback = k_iSteamMatchmakingCallbacks + 15 };
  551. bool m_bGameBootInviteExists;
  552. CSteamID m_steamIDLobby; // Should be valid if m_bGameBootInviteExists == true
  553. };
  554. #pragma pack( pop )
  555. #endif // ISTEAMMATCHMAKING