Using Communication Objects > SharedObject object > Flushing remote shared objects

 

Flushing remote shared objects

Flash Communication Server automatically flushes remote shared objects to the disk, on both the client and the server, when all users disconnect from the shared object or when the server shuts down. At any other time, if you want the shared object to be updated on disk, you must call the client-side SharedObject.flush method.

However, calling SharedObject.flush in the client-side ActionScript flushes only the local copy of the shared object. To manually flush the server copy of the shared object, you must call SharedObject.flush in a server-side script:

// Sample server-side code for flushing a persistent shared object 
// to the server

// Get the shared object when the application is loaded.
application.onAppStart = function()
{
	application.mySO = SharedObject.get("SharedObjName", true);
}

// When a user disconnects, flush the shared object.
application.onDisconnect = function(client)
{
	application.mySO.flush();
}