### Build and Dependency Setup Source: https://github.com/steamre/steamkit/blob/master/Resources/NetHook2/readme.md Commands to prepare the build environment and compile the NetHook2 project from source. ```powershell .\SetupDependencies.ps1 ``` ```powershell powershell -File SetupDependencies.ps1 ``` -------------------------------- ### CDN Client - Downloading Game Content Source: https://context7.com/steamre/steamkit/llms.txt This example demonstrates how to initialize the CDN client, retrieve depot decryption keys, download depot manifests, and then download individual file chunks for a given game depot. ```APIDOC ## CDN Client - Downloading Game Content ### Description This endpoint enables downloading depot manifests and game content chunks from Steam's content delivery network. It covers the process from client initialization to downloading specific file chunks. ### Method N/A (This is a client-side code example, not a direct API endpoint) ### Endpoint N/A ### Parameters N/A ### Request Example ```csharp using SteamKit2; using SteamKit2.CDN; using System.Buffers; var steamClient = new SteamClient(); var steamApps = steamClient.GetHandler(); var steamContent = steamClient.GetHandler(); // After logging in... manager.Subscribe(async callback => { if (callback.Result != EResult.OK) return; uint appId = 730; // CS:GO uint depotId = 731; ulong manifestId = 1234567890; // Get from PICS product info // Create CDN client using var cdnClient = new Client(steamClient); // Get depot decryption key var depotKeyResult = await steamApps.GetDepotDecryptionKey(depotId, appId); byte[] depotKey = depotKeyResult.DepotKey; // Get content servers var servers = await ContentServerDirectoryService.LoadAsync( steamClient.Configuration, (int)callback.CellID, CancellationToken.None ); var server = servers.First(); // Get manifest request code var manifestCode = await steamContent.GetManifestRequestCode(depotId, appId, manifestId, "public"); // Download the depot manifest var manifest = await cdnClient.DownloadManifestAsync( depotId, manifestId, manifestCode, server, depotKey ); Console.WriteLine($"Manifest has {manifest.Files.Count} files"); // Download a specific file's chunks foreach (var file in manifest.Files.Take(5)) { Console.WriteLine($"File: {file.FileName} ({file.TotalSize} bytes)"); foreach (var chunk in file.Chunks) { // Rent a buffer for the decompressed chunk var buffer = ArrayPool.Shared.Rent((int)chunk.UncompressedLength); try { int bytesWritten = await cdnClient.DownloadDepotChunkAsync( depotId, chunk, server, buffer, depotKey ); // Process the chunk data in buffer[0..bytesWritten] Console.WriteLine($" Chunk: {bytesWritten} bytes downloaded"); } finally { ArrayPool.Shared.Return(buffer); } } } }); ``` ### Response N/A (Client-side execution) ### Response Example N/A ``` -------------------------------- ### Dota 2 Game Coordinator Example Source: https://context7.com/steamre/steamkit/llms.txt This C# code snippet shows how to connect to Steam, log in, and interact with the Dota 2 Game Coordinator. It demonstrates sending messages to play the game and requesting match details, handling responses for match information. Dependencies include SteamKit2 libraries. ```csharp using SteamKit2; using SteamKit2.Internal; using SteamKit2.GC; using SteamKit2.GC.Dota.Internal; var steamClient = new SteamClient(); var manager = new CallbackManager(steamClient); var steamUser = steamClient.GetHandler(); var gameCoordinator = steamClient.GetHandler(); const int DOTA_APPID = 570; ulong matchIdToRequest = 7000000000; manager.Subscribe(callback => { if (callback.Result != EResult.OK) return; Console.WriteLine("Logged in! Launching Dota 2..."); // Tell Steam we're playing Dota 2 var playGame = new ClientMsgProtobuf(EMsg.ClientGamesPlayed); playGame.Body.games_played.Add(new CMsgClientGamesPlayed.GamePlayed { game_id = new GameID(DOTA_APPID), }); steamClient.Send(playGame); // Wait for GC to be ready, then send hello Task.Delay(5000).ContinueWith(_ => { var clientHello = new ClientGCMsgProtobuf((uint)EGCBaseClientMsg.k_EMsgGCClientHello); clientHello.Body.engine = ESourceEngine.k_ESE_Source2; gameCoordinator.Send(clientHello, DOTA_APPID); }); }); // Handle GC messages manager.Subscribe(callback => { switch (callback.EMsg) { case (uint)EGCBaseClientMsg.k_EMsgGCClientWelcome: var welcome = new ClientGCMsgProtobuf(callback.Message); Console.WriteLine($"GC Welcome! Version: {welcome.Body.version}"); // Request match details var matchRequest = new ClientGCMsgProtobuf( (uint)EDOTAGCMsg.k_EMsgGCMatchDetailsRequest ); matchRequest.Body.match_id = matchIdToRequest; gameCoordinator.Send(matchRequest, DOTA_APPID); break; case (uint)EDOTAGCMsg.k_EMsgGCMatchDetailsResponse: var matchResponse = new ClientGCMsgProtobuf(callback.Message); var result = (EResult)matchResponse.Body.result; if (result == EResult.OK) { var match = matchResponse.Body.match; Console.WriteLine($"Match {match.match_id}:"); Console.WriteLine($" Duration: {match.duration} seconds"); Console.WriteLine($" Radiant Win: {match.radiant_win}"); Console.WriteLine($" Players: {match.players.Count}"); } break; } }); steamClient.Connect(); ``` -------------------------------- ### C# Code Formatting: Function Signature and Call Source: https://github.com/steamre/steamkit/wiki/Contributing Demonstrates C# code formatting for function signatures with spacing around parameters and for function calls. This style guide helps maintain consistency across the codebase. ```csharp void MyFunction( int someParam, string otherParam ) MyFunction( param1, param2 ); ``` -------------------------------- ### Create and Use Custom SteamKit2 Message Handlers Source: https://context7.com/steamre/steamkit/llms.txt This C# example demonstrates how to create a custom message handler in SteamKit2 by extending `ClientMsgHandler`. It includes defining a custom callback, sending a custom request, and handling incoming messages like `ClientLogOnResponse`. This allows for extending SteamKit2's functionality to process specific or custom Steam messages. ```csharp using SteamKit2; using SteamKit2.Internal; // Define a custom handler public class MyCustomHandler : ClientMsgHandler { // Define a custom callback to pass data to consumers public class MyCustomCallback : CallbackMsg { public EResult Result { get; } public string Message { get; } internal MyCustomCallback(EResult result, string message) { Result = result; Message = message; } } // Send a custom request public void SendCustomRequest(uint appId) { var request = new ClientMsgProtobuf(EMsg.ClientGetAppOwnershipTicket); request.Body.app_id = appId; Client.Send(request); } // Handle incoming messages public override void HandleMsg(IPacketMsg packetMsg) { switch (packetMsg.MsgType) { case EMsg.ClientLogOnResponse: HandleLogonResponse(packetMsg); break; } } private void HandleLogonResponse(IPacketMsg packetMsg) { var response = new ClientMsgProtobuf(packetMsg); var result = (EResult)response.Body.eresult; // Post callback for consumers to handle Client.PostCallback(new MyCustomCallback(result, $"Logon result: {result}")); } } // Register and use the custom handler var steamClient = new SteamClient(); var manager = new CallbackManager(steamClient); // Add custom handler var myHandler = new MyCustomHandler(); steamClient.AddHandler(myHandler); // Subscribe to custom callback manager.Subscribe(callback => { Console.WriteLine($"Custom callback: {callback.Message} (Result: {callback.Result})"); }); // Use the custom handler myHandler.SendCustomRequest(440); ``` -------------------------------- ### WebAPI Protobuf Deserialization Source: https://github.com/steamre/steamkit/blob/master/SteamKit2/SteamKit2/changes.txt Example of using the CallProtobufAsync method to deserialize WebAPI responses directly into Protobuf objects. ```csharp var response = await webApi.CallProtobufAsync(interfaceName, methodName, arguments); ``` -------------------------------- ### SteamClient Creation and Connection Source: https://context7.com/steamre/steamkit/llms.txt Demonstrates how to create a SteamClient instance, configure connection settings, set up a CallbackManager, obtain specialized handlers, and initiate a connection to Steam servers. It also shows the main loop for processing callbacks. ```csharp using SteamKit2; // Create client with default configuration var steamClient = new SteamClient(); // Or create with custom configuration (e.g., TCP only, custom cell ID) var configuration = SteamConfiguration.Create(b => b .WithProtocolTypes(ProtocolTypes.Tcp) .WithCellID(1) .WithServerListProvider(new FileStorageServerListProvider("servers_list.bin")) ); var steamClient = new SteamClient(configuration); // Create callback manager to route callbacks to handlers var manager = new CallbackManager(steamClient); // Get handlers for specific functionality var steamUser = steamClient.GetHandler(); var steamFriends = steamClient.GetHandler(); var steamApps = steamClient.GetHandler(); // Register callbacks manager.Subscribe(callback => { Console.WriteLine("Connected to Steam!"); }); manager.Subscribe(callback => { Console.WriteLine($"Disconnected from Steam, user initiated: {callback.UserInitiated}"); }); // Initiate connection steamClient.Connect(); // Main loop - process callbacks var isRunning = true; while (isRunning) { manager.RunWaitCallbacks(TimeSpan.FromSeconds(1)); } ``` -------------------------------- ### Download Game Content and Manifests using SteamKit2 Source: https://context7.com/steamre/steamkit/llms.txt This snippet demonstrates how to initialize the SteamKit CDN client, fetch necessary decryption keys and server information, and download depot manifests. It also illustrates how to iterate through file chunks and use memory pooling to handle downloaded data efficiently. ```csharp using SteamKit2; using SteamKit2.CDN; using System.Buffers; var steamClient = new SteamClient(); var steamApps = steamClient.GetHandler(); var steamContent = steamClient.GetHandler(); manager.Subscribe(async callback => { if (callback.Result != EResult.OK) return; uint appId = 730; uint depotId = 731; ulong manifestId = 1234567890; using var cdnClient = new Client(steamClient); var depotKeyResult = await steamApps.GetDepotDecryptionKey(depotId, appId); byte[] depotKey = depotKeyResult.DepotKey; var servers = await ContentServerDirectoryService.LoadAsync( steamClient.Configuration, (int)callback.CellID, CancellationToken.None ); var server = servers.First(); var manifestCode = await steamContent.GetManifestRequestCode(depotId, appId, manifestId, "public"); var manifest = await cdnClient.DownloadManifestAsync( depotId, manifestId, manifestCode, server, depotKey ); Console.WriteLine($"Manifest has {manifest.Files.Count} files"); foreach (var file in manifest.Files.Take(5)) { Console.WriteLine($"File: {file.FileName} ({file.TotalSize} bytes)"); foreach (var chunk in file.Chunks) { var buffer = ArrayPool.Shared.Rent((int)chunk.UncompressedLength); try { int bytesWritten = await cdnClient.DownloadDepotChunkAsync( depotId, chunk, server, buffer, depotKey ); Console.WriteLine($" Chunk: {bytesWritten} bytes downloaded"); } finally { ArrayPool.Shared.Return(buffer); } } } }); ``` -------------------------------- ### Alternative Server List Providers Source: https://context7.com/steamre/steamkit/llms.txt Presents alternative server list provider implementations in SteamKit2, including isolated storage for UWP/Silverlight applications and an in-memory provider for no persistence. ```APIDOC ## Alternative Server List Providers SteamKit2 offers different options for server list persistence based on application requirements. ### Description This section details alternative server list providers: `IsolatedStorageServerListProvider` for environments like Silverlight or UWP, and `MemoryServerListProvider` for scenarios where no persistence is needed. ### Method N/A (Configuration Example) ### Endpoint N/A ### Parameters N/A ### Request Example ```csharp // Alternative: Use isolated storage (Silverlight/UWP compatible) var isolatedConfig = SteamConfiguration.Create(b => b .WithServerListProvider(new IsolatedStorageServerListProvider()) ); // Alternative: In-memory only (no persistence) var memoryConfig = SteamConfiguration.Create(b => b .WithServerListProvider(new MemoryServerListProvider()) ); ``` ### Response N/A (Configuration Example) ### Response Example N/A ``` -------------------------------- ### Implement QR Code Authentication with SteamKit2 Source: https://context7.com/steamre/steamkit/llms.txt This snippet demonstrates how to initiate a QR code authentication session, handle challenge URL updates, and poll for user approval. Upon successful authentication, it uses the received tokens to log the user into the Steam network. ```csharp using SteamKit2; using SteamKit2.Authentication; var steamClient = new SteamClient(); var manager = new CallbackManager(steamClient); var steamUser = steamClient.GetHandler(); manager.Subscribe(async callback => { var authSession = await steamClient.Authentication.BeginAuthSessionViaQRAsync(new AuthSessionDetails()); authSession.ChallengeURLChanged = () => { Console.WriteLine($"New QR Code URL: {authSession.ChallengeURL}"); }; Console.WriteLine($"Scan this QR code with Steam Mobile App: {authSession.ChallengeURL}"); var pollResponse = await authSession.PollingWaitForResultAsync(); Console.WriteLine($"Authenticated as: {pollResponse.AccountName}"); steamUser.LogOn(new SteamUser.LogOnDetails { Username = pollResponse.AccountName, AccessToken = pollResponse.RefreshToken, }); }); steamClient.Connect(); ``` -------------------------------- ### Access Steam PICS and Product Information Source: https://context7.com/steamre/steamkit/llms.txt Shows how to use the SteamApps handler to retrieve depot decryption keys, fetch product metadata via PICS, and request free licenses. It utilizes async/await patterns to handle network requests for app information. ```csharp using SteamKit2; var steamClient = new SteamClient(); var manager = new CallbackManager(steamClient); var steamApps = steamClient.GetHandler(); manager.Subscribe(async callback => { if (callback.Result != EResult.OK) return; uint appId = 730; var depotKey = await steamApps.GetDepotDecryptionKey(731, appId); var accessTokenResult = await steamApps.PICSGetAccessTokens(appId, package: null); accessTokenResult.AppTokens.TryGetValue(appId, out ulong accessToken); var request = new SteamApps.PICSRequest(appId, accessToken); var resultSet = await steamApps.PICSGetProductInfo(app: request, package: null, metaDataOnly: false); if (resultSet.Complete) { var productInfo = resultSet.Results.First(); Console.WriteLine($"App name: {productInfo.Apps[appId].KeyValues["common"]["name"].Value}"); } }); ``` -------------------------------- ### Server List Persistence with File Storage Source: https://context7.com/steamre/steamkit/llms.txt Demonstrates how to configure SteamKit2 to use file-based persistence for the server list, which stores successful server responses to speed up future connections. It also shows how to persist the cell ID. ```APIDOC ## Server List Persistence Persisting the server list improves connection times by remembering which Steam servers responded successfully. ### Description This C# code snippet shows how to load and save a cell ID from a file and configure SteamKit2 to use `FileStorageServerListProvider` for server list persistence. ### Method N/A (Configuration Example) ### Endpoint N/A ### Parameters N/A ### Request Example ```csharp using SteamKit2; using SteamKit2.Discovery; // Load cell ID from previous session uint cellId = 0; if (File.Exists("cellid.txt")) { uint.TryParse(File.ReadAllText("cellid.txt"), out cellId); Console.WriteLine($"Using persisted cell ID: {cellId}"); } // Configure with file-based server list persistence var configuration = SteamConfiguration.Create(b => b .WithCellID(cellId) .WithServerListProvider(new FileStorageServerListProvider("servers_list.bin")) ); var steamClient = new SteamClient(configuration); var manager = new CallbackManager(steamClient); var steamUser = steamClient.GetHandler(); manager.Subscribe(callback => { if (callback.Result == EResult.OK) { // Save cell ID for next session File.WriteAllText("cellid.txt", callback.CellID.ToString()); Console.WriteLine($"Saved cell ID: {callback.CellID}"); } }); ``` ### Response N/A (Configuration Example) ### Response Example N/A ``` -------------------------------- ### CDN Chunk Download with Buffer Pooling Source: https://github.com/steamre/steamkit/blob/master/SteamKit2/SteamKit2/changes.txt Shows how to download a depot chunk using the updated API which requires a pre-allocated destination buffer, utilizing ArrayPool for memory efficiency. ```csharp byte[] buffer = ArrayPool.Shared.Rent((int)chunk.UncompressedLength); try { long bytesWritten = await CDN.Client.DownloadDepotChunkAsync(chunk, buffer); } finally { ArrayPool.Shared.Return(buffer); } ``` -------------------------------- ### Unified Service Method Invocation Source: https://github.com/steamre/steamkit/blob/master/SteamKit2/SteamKit2/changes.txt Demonstrates the updated pattern for invoking service methods using the generated CreateService syntax in SteamKit. ```csharp var playerService = UnifiedMessages.CreateService(); playerService.GetGameBadgeLevels(req); ``` -------------------------------- ### Configure SteamKit2 Server List Persistence Source: https://context7.com/steamre/steamkit/llms.txt Demonstrates how to configure SteamKit2 to persist server lists and Cell IDs using file-based storage. It includes loading a previously saved Cell ID, configuring the SteamClient, and updating the storage upon successful login. ```csharp using SteamKit2; using SteamKit2.Discovery; // Load cell ID from previous session uint cellId = 0; if (File.Exists("cellid.txt")) { uint.TryParse(File.ReadAllText("cellid.txt"), out cellId); Console.WriteLine($"Using persisted cell ID: {cellId}"); } // Configure with file-based server list persistence var configuration = SteamConfiguration.Create(b => b .WithCellID(cellId) .WithServerListProvider(new FileStorageServerListProvider("servers_list.bin")) ); var steamClient = new SteamClient(configuration); var manager = new CallbackManager(steamClient); var steamUser = steamClient.GetHandler(); manager.Subscribe(callback => { if (callback.Result == EResult.OK) { // Save cell ID for next session File.WriteAllText("cellid.txt", callback.CellID.ToString()); Console.WriteLine($"Saved cell ID: {callback.CellID}"); } }); // Alternative: Use isolated storage (Silverlight/UWP compatible) var isolatedConfig = SteamConfiguration.Create(b => b .WithServerListProvider(new IsolatedStorageServerListProvider()) ); // Alternative: In-memory only (no persistence) var memoryConfig = SteamConfiguration.Create(b => b .WithServerListProvider(new MemoryServerListProvider()) ); ``` -------------------------------- ### Accessing Steam Unified Messages Service API Source: https://context7.com/steamre/steamkit/llms.txt Demonstrates how to initialize the SteamUnifiedMessages handler, create typed service interfaces for Steam features like player profiles, and subscribe to service notifications. It also shows how to perform asynchronous requests and direct message calls. ```csharp using SteamKit2; using SteamKit2.Internal; var steamClient = new SteamClient(); var manager = new CallbackManager(steamClient); var steamUnifiedMessages = steamClient.GetHandler(); var playerService = steamUnifiedMessages.CreateService(); manager.SubscribeServiceNotification( notification => { Console.WriteLine($"Game notification from {notification.Body.steamid}: App {notification.Body.appid}"); } ); manager.Subscribe(async callback => { if (callback.Result != EResult.OK) return; var request = new CPlayer_GetGameBadgeLevels_Request { appid = 440, }; var response = await playerService.GetGameBadgeLevels(request); if (response.Result == EResult.OK) { Console.WriteLine($"Player level: {response.Body.player_level}"); foreach (var badge in response.Body.badges) { Console.WriteLine($"Badge series {badge.series}: level {badge.level}"); } } var directResponse = await steamUnifiedMessages.SendMessage( "Player.GetGameBadgeLevels#1", request ); }); ``` -------------------------------- ### Interacting with Steam Web API Source: https://context7.com/steamre/steamkit/llms.txt Explains how to use the WebAPI utility to fetch public data such as game news or perform authenticated requests. It covers both dynamic interface usage for convenience and non-dynamic usage for explicit control over parameters. ```csharp using SteamKit2; using System.Net.Http; using (dynamic steamNews = WebAPI.GetInterface("ISteamNews")) { KeyValue kvNews = steamNews.GetNewsForApp(appid: 440); foreach (KeyValue news in kvNews["newsitems"]["newsitem"].Children) { Console.WriteLine($"News: {news["title"].AsString()}"); Console.WriteLine($" URL: {news["url"].AsString()}"); Console.WriteLine($" Date: {news["date"].AsInteger()}"); } kvNews = steamNews.GetNewsForApp2(appid: 570, count: 5, maxlength: 300); foreach (KeyValue news in kvNews["newsitems"].Children) { Console.WriteLine($"News: {news["title"].AsString()}"); } } using (dynamic steamUserAuth = WebAPI.GetInterface("ISteamUserAuth", "YOUR_API_KEY")) { steamUserAuth.Timeout = TimeSpan.FromSeconds(5); try { var result = steamUserAuth.AuthenticateUser( steamid: "76561198000000000", method: HttpMethod.Post ); } catch (HttpRequestException ex) { Console.WriteLine($"API request failed: {ex.Message}"); } } using (WebAPI.Interface steamNews = WebAPI.GetInterface("ISteamNews")) { var args = new Dictionary { ["appid"] = "440", ["count"] = "5" }; KeyValue results = steamNews.Call("GetNewsForApp", version: 1, args); foreach (KeyValue news in results["newsitems"]["newsitem"].Children) { Console.WriteLine($"News: {news["title"].AsString()}"); } } ``` -------------------------------- ### POST /Client/AuthorizeDevice Source: https://github.com/steamre/steamkit/blob/master/Resources/Misc/emsg_list_detailed.txt Endpoints for managing local device authorizations and security certificates. ```APIDOC ## POST /Client/AuthorizeLocalDevice ### Description Requests authorization for the current local device to access the Steam account. ### Method POST ### Endpoint /Client/AuthorizeLocalDeviceRequest ### Parameters #### Request Body - **device_token** (string) - Required - The token generated by the local device. ### Response #### Success Response (200) - **authorized** (boolean) - Status of the authorization request. #### Response Example { "authorized": true } ``` -------------------------------- ### C# Code Formatting: While Loop Braces Source: https://github.com/steamre/steamkit/wiki/Contributing Illustrates the C# code formatting style for while loops, specifically placing the opening brace on a new line. This is part of the project's overall code style guidelines. ```csharp while ( something ) { } ``` -------------------------------- ### Username/Password Authentication Source: https://context7.com/steamre/steamkit/llms.txt Shows how to authenticate with Steam using username and password via the modern authentication system. It includes handling Steam Guard two-factor authentication and obtaining JWT refresh tokens for subsequent logins. ```csharp using SteamKit2; using SteamKit2.Authentication; var steamClient = new SteamClient(); var manager = new CallbackManager(steamClient); var steamUser = steamClient.GetHandler(); string? previouslyStoredGuardData = null; // Persist this to avoid 2FA on subsequent logins manager.Subscribe(async callback => { Console.WriteLine("Connected! Starting authentication..."); // Begin credential-based authentication var authSession = await steamClient.Authentication.BeginAuthSessionViaCredentialsAsync(new AuthSessionDetails { Username = "your_username", Password = "your_password", IsPersistentSession = true, GuardData = previouslyStoredGuardData, // UserConsoleAuthenticator prompts for 2FA codes in console // Implement IAuthenticator for custom handling (e.g., TOTP generation) Authenticator = new UserConsoleAuthenticator(), }); // Poll Steam for authentication result (handles 2FA flow) var pollResponse = await authSession.PollingWaitForResultAsync(); // Save guard data for future logins (avoids 2FA) if (pollResponse.NewGuardData != null) { previouslyStoredGuardData = pollResponse.NewGuardData; // Persist this value to storage } // Log on with the refresh token steamUser.LogOn(new SteamUser.LogOnDetails { Username = pollResponse.AccountName, AccessToken = pollResponse.RefreshToken, ShouldRememberPassword = true, }); }); manager.Subscribe(callback => { if (callback.Result != EResult.OK) { Console.WriteLine($"Login failed: {callback.Result} / {callback.ExtendedResult}"); return; } Console.WriteLine($"Successfully logged on! SteamID: {callback.ClientSteamID}"); }); steamClient.Connect(); ``` -------------------------------- ### Game Server Reputation and Compatibility Source: https://github.com/steamre/steamkit/blob/master/Resources/Misc/emsg_list_detailed.txt Messages for managing game server reputation and computing player compatibility. ```APIDOC ## Game Server Reputation and Compatibility ### Description Messages related to game server reputation management and calculating compatibility between players. ### Method N/A (These are message identifiers, not API endpoints) ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response N/A ## Message Definitions - `k_EMsgGSGetReputation` (936) - `k_EMsgGSGetReputationResponse` (937) - `k_EMsgGSAssociateWithClan` (938) - `k_EMsgGSAssociateWithClanResponse` (939) - `k_EMsgGSComputeNewPlayerCompatibility` (940) - `k_EMsgGSComputeNewPlayerCompatibilityResponse` (941) ``` -------------------------------- ### Protocol Buffer Compilation Source: https://github.com/steamre/steamkit/blob/master/Resources/NetHook2/readme.md Command to generate C++ source files from the Steam messages protocol buffer definition. ```bash .\protoc.exe .\steammessages_base.proto --cpp_out=build ``` -------------------------------- ### Inject and Eject NetHook2 Source: https://github.com/steamre/steamkit/blob/master/Resources/NetHook2/readme.md Commands to inject the NetHook2 DLL into a running Steam process or eject it using rundll32. ```cmd rundll32 "",Inject rundll32 "",Eject ``` ```cmd rundll32 "",Inject 1234 rundll32 "",Inject srcds.exe ``` -------------------------------- ### Client Download and Playback (DP) Services Source: https://github.com/steamre/steamkit/blob/master/Resources/Misc/emsg_list_detailed.txt Messages related to client download and playback services, including survey responses and app job reports. ```APIDOC ## Client Download and Playback (DP) Services ### Description Messages concerning the client's Download and Playback (DP) services, covering special surveys, app job reporting, and content statistics. ### Method N/A (These are message identifiers, not API endpoints) ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response N/A ## Message Definitions - `k_EMsgClientDPCheckSpecialSurvey` (1620) - `k_EMsgClientDPCheckSpecialSurveyResponse` (1621) - `k_EMsgClientDPSendSpecialSurveyResponse` (1622) - `k_EMsgClientDPSendSpecialSurveyResponseReply` (1623) - `k_EMsgClientDPUpdateAppJobReport` (1625) - `k_EMsgClientDPUnsignedInstallScript` (1627) - `k_EMsgClientDPContentStatsReport` (1630) ``` -------------------------------- ### Manage Steam Friends and Persona State Source: https://context7.com/steamre/steamkit/llms.txt Demonstrates how to use the SteamFriends handler to set persona status, list friends, and automatically accept incoming friend requests. It relies on CallbackManager to process asynchronous events from the Steam network. ```csharp using SteamKit2; var steamClient = new SteamClient(); var manager = new CallbackManager(steamClient); var steamUser = steamClient.GetHandler(); var steamFriends = steamClient.GetHandler(); manager.Subscribe(callback => { steamFriends.SetPersonaState(EPersonaState.Online); steamFriends.SetPersonaName("My Bot Name"); }); manager.Subscribe(callback => { int friendCount = steamFriends.GetFriendCount(); for (int i = 0; i < friendCount; i++) { SteamID friendId = steamFriends.GetFriendByIndex(i); Console.WriteLine($"Friend: {steamFriends.GetFriendPersonaName(friendId)}"); } foreach (var friend in callback.FriendList) { if (friend.Relationship == EFriendRelationship.RequestRecipient) { steamFriends.AddFriend(friend.SteamID); } } }); ``` -------------------------------- ### Client File System Messages Source: https://github.com/steamre/steamkit/blob/master/Resources/Misc/emsg_list_detailed.txt Message types for interacting with the client's file system, including enumerating followed lists and retrieving friend Steam levels. ```APIDOC ## Client File System Messages ### Description Message types related to client file system operations, such as listing followed users and their Steam levels. ### Message Identifiers - **k_EMsgClientFSEnumerateFollowingListResponse** (7520) - **k_EMsgClientFSGetFriendsSteamLevels** (7528) - **k_EMsgClientFSGetFriendsSteamLevelsResponse** (7529) ``` -------------------------------- ### Generate Web Cookies and Renew Access Tokens Source: https://context7.com/steamre/steamkit/llms.txt This snippet shows how to construct the steamLoginSecure cookie string using the SteamID and access token. It also demonstrates how to programmatically renew access tokens using a refresh token to maintain an active session. ```csharp using SteamKit2; using SteamKit2.Authentication; var steamClient = new SteamClient(); var steamUser = steamClient.GetHandler(); string accessToken = ""; string refreshToken = ""; manager.Subscribe(async callback => { if (callback.Result != EResult.OK) return; var steamLoginSecure = $"{callback.ClientSteamID}||{accessToken}"; Console.WriteLine($"Steam Login Cookie: {steamLoginSecure}"); var newTokens = await steamClient.Authentication.GenerateAccessTokenForAppAsync( callback.ClientSteamID, refreshToken, allowRenewal: true ); accessToken = newTokens.AccessToken; if (!string.IsNullOrEmpty(newTokens.RefreshToken)) { refreshToken = newTokens.RefreshToken; } }); ``` -------------------------------- ### Client Authentication and Session Management Source: https://github.com/steamre/steamkit/blob/master/Resources/Misc/emsg_list_detailed.txt Messages for handling password checks, resets, and session token management. ```APIDOC ## Client Authentication and Session Management ### Description Messages related to user authentication, including checking and resetting passwords, and managing session tokens. ### Method N/A (These are message identifiers, not API endpoints) ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response N/A ## Message Definitions - `k_EMsgClientCheckPassword` (845) - `k_EMsgClientResetPassword` (846) - `k_EMsgClientCheckPasswordResponse` (848) - `k_EMsgClientResetPasswordResponse` (849) - `k_EMsgClientSessionToken` (850) ``` -------------------------------- ### User File System (UFS) Messages Source: https://github.com/steamre/steamkit/blob/master/Resources/Misc/emsg_list_detailed.txt API endpoints for managing user files through the UFS system. ```APIDOC ## UFS Messages ### Description Provides a set of messages for interacting with the User File System (UFS) to manage files, including upload, download, and deletion operations. ### Method Various (Internal Steam Protocol) ### Endpoint N/A (Internal Protocol) ### Parameters N/A ### Request Example N/A ### Response N/A **Message IDs:** - `k_EMsgClientUFSDownloadChunk` (5212) - `k_EMsgClientUFSLoginRequest` (5213) - `k_EMsgClientUFSLoginResponse` (5214) - `k_EMsgClientUFSTransferHeartbeat` (5216) - `k_EMsgClientUFSDeleteFileRequest` (5219) - `k_EMsgClientUFSDeleteFileResponse` (5220) - `k_EMsgClientUFSGetUGCDetails` (5226) - `k_EMsgClientUFSGetUGCDetailsResponse` (5227) - `k_EMsgClientUFSGetSingleFileInfo` (5230) - `k_EMsgClientUFSGetSingleFileInfoResponse` (5231) - `k_EMsgClientUFSShareFile` (5232) - `k_EMsgClientUFSShareFileResponse` (5233) - `k_EMsgClientUFSUploadCommit` (5251) - `k_EMsgClientUFSUploadCommitResponse` (5252) ``` -------------------------------- ### Client User File Storage (UFS) Operations Source: https://github.com/steamre/steamkit/blob/master/Resources/Misc/emsg_list_detailed.txt Messages for uploading, downloading, and managing user files stored via the User File Storage service. ```APIDOC ## Client User File Storage (UFS) Operations ### Description Messages related to the User File Storage (UFS) service, enabling clients to upload files (including chunked uploads), download files, and list files for a specific application. ### Method N/A (These are message identifiers, not API endpoints) ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response N/A ## Message Definitions - `k_EMsgClientUFSUploadFileRequest` (5202) - `k_EMsgClientUFSUploadFileResponse` (5203) - `k_EMsgClientUFSUploadFileChunk` (5204) - `k_EMsgClientUFSUploadFileFinished` (5205) - `k_EMsgClientUFSGetFileListForApp` (5206) - `k_EMsgClientUFSGetFileListForAppResponse` (5207) - `k_EMsgClientUFSDownloadRequest` (5210) - `k_EMsgClientUFSDownloadResponse` (5211) ``` -------------------------------- ### Steam Kit Message Definitions Source: https://github.com/steamre/steamkit/blob/master/Resources/Misc/emsg_list_detailed.txt This snippet defines constants for various Steam client messages. These messages are used for communication between the Steam client and servers, covering functionalities like authentication, friend management, and game server interactions. The definitions include message IDs, flags, and server types. ```C++ const int k_EMsgClientSentLogs = 5558; const int k_EMsgClientLogonGameServer = 5559; const int k_EMsgAMClientCreateFriendsGroup = 5560; const int k_EMsgAMClientCreateFriendsGroupResponse = 5561; const int k_EMsgAMClientDeleteFriendsGroup = 5562; const int k_EMsgAMClientDeleteFriendsGroupResponse = 5563; const int k_EMsgAMClientManageFriendsGroup = 5564; const int k_EMsgAMClientManageFriendsGroupResponse = 5565; const int k_EMsgAMClientAddFriendToGroup = 5566; const int k_EMsgAMClientAddFriendToGroupResponse = 5567; const int k_EMsgAMClientRemoveFriendFromGroup = 5568; const int k_EMsgAMClientRemoveFriendFromGroupResponse = 5569; const int k_EMsgClientAMGetPersonaNameHistory = 5570; const int k_EMsgClientAMGetPersonaNameHistoryResponse = 5571; const int k_EMsgClientRequestFreeLicense = 5572; const int k_EMsgClientRequestFreeLicenseResponse = 5573; const int k_EMsgClientDRMDownloadRequestWithCrashData = 5574; const int k_EMsgClientAuthListAck = 5575; const int k_EMsgClientItemAnnouncements = 5576; const int k_EMsgClientRequestItemAnnouncements = 5577; const int k_EMsgClientFriendMsgEchoToSender = 5578; const int k_EMsgClientCommentNotifications = 5582; const int k_EMsgClientRequestCommentNotifications = 5583; const int k_EMsgClientPersonaChangeResponse = 5584; const int k_EMsgClientRequestWebAPIAuthenticateUserNonce = 5585; const int k_EMsgClientRequestWebAPIAuthenticateUserNonceResponse = 5586; const int k_EMsgClientPlayerNicknameList = 5587; const int k_EMsgAMClientSetPlayerNickname = 5588; const int k_EMsgAMClientSetPlayerNicknameResponse = 5589; const int k_EMsgClientGetNumberOfCurrentPlayersDP = 5592; const int k_EMsgClientGetNumberOfCurrentPlayersDPResponse = 5593; const int k_EMsgClientServiceMethodLegacy = 5594; const int k_EMsgClientServiceMethodLegacyResponse = 5595; const int k_EMsgClientFriendUserStatusPublished = 5596; const int k_EMsgClientCurrentUIMode = 5597; const int k_EMsgClientVanityURLChangedNotification = 5598; const int k_EMsgClientUserNotifications = 5599; const int k_EMsgClientDFSAuthenticateRequest = 5605; const int k_EMsgClientDFSAuthenticateResponse = 5606; const int k_EMsgClientDFSEndSession = 5607; const int k_EMsgClientDFSDownloadStatus = 5617; const int k_EMsgClientNetworkingCertRequest = 5621; const int k_EMsgClientNetworkingCertRequestResponse = 5622; const int k_EMsgClientChallengeRequest = 5623; const int k_EMsgClientChallengeResponse = 5624; const int k_EMsgBadgeCraftedNotification = 5625; const int k_EMsgClientNetworkingMobileCertRequest = 5626; const int k_EMsgClientNetworkingMobileCertRequestResponse = 5627; const int k_EMsgClientGMSServerQuery = 6403; const int k_EMsgGMSClientServerQueryResponse = 6404; const int k_EMsgGameServerOutOfDate = 6407; const int k_EMsgClientAuthorizeLocalDeviceRequest = 6501; const int k_EMsgClientAuthorizeLocalDeviceResponse = 6502; const int k_EMsgClientDeauthorizeDeviceRequest = 6503; const int k_EMsgClientDeauthorizeDevice = 6504; const int k_EMsgClientUseLocalDeviceAuthorizations = 6505; const int k_EMsgClientGetAuthorizedDevices = 6506; const int k_EMsgClientGetAuthorizedDevicesResponse = 6507; const int k_EMsgClientAuthorizeLocalDeviceNotification = 6509; const int k_EMsgClientMMSCreateLobby = 6601; const int k_EMsgClientMMSCreateLobbyResponse = 6602; const int k_EMsgClientMMSJoinLobby = 6603; const int k_EMsgClientMMSJoinLobbyResponse = 6604; const int k_EMsgClientMMSLeaveLobby = 6605; const int k_EMsgClientMMSLeaveLobbyResponse = 6606; const int k_EMsgClientMMSGetLobbyList = 6607; const int k_EMsgClientMMSGetLobbyListResponse = 6608; ``` -------------------------------- ### POST /MMS/Lobby Source: https://github.com/steamre/steamkit/blob/master/Resources/Misc/emsg_list_detailed.txt Endpoints for managing Matchmaking System (MMS) lobbies, including creation, joining, and listing available lobbies. ```APIDOC ## POST /MMS/CreateLobby ### Description Creates a new game lobby via the Matchmaking System. ### Method POST ### Endpoint /Client/MMSCreateLobby ### Parameters #### Request Body - **lobby_type** (int) - Required - The type of lobby to create. - **max_members** (int) - Required - Maximum number of players allowed. ### Response #### Success Response (200) - **lobby_id** (long) - The unique identifier for the created lobby. #### Response Example { "lobby_id": 987654321 } ``` -------------------------------- ### Game Server Status and Information Source: https://github.com/steamre/steamkit/blob/master/Resources/Misc/emsg_list_detailed.txt Messages related to game server status updates, player lists, and server type information. ```APIDOC ## Game Server Status and Information ### Description Messages used to report and query the status of game servers, including player lists, server types, and general status updates. ### Method N/A (These are message identifiers, not API endpoints) ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response N/A ## Message Definitions - `k_EMsgClientServerList` (880) - `k_EMsgGSDisconnectNotice` (901) - `k_EMsgGSStatus` (903) - `k_EMsgGSUserPlaying` (905) - `k_EMsgGSStatus2` (906) - `k_EMsgGSStatusUpdate_Unused` (907) - `k_EMsgGSServerType` (908) - `k_EMsgGSPlayerList` (909) ``` -------------------------------- ### Client Base and Timestamp Messages Source: https://github.com/steamre/steamkit/blob/master/Resources/Misc/emsg_list_detailed.txt Base message definitions and client server timestamp requests. ```APIDOC ## Client Base and Timestamp Messages ### Description Base message identifiers and messages for requesting server timestamps. ### Message Identifiers - **k_EMsgBaseClient3** (9800) - **k_EMsgClientVoiceCallPreAuthorizeResponse** (9801) - **k_EMsgClientServerTimestampRequest** (9802) ``` -------------------------------- ### Account Management (AM) Game Server Updates Source: https://github.com/steamre/steamkit/blob/master/Resources/Misc/emsg_list_detailed.txt Messages for updating and removing game server information within the Account Management system. ```APIDOC ## Account Management (AM) Game Server Updates ### Description Messages used by the Account Management system to update and remove game server entries. ### Method N/A (These are message identifiers, not API endpoints) ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response N/A ## Message Definitions - `k_EMsgAMGameServerUpdate` (4331) - `k_EMsgAMGameServerRemove` (4332) ``` -------------------------------- ### Update JobCallback Declaration and Usage in SteamKit C# Source: https://github.com/steamre/steamkit/wiki/JobCallback-Transition This snippet demonstrates the old and new syntax for declaring and using JobCallbacks in SteamKit. The new syntax uses the generic Callback class directly and accesses the JobID as a member of the callback object, simplifying the process compared to the previous separate JobCallback class. ```csharp ... new JobCallback( OnAppInfo, callbackMgr ); ... void OnAppInfo( SteamApps.AppInfoCallback callback, JobID jobId ) { // do something with this info } ``` ```csharp ... new Callback( OnAppInfo, callbackMgr ); ... void OnAppInfo( SteamApps.AppInfoCallback callback ) { // the jobid is available as a member of the |callback| object } ``` -------------------------------- ### Account Management (AM) Account Reset Details Source: https://github.com/steamre/steamkit/blob/master/Resources/Misc/emsg_list_detailed.txt Messages for retrieving details related to account resets. ```APIDOC ## Account Management (AM) Account Reset Details ### Description Messages used to request and receive details concerning account reset procedures. ### Method N/A (These are message identifiers, not API endpoints) ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response N/A ## Message Definitions - `k_EMsgAMGetAccountResetDetailsRequest` (4408) - `k_EMsgAMGetAccountResetDetailsResponse` (4409) ``` -------------------------------- ### Client DRM and Friend Management Source: https://github.com/steamre/steamkit/blob/master/Resources/Misc/emsg_list_detailed.txt Messages for DRM-related issues, friend management (ignoring users), and app ownership ticket retrieval. ```APIDOC ## Client DRM and Friend Management ### Description Messages pertaining to Digital Rights Management (DRM) issues, managing friend relationships by ignoring users, and obtaining app ownership tickets. ### Method N/A (These are message identifiers, not API endpoints) ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response N/A ## Message Definitions - `k_EMsgClientDRMProblemReport` (851) - `k_EMsgClientSetIgnoreFriend` (855) - `k_EMsgClientSetIgnoreFriendResponse` (856) - `k_EMsgClientGetAppOwnershipTicket` (857) - `k_EMsgClientGetAppOwnershipTicketResponse` (858) - `k_EMsgClientDRMBlobRequest` (896) - `k_EMsgClientDRMBlobResponse` (897) ```