question

yogev avatar image
yogev asked

Handling offline sync

Hey I am thinking about how to handle offline sync I have 2 ways

  1. I will save the data locally with playerpref and with OnApplicationQuit I will invoke Azure function and I will check if the info is OK and compare it to the old player info

  2. for each level that the player passes I will invoke the Azure function ^

I am thinking on the amount of the calls that I am going to send to the server in the first option, I send it when the player exits from the app and send all the info in one package

the second option is when the player passes a level so it could be up to the maximum levels in the app but if I have 1000 or more levels it could be a lot of calls

what do you think will be the best and most optimized way to do it?

And my second question is when should I check if the player is offline? should I let him send request and if the request is null tell him that he is offline? or should I use this code ?

         IEnumerator CheckConnection()
         {
             using (UnityWebRequest request = new UnityWebRequest("https://google.com"))
             {
                 yield return request.SendWebRequest();
    
                 if (request.error != null)
                 {
    
                 }
                 else
                 {
                 }
             }
         }

If yes for how long should I wait between pings? thank you

apis
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Infer Wang avatar image
Infer Wang answered

For the first option, you may save the data periodically to prevent data loss due to app crashes or forced close. For the second option, you may change the call condition to decrease call frequency if possible, for example, invoke when player pass 10 levels. Is it possible to add save button in your game? As a result, player can save progress as they want, of course note to check the authenticity. You may consider using a hybrid way based on the above. Could you please tell me why you want to check if player is offline? PlayFab SDK will return error when the caller is offline, you may test it and use it as judgement condition.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.