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

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

Advertisement

In the server-side code, the application can accept or reject connections from clients, shut down the application, and
perform other tasks to manage the connection. When a client connects, the application receives an
application.onConnect
application.onDisconnect
To manage the connection from the server, start with
application.onDisconnect()
Managing connections sample application
This example shows how to manage connections from both the application client and the server-side code.
Write the client code
In the client code, you need to check for specific connection codes and handle them. Create live streams or play
recorded streams only when the client receives
NetConnection.Connect.AppShutDown
case, close the connection to the server.
Note: See the SimpleConnectManage sample, SimpleConnectManage.as, written in ActionScript 3.0.
1
Create a NetConnection object and call the
Write a
event handler. In it, check for specific connection codes, and take an action for each:
2
netStatus
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.Success":
trace("Congratulations! you're connected");
// create live streams
// play recorded streams
break;
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");
// display a message for the user
break;
case "NetConnection.Connect.AppShutDown":
trace("The application is shutting down");
// this method disconnects all stream objects
nc.close();
break;
case "NetConnection.Connect.Closed":
trace("The connection was closed successfully - goodbye");
// display a reconnect button
break;
}
}
event. Likewise, when the client disconnects, the application receives an
event.
in Server-Side ActionScript.
NetConnection.Connect.Success
, all streams from server to client or client to server are shut down. In that
connect()
application.onConnect()
method to connect to the server.
ADOBE FLASH MEDIA SERVER
Developer Guide
and
. When the client receives
22

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the 65029121 - Flash Media Streaming Server and is the answer not in the manual?

This manual is also suitable for:

Flash media server

Table of Contents