
Chapter 116
Using application instances
To distinguish among different instances of a single application, pass a value for
instanceName to
your
NetConnection.connect command. For example, you may want to give different groups of
people access to the same application without having them interact with each other. To do so, you
can open multiple chat rooms at the same time, as shown below.
my_nc.connect("rtmp://myServer.myDomain.com/chatApp/room_01")
my_nc.connect("rtmp://myServer.myDomain.com/chatApp/room_02")
Another reason to use application instances is to avoid collision of recorded streams or shared
objects that are created by the application. In the above example, for instance, any streams or
shared objects created by
room_01 are distinct from those created by room_02, and vice versa,
even though both instances are running the same application, chat_App.
For example, although the support application in the following code creates two shared objects
named CustomerInfo, each instance of the support application has access only to its own
CustomerInfo object. Also, the data in CustomerInfo used by session1 is different from the data
in CustomerInfo used by session2.
// One instance of application "support"
first_nc = new NetConnection();
first_nc.connect("myserver.mydomain.com/support/session1");
first_so = SharedObject.getRemote("CustomerInfo", first_nc.URI, false);
first_so.connect(first_nc.URI);
// Another instance of application "support"
second_nc = new NetConnection();
second_nc.connect("myserver.mydomain.com/support/session2");
second_so = SharedObject.getRemote("CustomerInfo", second_nc.URI, false);
second_so.connect(second_nc.URI);
Many of the samples in this manual use the instance name room_01. However, you can use any
string for an instance name that makes sense in your application. For an example of dynamically
creating an instance name, see “Sample 5: Text Chat” on page 41.
For more information on using instance names, see the
NetStream.publish entry in the Client-
Side Communication ActionScript Dictionary. For information on making remote shared objects
available to multiple applications, see the
SharedObject.getRemote entry in the Client-Side
Communication ActionScript Dictionary.
File types used by Flash Communication Server
In addition to the file types created and used by Flash MX (FLA, SWF, and SWD), Flash
Communication Server uses or creates the following file types:
• ASC—server-side script files that you write
• FLV and IDX—recorded streams and their associated index files
• FSO, SOL, and SOR—shared objects that are persistent on the client, the server, or both
You use a JavaScript editor to write ASC files, which you must place in your application directory;
this is illustrated in many of the sample applications in this manual. For more information about
creating ASC files, see “Setting up your development environment” on page 17. For information
on where Flash Communication Server stores stream and shared object files, see “File types and
paths” on page 67.
Kommentare zu diesen Handbüchern