How To use the client-side API
You can use Rethync SDK in standalone mode and to implement plugin for Rethync Client software.
The sequence of calls in code when using Rethync SDK (client side) is
- (in standalone mode) Create an instance of ClientEngine
- (in standalone mode) Create an instance of some transport class and assign it to ClientEngine.Transport property
- (in standalone mode) Depending on particular transport you might need to perform initialization of the transport.
- (in standalone mode) Activate the transport with the call to BaseTransport.Activate method.
- (in standalone mode) Call ClientEngine.OpenSession to open the synchronization session. This call will connect to the server.
- Use BaseClientEngine.LockClass to lock the object class in order to work with it. Note that this command notifies the server to "lock" certain objects, however you need to lock the local set of objects somehow as well to prevent interference of external factors.
- Optionally load information about previous synchronization of the class in order to have data for comparison during current synchronization. This is done using BaseClientEngine.LoadLocalObjectInfo method.
- Receive information about remote objects available for synchronization using BaseClientEngine.GetRemoteObjectInfo method
- Create a list of objects of the given class which you have for local synchronization (contacts, notes, todo, calendar etc)
- Having collected information about remote, local and (optionally) previously synchronized lists use BaseClientEngine.CompareObjectLists method to compose object lists for further operations. Obtained lists are informational – further synchronization is better done step-by-step for subset of objects (then there will be no problems with process interruption) though you can sycnhronize a list with one call.
- Decide what to do with conflicts
- Perform retrieval, uploading, deletion of objects using BaseClientEngine.GetRemoteObjects, BaseClientEngine.PutRemoteObjects and BaseClientEngine.DeleteRemoteObjects respectively.
- Unlock the class using BaseClientEngine.UnlockClass method. Do not unlock local data at this point!
- Build the local list of objects of recently synchronized class. Note that the list must be built using the information used during synchronization, otherwise it's possible that in situation when the data were changed between synchronization and building the local list.
- Store the local list using BaseClientEngine.SaveLocalObjectInfo method.
- Now you can unlock local data as you have stored the list.
- Repeat synchronization steps (from a call to LockClass to local unlock) for each class of data that you want to synchronize.
- (in standalone mode) When synchronization is complete, call ClientEngine.CloseSession method to close the session.
- (in standalone mode) Turn off the transport with the call to BaseTransport.Deactivate method.
- (in standalone mode) Delete created instances of ClientEngine and ClientTransport
Got questions or comments about this topic? Tell us about them.