The callback function that monitors synchronization takes a ul_synch_status structure as parameter. For additional information, see ul_synch_status struct.
The ul_synch_status structure has the following members:
struct ul_synch_status { struct { ul_u_long bytes; ul_u_long inserts; ul_u_long updates; ul_u_long deletes; } sent; struct { ul_u_long bytes; ul_u_long inserts; ul_u_long updates; ul_u_long deletes; } received; p_ul_synch_info info; ul_synch_state state; ul_u_short db_tableCount; ul_u_short table_id; char table_name[]; ul_wchar table_name_w2[]; ul_u_short sync_table_count; ul_u_short sync_table_index; ul_sync_state state; ul_bool stop; ul_u_short flags; ul_void * user_data; SQLCA * sqlca; } |
sent.inserts The number of inserted rows that have been uploaded so far.
sent.updates The number of updated rows that have been uploaded so far.
sent.deletes The number of deleted rows that have been uploaded so far.
sent.bytes The number of bytes that have been uploaded so far.
received.inserts The number of inserted rows that have been downloaded so far.
received.updates The number of updated rows that have been downloaded so far.
received.deletes The number of deleted rows that have been downloaded so far.
received.bytes The number of bytes that have been downloaded so far.
info A pointer to the ul_synch_info structure. See ul_synch_info_a struct.
db_tableCount Returns the number of tables in the database.
table_id The current table number (relative to 1) that is being uploaded or downloaded. This number may skip values when not all tables are being synchronized and is not necessarily increasing.
table_name[] Name of the current table.
table_name_w2[] Name of the current table (wide character version). This field is only populated in the Windows (desktop and Mobile) environment.
sync_table_count Returns the number of tables being synchronized.
sync_table_index The number of the table that is being uploaded or downloaded, starting at 1 and ending at the sync_table_count value. This number may skip values when not all tables are being synchronized.
state One of the following states:
UL_SYNCH_STATE_STARTING No synchronization actions have yet been taken.
UL_SYNCH_STATE_CONNECTING The synchronization stream has been built, but not yet opened.
UL_SYNCH_STATE_SENDING_HEADER The synchronization stream has been opened, and the header is about to be sent.
UL_SYNCH_STATE_SENDING_TABLE A table is being sent.
UL_SYNCH_STATE_SENDING_DATA Schema information or data is being sent.
UL_SYNCH_STATE_FINISHING_UPLOAD The upload stage is completed and a commit is being carried out.
UL_SYNCH_STATE_RECEIVING_UPLOAD_ACK An acknowledgement that the upload is complete is being received.
UL_SYNCH_STATE_RECEIVING_TABLE A table is being received.
UL_SYNCH_STATE_RECEIVING_DATA Schema information or data is being received.
UL_SYNCH_STATE_COMMITTING_DOWNLOAD The download stage is completed and a commit is being carried out.
UL_SYNCH_STATE_SENDING_DOWNLOAD_ACK An acknowledgement that download is complete is being sent.
UL_SYNCH_STATE_DISCONNECTING The synchronization stream is about to be closed.
UL_SYNCH_STATE_DONE Synchronization has completed successfully.
UL_SYNCH_STATE_ERROR Synchronization has completed, but with an error.
UL_SYNCH_STATE_ROLLING_BACK_DOWNLOAD An error occurred during download and the download is being rolled back.
For more information about the synchronization process, see The synchronization process.
stop Set this member to true to interrupt the synchronization. The SQL exception SQLE_INTERRUPTED is set, and the synchronization stops as if a communications error had occurred. The observer is always called with either the DONE or ERROR state so that it can do proper cleanup.
flags Returns the current synchronization flags indicating additional information related to the current state.
user_data Returns the user data object that is passed as an argument to the ULRegisterSynchronizationCallback function.
sqlca Pointer to the connection's active SQLCA.
The following code illustrates a very simple observer function:
extern void __stdcall ObserverFunc( p_ul_synch_status status ) { switch( status->state ) { case UL_SYNCH_STATE_STARTING: printf( "Starting\n"); break; case UL_SYNCH_STATE_CONNECTING: printf( "Connecting\n" ); break; case UL_SYNCH_STATE_SENDING_HEADER: printf( "Sending Header\n" ); break; case UL_SYNCH_STATE_SENDING_TABLE: printf( "Sending Table %d of %d\n", status->tableIndex + 1, status->tableCount ); break; case UL_SYNCH_RECEIVING_UPLOAD_ACK: printf( "Receiving Upload Ack\n" ); break; case UL_SYNCH_STATE_RECEIVING_TABLE: printf( "Receiving Table %d of %d\n", status->tableIndex + 1, status->tableCount ); break; case UL_SYNCH_STATE_SENDING_DOWNLOAD_ACK: printf( "Sending Download Ack\n" ); break; case UL_SYNCH_STATE_DISCONNECTING: printf( "Disconnecting\n" ); break; case UL_SYNCH_STATE_DONE: printf( "Done\n" ); break; break; ... |
This observer produces the following output when synchronizing two tables:
Starting Connecting Sending Header Sending Table 1 of 2 Sending Table 2 of 2 Receiving Upload Ack Receiving Table 1 of 2 Receiving Table 2 of 2 Sending Download Ack Disconnecting Done |
An example of an observer function is included in the CustDB sample application. The implementation in CustDB provides a window that displays synchronization progress and allows the user to cancel synchronization. The user-interface component makes the observer function platform specific.
The CustDB sample code is in the samples-dir\UltraLite\CustDB directory. The observer function is contained in platform-specific subdirectories of the CustDB directory.
Send feedback about this page via email or DocCommentXchange | Copyright © 2008, iAnywhere Solutions, Inc. - SQL Anywhere 11.0.0 |