Description
Event handler; invoked on the server side when
client side and a client attempts to connect to an application instance. You can define a function
for the
application.onConnect
accepted by default. If the server accepts the new connection, the
is updated.
You can use the
application.onConnect
All the information required for authentication should be sent to the server by the client as
parameters (
...,
p1
rights to all server-side objects that this client can modify by setting the
Client.writeAccess
If there are several simultaneous connection requests for an application, the server serializes the
requests so there is only one
idea to write code for the
long connect time for clients.
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);
}
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
property set to "Invalid password" is returned to the client side. The object is assigned to
infoObject.application
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.onDisconnect
Availability
Flash Communication Server MX.
18
event handler. If you don't define a function, connections are
) that you define. In addition to authentication, the script can set the access
pN
properties.
application.onConnect
application.onConnect
. To access the
,
Application.rejectConnection
NetConnection.connect
event in server-side scripts to perform authentication.
handler executing at a time. It is a good
function that executes quickly to prevent a
property, use the following code on the client
message
is called from the
application.clients
Client.readAccess
message
object
and
Need help?
Do you have a question about the FLASH COMMUNICATION SERVER MX-SERVER-SIDE COMMUNICATION ACTIONSCRIPT DICTIONARY and is the answer not in the manual?