
Server-Side Communication ActionScript 17
p1 ..., pN Optional parameters passed to the application.onConnect method. These
parameters are passed from the client-side
NetConnection.connect method when a client
connects to the application.
Returns
The value you provide. If you return a Boolean value of true, the server accepts the connection; if
the value is false, the server rejects the connection. If you return null or no return value, the
server puts the client in a pending state and the client can’t receive or send messages. If the client
is put in a pending state, you must call
application.acceptConnection or
application.rejectConnection at a later time to accept or reject the connection. For example,
you can perform external authentication by making a NetConnection call in your
application.onConnect event handler to an application server, and having the reply handler
call application.acceptConnection or application.rejectConnection, depending on the
information received by the reply handler.
You can also call
application.acceptConnection or application.rejectConnection inside
the
application.onConnect event handler. If you do, any value returned by the function is
ignored.
Note: Returning 1 or 0 is not the same as returning true or false. The values 1 and 0 are treated the same as any
other integers and do not accept or reject a connection.
How to use application.onConnect to accept, reject, or put a client in a pending state
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
Comentários a estes Manuais