User Guide

94 Application Development Tips and Tricks
About unloading and reloading
applications
Application instances are usually unloaded because of garbage collection. The first time the
garbage collector runs after all clients are disconnected from an application, the application is
unloaded. In other words, applications arent unloaded immediately when all clients
disconnect. Because application startup usually takes some time, it is better for the application
to stay open for a short time, so that the next client that connects doesnt encounter the same
delay.
By default, garbage collection happens once every 20 minutes (every 5 minutes for unused I/
O threads). You can configure these values to be any number of minutes (greater than zero);
for more information, see Managing Flash Media Server.
Also, whenever you make changes to the main.asc file, you must reload the application for the
changes to be applied; reloading the application disconnects all connected users. You can use
the management console to reload an application (see Chapter 5, “Debugging and
Monitoring Applications).
Implementing dynamic access control
Server-side ActionScript provides a mechanism to implement dynamic access control list
(ACL) functionality for shared objects and streams. By default, all connections have full access
to all streams and shared objects. You can control who has access to create, read, or update
shared objects or streams. Every connection to a server-side application instance is represented
by a Client object on the server-side, and each Client object has two properties:
readAccess
and
writeAccess. Using these two properties, you can control access on a per-connection
basis.
Because shared object and stream names are strings, and both follow the same rules of URI-
encoded data, you can define access based on them. The
client.readAccess and
client.writeAccess commands take string values. These values can contain multiple string
tokens, or unique identifiers for the object names you want to control, separated by
semicolons (
;). Two example strings follow:
client.readAccess = "appStream;/appSO/"
client.writeAccess = "appStreams/public/;appSO/public/"
Using these calls and the string token convention, you can create shared objects and streams
that follow well-defined patterns. For example, suppose all shared objects that the application
creates start with the prefix
appSO, shared objects available for all users begin with the prefix
appSO/public, and shared objects you want to protect have the prefix appSO/private.