Flash Media Server |
|||
| Server-Side ActionScript Language Reference > Server-Side ActionScript Language Reference > Application class > Application.onConnectReject | |||
Flash Media Server (with communication components only).
application.onConnectReject = function (clientObj [,p1, ..., pN]){}
clientObj A Client object; the client connecting to the application.
p1...pN Optional parameters passed to the application.onConnectReject handler. These parameters are passed from the client-side NetConnection.connect() method when a client connects to the application.
Nothing.
Event handler; invoked only when communication components are used (that is, when the components.asc script is loaded into your server-side script) when NetConnection.connect() is called from the client side and a client fails to connect to an application instance.
Use onConnectReject to handler the result of an rejected connection in an application that contains components.
If you don't use the Flash Media Server components framework, you can execute code in the application.onConnect handler after accepting or rejecting a connection. When you use the components framework, however, any code you want to execute after the connection is accepted or rejected must be placed in the framework event handlers application.onConnectAccept and application.onConnectReject. This architecture allows all the components to decide whether a connection is accepted or rejected.
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 the 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);
}
}
application.onConnectAccept = function(client, username){
trace("Connection accepted for "+username);
client.call("doSomething",null);
}
application.onConnectReject = function(client, username){
trace("Connection rejected for "+username);
}
Application.acceptConnection(), Application.onConnect, Application.onConnectAccept, Application.rejectConnection()
Send me an e-mail when comments are added to this page | Comment Report
Current page: http://livedocs.adobe.com/fms/2/docs/00000657.html