Sign In Register

How can we help you today?

Start a new topic

Synchronous .Send for AccountDetailsResponse


I am new and do not yet understand how to handle the asynchronous methods correctly.
Is there a way to synchronize the .Send or how to solve the following problem on clean?

I retrieve the account details with my method "GetAccountDetails" as follows and save them in my own GSPlayer object. The code also works (shortened):

new AccountDetailsRequest().Send((response) => {                    
            if (response.HasErrors)
                        GameSparksAvailable = false;
                        Currency1 = response.Currency1;

If I want to retrieve the data in another place, for example after a purchase, I always get zero as the output of "Currency1" because the code is executed faster than the data is retrieved: 

            if (GSPlayer.GetAccountDetails())
                Debug.Log("GameSparksAvailable = false");


How is it possible to retrieve the data and process it directly in the next line?

1 Comment

In the following situation I have the same problem. The player should press a button to buy something. For this a CloudCode is executed. But I would like to prevent the user from pressing the buy button too fast in quick succession. He has to wait until he receives the confirmation of the successful purchase.
Login to post a comment