
Client-Side Communication ActionScript 59
If your connection fails, make sure you have met all the requirements for connecting successfully:
• You are specifying the correct protocol name for connecting to the server (rtmp for the Flash
Communication Server).
• You are connecting to a valid application on the correct server.
• You have a subdirectory in the FlashCom application directory with the same name as the
application.
• The server is running.
To distinguish among different instances of a single application, pass a value for
instanceName as
part of
targetURI. 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.
nc.connect("rtmp://www.myserver.com/chatApp/peopleWhoSew")
nc.connect("rtmp://www.myserver.com/chatApp/peopleWhoKnit")
In another case, you may have an application named “lectureSeries” that records and plays back
classroom lectures. To save individual lectures, pass a different value for
instanceName each time
you record a lecture, as shown below.
// Record Monday’s lecture
nc.connect("rtmp://www.myserver.com/lectureSeries/Monday");
...
ns.connect(nc);
ns.publish("lecture", "record");
// Record Tuesday’s lecture
nc.connect("rtmp://www.myserver.com/lectureSeries/Tuesday");
...
ns.connect(nc);
ns.publish("lecture", "record");
// and so on
// Play back one of the lectures
nc.connect("rtmp://www.myserver.com/lectureSeries/Monday");
...
ns.connect(nc);
ns.play("lecture")
You can also nest instance names, as shown below.
nc.connect("rtmp://www.myserver.com/chatApp/peopleWhoSew/Monday")
nc.connect("rtmp://www.myserver.com/chatApp/peopleWhoSew/Tuesday")
For information on where recorded streams are stored on the server, see NetStream.publish.
Commentaires sur ces manuels