Adobe 65029121 - Flash Media Streaming Server Developer's Manual page 32

Developer's guide
Hide thumbs Also See for 65029121 - Flash Media Streaming Server:
Table of Contents

Advertisement

To be resilient, your application needs to listen for and handle
As you test and run your application, you can also use the Administration Console to troubleshoot various
connection and stream events.
Handle a failed connection
If a connection cannot be made, handle the
objects. You may need to retry connecting to the server's URI, ask the user to reenter a user name or password, or
take some other action.
The event codes to watch for and sample actions to take are as follows:
Event
NetConnection.Connect.Failed
NetConnection.Connect.Rejected
NetConnection.Connect.AppShutDown
Note: Use the SimpleConnectManage sample, SimpleConnectManage.as, written in ActionScript 3.0.
Write client code to handle netStatus events
Create a NetConnection object and connect to the server. Then, write a
detect each event and handle it appropriately for your application, for example:
public function netStatusHandler(event:NetStatusEvent):void
{
trace("connected is: " + nc.connected );
trace("event.info.level: " + event.info.level);
trace("event.info.code: " + event.info.code);
switch (event.info.code)
{
...
case "NetConnection.Connect.Rejected":
trace ("Oops! the connection was rejected");
// try to connect again
break;
case "NetConnection.Connect.Failed":
trace("The server may be down or unreachable");
break;
case "NetConnection.Connect.AppShutDown":
trace("The application is shutting down");
// this method disconnects all stream objects
nc.close();
break;
...
}
}
Handle a stream not found
If a stream your application attempts to play is not found, a
NetStream.Play.StreamNotFound
such as displaying a message for the user or playing a standard stream in a default location.
Note: Use the Streams sample, Streams.as, written in ActionScript 3.0.
netStatus
event before you create a NetStream object or any other
netStatus
Action
Display a message for the user that the server is down.
Try to connect again.
Disconnect all stream objects and close the connection.
netStatus
. Your
event handler should detect this code and take some action,
netStatus
ADOBE FLASH MEDIA SERVER
events that affect connections and streams.
event handler in which you
netStatus
event is triggered with a code of
29
Developer Guide

Advertisement

Table of Contents
loading

This manual is also suitable for:

Flash media server

Table of Contents