
ADOBE FLASH MEDIA INTERACTIVE SERVER
Server-Side ActionScript Language Reference
18
How to use application.onConnect() to accept, reject, or put a client in a pending state.
A. Client-side ActionScript B. Server-Side ActionScript
Example
The following examples show three ways to accept or reject a connection in the
onConnect() handler:
(Usage 1)
application.onConnect = function (clientObj [, p1, ..., pN]){
// Insert code here to call methods that do authentication.
// Returning null puts the client in a pending state.
return null;
};
(Usage 2)
application.onConnect = function (clientObj [, p1, ..., pN]){
// Insert code here to call methods that do authentication.
// The following code accepts the connection:
application.acceptConnection(clientObj);
};
(Usage 3)
application.onConnect = function (clientObj [, p1, ..., pN])
{
// Insert code here to call methods that do authentication.
// The following code accepts the connection by returning true:
return true;
};
The following example verifies that the user has sent the password “XXXX”. If the password is sent, the user’s access
rights are modified and the user can complete the connection. In this case, the user can create or write to streams
and shared objects in the user’s own directory and can read or view any shared object or stream in this application
instance.
// This code should be placed in the global scope.
application.onConnect = function (newClient, userName, password){
// Do all the application-specific connect logic.
if (password == "XXXX"){
NetConnection.onStatus(info)
info.code == NetConnection.Connect.Rejected
NetConnection.connect()
NetConnection.onStatus(info)
info.code == NetConnection.Connect.Success
application.onConnect(clientObject)
return true
or call
application.acceptConnection()
return false
or call
application.rejectConnection()
return null
or don’t return a value
places application in a pending state
A
B
Commentaires sur ces manuels