If you don't use the Flash Media Server components framework, you can execute code in the
application.onConnect
the components framework, however, any code you want to execute after the connection is
accepted or rejected must be placed in the event handlers
and
application.onConnectReject
whether a connection is accepted or rejected.
Example
The following example is the client-side code you can use for an application:
nc = new NetConnection();
nc.connect("rtmp:/test","jlopes");
nc.onStatus = function(info) {
trace(info.code);
};
nc.doSomething = function(){
trace("doSomething called!");
}
The following example is server-side code you can include in the main.asc file:
// When using components, always load components.asc.
load("components.asc");
application.onConnect = function(client, username){
trace("onConnect called");
gFrameworkFC.getClientGlobals(client).username = username;
if (username == "hacker") {
application.rejectConnection(client);
}
else {
application.acceptConnection(client);
}
}
// Code is in onConnectAccept and onConnectReject statements
// because components are used.
application.onConnectAccept = function(client, username){
trace("Connection accepted for "+username);
client.call("doSomething",null);
}
application.onConnectReject = function(client, username){
trace("Connection rejected for "+username);
}
34
Server-Side ActionScript Language Reference
handler after accepting or rejecting the connection. When you use
. This architecture allows all the components to decide
application.onConnectAccept
Need help?
Do you have a question about the FLASH MEDIA SERVER 2-SERVER-SIDE ACTIONSCRIPT LANGUAGE and is the answer not in the manual?