ColdFusion 9.0 Resources |
Using the AIR SyncManager class to manage dataThe AIR application uses the SyncManager class to fetch
data from the server and synchronize the local data with the ColdFusion
data source. The SyncManager uses a coldfusion.air.Session object
to manage the session between the client and the local SQLite database,
and uses calls to the following methods in the ColdFusion sync manager
CFC:
The following text describes basic functionality that you must implement. For details on the SyncManager and Session classes, and other classes in the coldfusion.air package, see ASDocs. The AIR application init() function creates and configures a SyncManager instance, and fetches the initial data from ColdFusion as shown in the following code: private function init():void { syncmanager = new SyncManager(); //The ColdFusion server and port. Port without double quotes as it is //expected to be integer and IP is taken as String. syncmanager.cfPort = CFServerPort; syncmanager.cfServer = "CFServerIP"; //The CFC that implements the ColdFusion sync manager. Here //AIRIntegration is the user defined folder under webroot. syncmanager.syncCFC = "AIRIntegration.empManager"; //Specify a user-defined CF destination,if not specified, default destination //'ColdFusion' will be used syncmanager.destination = 'USerDefinedCFDestination' //The event listener for conflict events returned byt the CFC syncmanager.addEventListener(ConflictEvent.CONFLICT, conflictHandler); //The local database file var dbFile:File = File.userDirectory.resolvePath("EmpManager.db"); //Create a session object, which handles all interactions between the //AIR application and the SQLite database. var sessiontoken:SessionToken = syncmanager.openSession(dbFile, 999); //Add a responder for handling session connection results. sessiontoken.addResponder(new mx.rpc.Responder(connectSuccess, connectFault)); } |