View comments | RSS feed

Application.rejectConnection()

Availability

Flash Communication Server MX 1.0.

Usage

application.rejectConnection(clientObj, errObj)

Parameters

clientObj A client to reject.

errObj An object of any type that is sent to the client, explaining the reason for rejection. The errObj object is available in client-side scripts as the application property of the information object that is passed to the application.onStatus call when the connection is rejected. For more information, see the appendix, "Client-Side Information Objects," in the Client-Side ActionScript Language Reference for Flash Media Server 2.

Returns

Nothing.

Description

Method; rejects the connection call from a client to the server. The application.onConnect event handler notifies a script when a new client is connecting. In the function assigned to application.onConnect, you can either accept or reject the connection. You can also define a function for application.onConnect that calls an application server for authentication. In that case, an application could call application.rejectConnection from the application server's response callback to disconnect the client from the server.

When you use components and your code includes an explicit call to application.acceptConnection or application.rejectConnection, the last line (in order of execution) of the onConnect method should be either application.acceptConnection or application.rejectConnection. Also, any logic that follows the explicit acceptConnection or rejectConnection statement must be placed in application.onConnectAccept and application.onConnectReject statements, or it will be ignored. This requirement exists only when you use components.

Example

In the following example, the client specified by client1 is rejected and provided with the error message contained in err.message. The message "Too many connections" appears on the server side.

function onConnect(client1){
    // Insert code here.
    var err = new Object();
err.message = "Too many connections"; application.rejectConnection(client1, err); }

The following code should appear on the client side:

clientConn.onStatus = function (info){
    if (info.code == "NetConnection.Connect.Rejected"){
        trace(info.application.message);
        // Sends the message 
        // "Too many connections" to the Output panel
        // on the client-side.
    }
};

See also

Application.onConnect, Application.acceptConnection()


Comments


Leszek Mzyk said on May 11, 2007 at 1:52 AM :
The connections rejected with rejectConnection method, are using the possible connections. E.g. on fms2 developer edition with connection limit 10 clients, after rejecting 5 connections, it's possible to have max 5 active connections.
Does enyone know where's the problem?

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/fms/2/docs/00000662.html