
20
Example
This 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"){
newClient.writeAccess = "/" + userName;
this.acceptConnection(newClient);
} else {
var err = new Object();
err.message = "Invalid password";
this.rejectConnection(newClient, err);
}
};
If the password is incorrect, the user is rejected and an information object with a message
property set to “Invalid password” is returned to the client side. The object is assigned to
infoObject.application. To access the message property, use the following code on the client
side:
ClientCom.onStatus = function (info){
trace(info.application.message);
// it will print "Invalid password"
// in the Output window on the client side
};
See also
Application.acceptConnection, Application.onConnectAccept,
Application.onConnectReject, Application.rejectConnection
Kommentare zu diesen Handbüchern