
139
SERVER-SIDE ACTIONSCRIPT LANGUAGE REFERENCE FOR ADOBE MEDIA SERVER 5.0.1
Server-Side ActionScript Language Reference
Last updated 7/2/2013
var so = SharedObject.get("foo", true);
if (so.isDirty){
SharedObject.commit(so.name);
}
SharedObject.lock()
so.lock()
Locks a shared object. This method gives the server-side script exclusive access to the shared object; when the
SharedObject.unlock() method is called, all changes are batched and one update message is sent through the
SharedObject.onSync() handler to all the clients that subscribe to this shared object. If you nest the
SharedObject.lock() and SharedObject.unlock() methods, make sure that there is an unlock() method for
every
lock() method; otherwise, clients are blocked from accessing the shared object.
You cannot use the SharedObject.lock() method on proxied shared objects.
Availability
Flash Communication Server 1
Returns
An integer indicating the lock count: 0 or greater indicates success; -1 indicates failure. For proxied shared objects,
always returns -1.
Example
The following example locks the so shared object, executes the code that is to be inserted, and then unlocks the object:
var so = SharedObject.get("foo");
so.lock();
// Insert code here that operates on the shared object.
so.unlock();
SharedObject.mark()
so.mark(handlerName, p1, ..., pN)
Delivers all change events to a subscribing client as a single message.
In a server-side script, you can call the SharedObject.setProperty() method to update multiple shared object
properties between a call to the
lock() and unlock() methods. All subscribing clients receive a change event
notification through the
SharedObject.onSync() handler. However, because the server may collapse multiple
messages to optimize bandwidth, the
change event notifications may not be sent in the same order as they were in the
code.
Use the mark() method to execute code after all the properties in a set have been updated. You can call the
handlerName parameter passed to the mark() method, knowing that all property changes before the mark() call have
been updated.
Availability
Flash Media Server 2
Kommentare zu diesen Handbüchern