
17
SERVER-SIDE ACTIONSCRIPT LANGUAGE REFERENCE FOR ADOBE MEDIA SERVER 5.0.1
Server-Side ActionScript Language Reference
Last updated 7/2/2013
Example
application.onAppStart = function (){
trace ("*** sample_guestbook application start");
// Create a reference to a persistent shared object.
application.entries_so = SharedObject.get("entries_so", true);
// Prevent clients from updating the shared object.
application.entries_so.lock();
// Get the number of entries saved in the shared object
// and save it in application.lastEntry.
var maxprop = 0;
var soProperties = application.entries_so.getPropertyNames();
trace("soProperties:" + soProperties);
if (soProperties == null) {
application.lastEntry = 0;
} else {
for (var prop in soProperties) {
maxprop = Math.max (parseInt(prop), maxprop);
trace("maxprop " + maxprop);
}
application.lastEntry = maxprop+1;
}
// Allow clients to update the shared object.
application.entries_so.unlock();
trace("*** onAppStart called.");
};
application.onAppStop()
application.onAppStop = function (info){}
Invoked when the server is about to unload an application instance. You can use onAppStop() to flush the application
state or to prevent the application from being unloaded.
Define a function that is executed when the event handler is invoked. If the function returns true, the application is
unloaded. If the function returns
false, the application is not unloaded. If you don’t define a function for this event
handler, or if the return value is not a boolean value, the application is unloaded when the event is invoked.
The Adobe Media Server application passes an information object to the application.onAppStop() event. You can
use Server-Side ActionScript to look at this information object to decide what to do in the function you define. You
can also use the
application.onAppStop() event to notify users before shutdown.
If you use the Administration Console or the Server Administration API to unload a Adobe Media Server application,
application.onAppStop() is not invoked. Therefore you cannot use application.onAppStop() to tell users that
the application is exiting.
When an application doesn’t have incoming client connections, the server considers the application idle and unloads
it. To prevent this, define an
Application.onAppStop() handler that returns false.
Availability
Flash Communication Server 1
Kommentare zu diesen Handbüchern