MACROMEDIA FLASH MEDIA SERVER 2-CLIENT-SIDE ACTIONSCRIPT LANGUAGE REFERENCE FOR FLASH MEDIA SERVER 2 Uživatelský manuál Strana 27

  • Stažení
  • Přidat do mých příruček
  • Tisk
  • Strana
    / 172
  • Tabulka s obsahem
  • KNIHY
  • Hodnocené. / 5. Na základě hodnocení zákazníků
Zobrazit stránku 26
24
SERVER-SIDE ACTIONSCRIPT LANGUAGE REFERENCE FOR ADOBE MEDIA SERVER 5.0.1
Server-Side ActionScript Language Reference
Last updated 7/2/2013
Example
This example notifies all connected clients when a client disconnects from an application. The client-side FLA file
contains an input text field called
nameText, a dynamic text field called statusText, and a button called
connectButton. The user enters their name in the input text field. The client-side code passes the name to the server
in the
NetConnection.connect() call, as follows:
nc = new NetConnection();
nc.userDisconnects = function(name) {
statusText.text = name + ": disconnected";
}
nc.onStatus = function(info){
statusText.text = info.code;
}
connectButton.onPress = function() {
nc.connect("rtmp://localhost/testapp", nameText.text);
};
The server-side onConnect() handler receives the user name from the client-side code and assigns it to a property of
the Client object. The server passes the Client object to the
onDisconnect() handler when a client disconnects from
the application. The
Client.call() method inside the onDisconnect() handler calls the userDisconnects
method on the client and passes it the name of the disconnecting client. The client displays the name of the
disconnected user.
application.onConnect = function(client, name){
client.name = name;
trace(client.name + ": onConnect");
return true;
}
application.onDisconnect = function(client){
for (var i = 0; i < application.clients.length; i++){
application.clients[i].call("userDisconnects", null, client.name);
}
trace(client.name + ": onDisconnect");
}
Note: To pass optional parameters to the Client.call() method, pass null for the second (responseObject)
parameter.
application.onPeerLookup()
application.onPeerLookup = function (event:Object){}
Invoked when Adobe Media Server receives a request from a client to connect to another peer. The initiating peer is
the peer that makes the request. The target peer is the peer to which the initiating peer wants to connect. Both the
initiating peer and the target peer can be connected directly to the server or remote. To reply to the peer lookup
request, call
application.sendPeerRedirect().
Availability
Flash Media Server 4.5
Parameters
event Object; contains information about the intiating peer and the target peer. Pass the event object in calls to
application.sendPeerRedirect(). Pass the event.tag object in calls to Client.introducePeer().
The event object contains the following properties:
Zobrazit stránku 26
1 2 ... 22 23 24 25 26 27 28 29 30 31 32 ... 171 172

Komentáře k této Příručce

Žádné komentáře