| Argument | Description | Types / Required |
| syncId | The resource ID returned by Sync.connect. | number
recommended |
| direction | The synchronization direction.
The default value is "both". | string
not required |
| path | The path of a paradata log, or logs, to synchronize. | string, array
not required |
The
Sync.syncParadata action synchronizes the events in a
paradata log with a
synchronization service. The action can upload paradata from the local device (client) to the service as well as download paradata from the service. It keeps track of what paradata has been transferred each time the client and service synchronize. This information is used to only transfer paradata that has been collected since the last synchronization. This significantly reduces the amount of data transferred.
The connection is identified using
syncId, a
resource ID returned by
Sync.connect. While optional, this should generally be specified explicitly. (If there is only one synchronization session active, the resource ID can be calculated implicitly.)
The direction argument determines whether paradata is uploaded, downloaded, or both. Options include:
- "get": Download any paradata that was sent to the service (from another paradata log) since the last synchronization.
- "put": Upload to the service any paradata that has been collected since the last synchronization.
- "both": Synchronize paradata with the service in both directions (i.e., perform both a "get" and a "put").
Paradata logs can be very large so be careful when adding paradata synchronization to an application. If you are interested in syncing paradata, a general suggestion is to use
"both" when syncing between devices using
Bluetooth, and to use
"put" for
CSWeb,
Dropbox, or
FTP.
If no argument for path is provided, the currently open paradata log is synchronized. However, using path, you can synchronize one or more paradata logs. Logs are specified as:
- A single string representing a paradata log.
- A single string using wildcard characters "*" and "?" to specify a group of paradata logs.
- An array of strings containing strings specified in one of the two above forms.
The action returns undefined.
The action throws an exception if any of its arguments are not specified in a valid form, or if:
- The synchronization connection ID is not valid.
- No path argument is specified and no paradata log is currently open.
- A nonexistent paradata log is specified and the direction is "put". For other directions, a paradata log is created if one does not already exist.
- There is a network error while sending or receiving data from the synchronization service.
// connect to another device using Bluetooth
const syncId = CS.Sync.connect({
connection: "Bluetooth"
});
// sync the currently open paradata log (in both directions)
CS.Sync.syncParadata({
syncId: syncId
});
// send any other paradata logs on this device
CS.Sync.syncParadata({
syncId: syncId,
direction: "put",
path: "../paradata/*.cslog"
});
// other sync events...