How to synchronise the model with a server?

sketchup

#1

I am creating a viewer for a model. Initially whole model is exported to a server.
Now if user changes anything in the model I want to apply those changes to server file.
How can this be done ?
I can see some observer ruby class but which one to implement or there is simpler way to do this task ?


#2

The export format defines whether an incremental update could be done. Regardless, I believe it would be really messy…


#3

Let say if the export format is .skp .


#4

Either you transfer the whole changed model (saved file or exported model) or you transfer the differences that you can read out by observers (what needs to be added, removed, changed) and apply them to the model on the server-side.

Then you also need to decide whether you transfer differences of the file (comparing bytes on the file system level, like Github diffs) or of the model scene graph in memory (reading and comparing properties through the API/SDK and encoding them in your own format, e.g. JSON).

Note that SketchUp’s .skp format is a binary format and does not provide an option for incremental updates or diffs. You would need a tool to create binary diffs of the saved binary file, or you define your own format for encoding model entities or updates.


#5

When quiting …

Easiest Incremental …

You can use both, BTW.


#6

I would like to do incremental update. But onPostSaveModel will not tell me the changes.
If I can know the changes I can apply them to server also.


#7

There is some work you have to do on your own.

You could

  • use other observers (EntityObserver etc.) to be notified about what changed (which entity, but not which property of the entity) and collect these and sync them for example after onPostModel (or after some preiod of time).
  • traverse the whole model and identify what is different than at the ast sync (therefore you need to keep a your data structure of the last synced version in memory).

Think about how would you identify the place where to apply a change in a nested model?