How to use steamAPI Unregistercallresult to cancel a Steam API call
Steam API calls are asynchronous operations that return a handle of type SteamAPICall_t. You can use this handle to check the status of the call, get the result data, or cancel the call if you no longer need it.
{steamAPI Unregistercallresult}
Download Zip: https://conrumencpe.blogspot.com/?uq=2vMJTu
To cancel a Steam API call, you need to use the function steamAPI Unregistercallresult, which takes two parameters: a pointer to a callback object and the handle of the call. The callback object is a class that inherits from CCallbackBase and implements a virtual function Run with the result data as an argument. You can use the STEAM_CALLBACK macro to simplify the creation of callback objects.
The function steamAPI Unregistercallresult will unregister the callback object from the Steam API system and prevent it from being called when the call completes. This will also free up some memory used by the callback object. However, this does not mean that the Steam API call is actually cancelled on the server side. The call may still complete and send back some data, but you will not receive it.
Here is an example of how to use steamAPI Unregistercallresult to cancel a Steam API call:
// Declare a callback object class
class CMyCallback : public CCallbackBase
public:
// Constructor
CMyCallback()
// Register the callback with Steam
m_hAPICall = SteamUser()->RequestEncryptedAppTicket(NULL, 0);
m_iCallback = GetAPICallCompleted();
m_nCallbackFlags = k_ECallbackFlagsRegistered;
// Destructor
~CMyCallback()
// Unregister the callback from Steam
steamAPI_UnregisterCallResult(this, m_hAPICall);
// The callback function
virtual void Run(void *pvParam)
// Get the result data
EncryptedAppTicketResponse_t *pResponse = (EncryptedAppTicketResponse_t *)pvParam;
// Check the result status
if (pResponse->m_eResult == k_EResultOK)
// Do something with the encrypted app ticket
else
// Handle the error
private:
// The handle of the Steam API call
SteamAPICall_t m_hAPICall;
;
// Create an instance of the callback object
CMyCallback myCallback;
// Do some other stuff
// Cancel the Steam API call by deleting the callback object
delete myCallback;
For more information on how to use Steam API calls and callbacks, please refer to Steamworks API Overview [^2^] and source-sdk-2013/steam_api.h at master - Github [^1^].
An encrypted app ticket is a way to securely authenticate a user's ownership of your game on Steam. It is a blob of data that contains information such as the user's Steam ID, the App ID of your game, and a random nonce. The data is encrypted with a secret key that only Steam and your game server know. You can use encrypted app tickets to implement your own custom authentication system for your game server, without relying on Steam's user authentication API.
To use encrypted app tickets, you need to do the following steps:
Request an encrypted app ticket from Steam using the function SteamUser()->RequestEncryptedAppTicket. This will trigger a Steam API call that will return a handle of type SteamAPICall_t. You need to pass a pointer to a buffer and the size of the buffer as parameters. The buffer will be filled with the encrypted app ticket data when the call completes.
Register a callback object to receive the result of the Steam API call. The callback object should inherit from CCallbackBase and implement a virtual function Run with an argument of type EncryptedAppTicketResponse_t. This is a struct that contains a field m_eResult of type EResult, which indicates the status of the request. You can use the STEAM_CALLBACK macro to simplify the creation of callback objects.
Send the encrypted app ticket data to your game server using your own network protocol. The game server should decrypt the data using the secret key that you obtained from Steamworks. You can use the function BDecryptTicket from steam_encrypted_app_ticket.h to perform the decryption. This will return a pointer to a struct of type EncryptedAppTicket, which contains the fields m_ulSteamID, m_unAppID, and m_rgubTicketData.
Verify the decrypted app ticket data on your game server. You should check that the Steam ID matches the user's identity, that the App ID matches your game's App ID, and that the nonce is not reused. You can also perform any additional checks that you need for your game logic.
Respond to the user with an authentication result using your own network protocol. You can either grant or deny access to your game server based on the verification of the encrypted app ticket data.
For more information on how to use encrypted app tickets, please refer to Encrypted App Ticket (Steamworks Documentation) and
steam_encrypted_app_ticket.h in Steamworks.NET.
e033bf56a8