How to synch local data(coin/score) and server data?

0 votes
Hi All

I have user data like coin, score etc. How can I synch these data between server and client? Are there any common techniques used? I mean basically should I get data whenever game is opened and write it to local data? How can I be sure server data is always correct data? Maybe there was a server problem last time coin earned and served could not be updated. Can you please write me a basic algorithm/description about this issue? My second question regarding this issue is: whenever user earns coin or score or whatever, should I save them immediately to server? I thought whenever game is closed, save to server. But in unity I cannot save something to server just inside applicationClose event.  

Thanks
asked Dec 12, 2016 in Unity by gokhan (20 points)
edited Dec 13, 2016 by gokhan

1 Answer

0 votes
Hi Gokhan,

If you want to send data to the server only once then you can store it locally and try to send it to server at following events in your game:

1. When user croses a level

2. When app closes

3. When app opens

You can check your local database when app opens, if there is some data which need to be sent to the server then you can send it to the same at that time else not needed.

It is recommended to send data to the server whenever you peform any important event in the game which can be level cross, game win/lose, in game scores etc. I mean any important data which you are keeping on the server need to be sent immediately if there is a change.

Regarding your second question about the correct data on the server, Yes, it might be possible that when you try to send data to the server and the request fails due to some reason. In that case you will be getting failed response for that call and you can save that data to your local database and try to send after some time or in the next game session.

You can also maintain times stamp to check that which data is the recent one, local database or server .

Let me know if you have any further queries.

Thanks.
answered Dec 13, 2016 by rajeev.etc (1,660 points)
Hi Rajeev
I want to ask different but related question.I cannot save something to server at the time of application closing in unity3d. This produces many problem in my game and everytime I try to find another ways to solve the problem. I wonder is it possible to save something on other platforms for example native android,cocos3d or xamarin etc? How can we overcome this problem inside unity?
Download Widgets
Welcome to ShepHertz Product line forum, where you can ask questions and receive answers from the community. You can also reach out to us on support@shephertz.com
...