Skip to content

Realtime Synchronization

Harald Schilly edited this page May 21, 2017 · 9 revisions

How CoCalc's Realtime Synchronization works

Whenever a user makes a change — for some definition of change — a patch is made and sent from the client to the server. The patch contains the change and when the change was made. This way if the user loses connection in the middle of some changes, patches are applied in very nearly always the correct order.

This is always well defined based on this diff-match-patch library even when patches are distributed from various computers with varying connections. That is to say, the final application of all patches is consistent based on timestamps and changes alone.

The core code for realtime sync in CoCalc is mainly found in syncstring.coffee. It builds on synctable.coffee, which provides an interface to rethinkdb, which supports writing when offline, syncing later, merging, etc.

Analytics

Clone this wiki locally
You can’t perform that action at this time.