
19
SERVER-SIDE ACTIONSCRIPT LANGUAGE REFERENCE FOR ADOBE MEDIA SERVER 5.0.1
Server-Side ActionScript Language Reference
Last updated 7/2/2013
Returns
A boolean value; true causes the server to accept the connection; false causes the server to reject the connection.
When true is returned, NetConnection.onStatus() is invoked on the client with info.code set to
"NetConnection.Connect.Success". When false is returned, NetConnection.onStatus() is invoked on the
client with
info.code set to "NetConnection.Connect.Rejected".
If null or no value is returned, 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() in 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.
A. Client-side ActionScript B. Server-Side ActionScript
Example
The following examples show three ways to accept or reject a connection in the onConnect() handler:
NetConnection.onStatus(info)
info.code == NetConnection.Connect.Rejected
NetConnection.connect()
NetConnection.onStatus(info)
info.code == NetConnection.Connect.Success
application.onConnect(clientObject)
return true
or call
application.acceptConnection()
return false
or call
application.rejectConnection()
return null
or don’t return a value
places application in a pending state
A
B
Komentáře k této Příručce