User Guide

Application class 31
How to use application.onConnect to accept, reject, or put a client in a pending state.
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.
New Client object
(not accepted or rejected yet)
NetConnection.connect
Pending clientApplication.onConnect
Server-side ActionScript
true, acceptConnection
false, rejectConnection
Client-side ActionScript
Rejected
client
Accepted
client
rejectConnection
acceptConnection
none, null