App.Client
Access the Steam App system with Heathen's Steam API
Like what your seeing?
Support us as a GitHub Sponsor and get instant access to all our assets, exclusive tools and assets, escalated support and issue tracking and our gratitude. These articles are made possible by our GitHub Sponsors ... become a sponsor today!
Introduction
Namespace
Definition
This leverages the ISteamApp interface from Valve's Steam Client API and exposes every feature of that API in a C# and Unity centric way. Beyond a simple API wrapper the App.Client class provides for basic API initalizations and runs the callback update. It is possible to run Steam API without Steamworks Behaviour using only this class.
This will cause the client API from Valve's Steam API to be initialized to the App ID provided and will start a background worker to run callbacks for you.
What can it do?
The App interface can be used to verify ownership, check for DLC, VAC Ban and more. The main function commonly used in Unity games would be Dlc. You can fetch a list of all DLC, check for ownership of the DLC and more.
Most of this functionality is wrapped up in your SteamSettings making it even easier to leverage.
Events
EventDlcInstalled
This event is invoked when a DLC is installed and has a single parameter of type DlcInstalled_t
. The type DlcInstalled_t
is defined by Valve here.
You would add a listener on this event such as:
Assuming a handler in the form of
Then you would register the event such as:
When you no longer need this handler you should remove it for example when the behaviour using it is destroyed
EventNewUrlLaunchParameters
This event is raised after the user executes a steam URL with command line or query parameters such as `steam://run/<appId>?param1=value1; while the game is already running. The new params can be queried with the GetLaunchCommandLine and GetLaunchQueryParam methods.
This event has a single parameter of type NewUrlLaunchParameters_t
which is defined by Valve here.
You would add a Listener on this event such as:
Assuming a handler in the form of
Then you would register the event such as:
When you no longer need this handler you should remove it for example when the behaviour using it is destroyed
EventServersConnected
Called when a connections to the Steam back-end has been established. This means the Steam client now has a working connection to the Steam servers. Usually this will have occurred before the game has launched, and should only be seen if the user has dropped connection due to a networking issue or a Steam server update.
Assuming a handler in the form of
Then you would register the event such as:
When you no longer need this handler you should remove it for example when the behaviour using it is destroyed
EventServersDisconnected
Called if the client has lost connection to the Steam servers. Real-time services will be disabled until a matching EventServersConnected has been posted.
You can read more about the EResult data type here.
Assuming a handler in the form of
Then you would register the event such as:
When you no longer need this handler you should remove it for example when the behaviour using it is destroyed
EventServersConnectFailure
Called when a connection attempt has failed. This will occur periodically if the Steam client is not connected, and has failed when retrying to establish a connection.
You can read more about the SteamServerConnectFailure_t data type here.
Assuming a handler in the form of
Then you would register the event such as:
When you no longer need this handler you should remove it for example when the behaviour using it is destroyed
Fields and Attributes
Initialized
This is a global field located on API.App.Initalized and indicates rather or not the system is initialized.
This is *Not* located in the API.App.Client class rather its in the parent API.App class so to access it
LoggedOn
Indicates rather or not the system is logged on to the Steam backend services. When false this indicates the system is running in "offline mode" and as a result realtime systems like Lobby, parts of Inventory and others will not funciton or will have a limited level of funcitonality.
IsSubscribed
Check if the active user is subscribed to the current App ID ... in Valve's speak this means that the active user has a license to this app.
You can call this field via
IsSubscribedFromFamilySharing
Checks if the active user is accessing the current appID via a temporary Family Shared license owned by another user.
You can call this field via
IsSubscribedFromFreeWeekend
Checks if the user is subscribed to the current App ID through a free weekend.
You can call this field via
IsVACBanned
Checks if the user has a VAC (Valve Anti Cheat) ban on their account
You can call this field via
Owner
Gets the UserData for the owner of the app, if this is different than the local user then the app is being barrowed.
You can call this field via
AvailableLanguages
Returns a list of languages supported by the app
You can call this field via
IsBeta
Returns true if a beta branch is being used
You can call this field via
CurrentBetaName
Returns a list of languages supported by the app
You can call this field via
CurrentGameLanguage
Gets the current language that the user has set
You can call this field via
Dlc
Returns the metadata for all available DLC
You can call this field via
IsCybercafe
Checks whether the current App ID is for Cyber Cafes.
You can call this field via
IsLowViolence
Checks if the license owned by the user provides low violence depots.
You can call this field via
Id
Gets the App Id of the current process.
You can call this field via
BuildId
Gets the build id (aka the Build Number) of this app, may change at any time based on backend updates to the game.
You can call this field via
InstallDirectory
Gets the buildid of this app, may change at any time based on backend updates to the game.
You can call this field via
DLCCount
Gets the number of DLC pieces for the current app.
You can call this field via
LaunchCommandLine
Gets the command line if the game was launched via Steam URL, e.g. steam://run/<appid>//<command line>/. This method is preferable to launching with a command line via the operating system, which can be a security risk. In order for rich presence joins to go through this and not be placed on the OS command line, you must enable "Use launch command line" from the Installation > General page on your app.
You can call this field via
Methods
Initialize
Initializes the the Steam API for client processing. If your using SteamSettings or SteamworksBehaviour this is done for you. You should only call this if you are not using SteamSettings.Initialize or SteamworksBehaviour.
IsAppInstalled
Checks if a specific app is installed.
The app may not actually be owned by the current user, they may have it left over from a free weekend, etc. This only works for base applications, not Downloadable Content(DLC). Use IsDlcInstalled for DLC instead.
IsDlcInstalled
Checks if the user owns a specific DLC and if the DLC is installed
GetDlcDownloadProgress
Gets the download progress for optional DLC.
GetAppInstallDirectory
Gets the install directory of the app if any
InstalledDepots
Returns the collection of installed depots in mount order
QueryLaunchParam
Parameter names starting with the character '@' are reserved for internal use and will always return an empty string. Parameter names starting with an underscore '_' are reserved for steam features -- they can be queried by the game, but it is advised that you not param names beginning with an underscore for your own features.
InstallDLC
Install an optional DLC
UninstallDLC
Uninstall an optional DLC
IsSubscribedApp
Checks if the active user is subscribed to a specified appId.
IsTimedTrial
Is the current license a time trial license
GetCurrectBetaName
Gets the current beta branch name if any
GetEarliestPurchaseTime
Gets the time of purchase of the specified app
GetFileDetails
Asynchronously retrieves metadata details about a specific file in the depot manifest.
MarkContentCorrupt
If you detect the game is out-of-date (for example, by having the client detect a version mismatch with a server), you can call use MarkContentCorrupt to force a verify, show a message to the user, and then quit.
How To
Check if Online
You can check if the user is currently connected to the Steam backend as a good means to check if the user is "online" at least as far as Steam is concenred.
The events EventServersConnected and EventServersDisconnected will be invoked as the connection is gained or lost respectively.
Check for app ownership
You can check if the user owns the current app via
There are multiple ways for a user to have legitimate access to your game however so this alone doesn't always tell the full story. For example your player may be barrowing the game from a Steam Family Sharing link.
or perhaps you offered your game via a free weekend promotion
Time trials are another option
Your game could be, being played via a Cybercafe
Finally you may just want to see who the proper owner of this license is
If the owner doesn't match the current user then you know several things
The local user is interested in game and has either barrowed it from a family member, is playing it via a promotion such as a free weekend or is playing it at a Cybercafe
The local user is authenticated to Steam and has a legit path to play your game
The owner of the game has in one way or another promoted your game for you ... you could use that to drive a reward system or simply make note of it for your own marketing
Check purchase date
Check when the user first purchased the game (or any app), if you get a date back from the 70s then they purchased the game before Steam started tracking ... or they never purchased the game.
Check for VAC Ban
The App interface can check the local user's VAC Ban status via
Check language
The App interface is able to list the available languages for this app from Steam
You can also fetch the current game language
Check for beta status
The App interface can check if the current build is a beta and if so which one.
Alternatively
Get available DLC
Typically you would have done this at development time but you can query for a list of all DLC available to this app at run time.
The returned DownloadableContent objects can further be used to check for ownership and install of a given DLC. Again you would typically do this from your Steam Settings which will already have this information to hand but this can be useful when you want or need to check DLC availability at runtime.
Check DLC Ownership
You can also check for ownership of any related app ID
Check DLC Install
While most modern DLC dont need to install, typically a game always contains all of its content especially if its multiplayer. DLC ownership typically only unlocks the content for the player. That said a DLC is an app and can download new content ... to check for the install of that content use:
Even if your DLC is empty it can still be useful to test this to see if they have the DLC enabled. Some gamers will disable DLC to play the vanilla version that would cause ownership to be true but install to be false.
Get DLC Download Progress
DLC can be installed or uninstalled from within game, to check the status of the install/download progress use: