Mobile game data server sync architecture using changesets.


I have a huge game data scheme (model classes & hierarchy) populated with data and serialisable to JSON.
Player performs an actions that change specific data in a specific places in a specific time.
I need to record players action, reproduce it on a server, and then compare resulting data model snapshots(client and server). I can do it by MD5 checksumm or something like that.
If the checksumm are equal the model on server acceps an update from a client.
If there is some inconsistency i want to rollback model to the last valid user action and then send it back to client authoritatively with “force update client + rollback”.


What is the basic architectural approach for a Model(MVC) on a client-side/server-side and which methods and where sould be implemented by which parts?

Basically i need a more detailed workflow/class hierarchy to be able to create something like this.
I’m developting an RPG with time-management mechanics (like Clash of Clans)

P.S. Forget about cheating issues for a while if you think it’s a bad idea to have logic on a client side.

Your question is a bit broad, so I will speak broadly.

I would treat the networking as a second MVC controller. So on the client side would have a local user controller and a controller for the remote server, whereas on the server side you have an authoritative controller and a controller for the remote client (that isn’t authoritative so can only ask nicely for changes). In each case, both controllers manipulate the model, but do not talk to each other.

When the server needs to tell the client to do something, this would be done by the authoritative controller, and when the client needs to ask the server to do something, this would be done by the user controller.

Speaking more specifically, I can’t give you a list of methods to implement since it is highly dependent on the specifics of your game, and would be very time-consuming to do so anyway. This is something you’ll need to do yourself. I think the approach you talked about involving syncing and checking checksums could work.

Checksums seem like an anti-cheating mechanism though, and you said you weren’t worried about it. I’m not too familiar with Clash of Clans, but I believe that two players never interact simultaneously. So if you’re not worried about cheating then you can simply have the server send the saved local player’s state when the building phase starts, and the saved remote player’s state at the beginning of a battle, then the client would simply tell the server what happens and the server would accept it.