MACROMEDIA FLASH COMMUNICATION SERVER MX-SERVER-SIDE COMMUNICATION ACTIONSCRIPT DICTIONARY Especificaciones Pagina 318

  • Descarga
  • Añadir a mis manuales
  • Imprimir
  • Pagina
    / 369
  • Tabla de contenidos
  • MARCADORES
  • Valorado. / 5. Basado en revisión del cliente
Vista de pagina 317
18
Description
Event handler; invoked on the server side when NetConnection.connect is called from the
client side and a client attempts to connect to an application instance. You can define a function
for the
application.onConnect event handler. If you dont define a function, connections are
accepted by default. If the server accepts the new connection, the
application.clients object
is updated.
You can use the
application.onConnect event in server-side scripts to perform authentication.
All the information required for authentication should be sent to the server by the client as
parameters (
p1 ..., pN) that you define. In addition to authentication, the script can set the access
rights to all server-side objects that this client can modify by setting the
Client.readAccess and
Client.writeAccess properties.
If there are several simultaneous connection requests for an application, the server serializes the
requests so there is only one
application.onConnect handler executing at a time. It is a good
idea to write code for the
application.onConnect function that executes quickly to prevent a
long connect time for clients.
Example
This example verifies that the user has sent the password “XXXX”. If the password is sent, the
users 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 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.rejectConnection
Application.onDisconnect
Availability
Flash Communication Server MX.
Vista de pagina 317
1 2 ... 313 314 315 316 317 318 319 320 321 322 323 ... 368 369

Comentarios a estos manuales

Sin comentarios