code-disaster / steamworks4j

A thin Java wrapper to access the Steamworks API
https://code-disaster.github.io/steamworks4j/
MIT License
482 stars 67 forks source link

GetTicketForWebApiResponse callback not triggered #143

Closed Frotty closed 8 months ago

Frotty commented 8 months ago

Hi, I'm trying to validate a user ticket via my server. I have updated to 1.10.0-SNAPSHOT to use the getAuthTicketForWebApi method, and authTicketHandle.isValid() is true. But the onGetTicketForWebApi method in my SteamUserCallback is never triggered. According to the steamworks doc https://partner.steamgames.com/doc/api/ISteamUser#GetAuthTicketForWebApi the call should trigger the GetTicketForWebApiResponse callback, but it doesn't do that in my case, and therefore I cannot read the ticketData. Am I missing something? Any help would be appreciated.

This a minimal code example:

try {
    SteamAPI.loadLibraries(SteamLibraryLoaderGdx())
    if (!SteamAPI.init()) {
        println("Steamworks initialization error, e.g. Steam client not running")
    } else {
        println("Steamworks initialized")
        val user = SteamUser(object : SteamUserCallback {
            override fun onGetTicketForWebApi(authTicket: SteamAuthTicket?, result: SteamResult?, ticketData: ByteArray?) {
                println("onGetTicketForWebApi")
            }
        })
        println("requesting api ticket")
        val authTicketForWebApi = user.getAuthTicketForWebApi("demo-identity")
        println("requested api ticket, isValid: ${authTicketForWebApi.isValid}")
    }
} catch (e: SteamException) {
    println("Error extracting or loading native steamworks libraries")
}

Output:

Setting breakpad minidump AppID = xxx
SteamInternal_SetMinidumpSteamID:  Caching Steam ID:  xxx [API loaded no]
Steamworks initialized
requesting api ticket
requested api ticket, isValid: true
Frotty commented 8 months ago

Okay my bad, for the callbacks to trigger SteamAPI.runCallbacks() must be invoked periodically. I had this call only in my game loop but not on my menu. Thanks @code-disaster for the library and the quick help.