Updates to the SimpleConnect component
The following updates have been made to the SimpleConnect component:
| |
A new event handler;onComponentsConnected;has been added to the SimpleConnect component. |
| |
The SimpleConnect component can now load the server name from an external XML file. |
| |
The connection times forHTTP tunneling have been improved. |
Using the onComponentsConnected event handler
Use this event handler with the SimpleConnect component on your stage to connect several other components when you need to execute additional Flash Communication Server code after all the components are connected to the server. The onComponentsConnected event handler is called when the components have all connected.
In the following example, the SimpleConnect component (instance nameconnect_mc) is connecting two AVPresence components (av1_mc and av2_mc). To use onComponentsConnected, add the following code in your main timeline:
connect_mc.onComponentsConnected = function() { trace("all the components have been connected"); //change the buffertime of the stream used by av1_mc av1_mc.ns.setBufferTime(3); }
Loading the server name from an external XML file
Currently, developers specify the server to which the application connects in the Application Directory parameter of the SimpleConnect component. This writes the location to the RTMP string. In such a scenario, any change to the IP address or in the name of the Flash Communication Server requires that the developer republish the FLA.
To overcome this workflow issue, the SimpleConnect component can now load the server name from an external XML file. Loading the server name from an XML file is expedient for development and can also improve the speed of connections if users are behind a firewall or proxy server (see "Improved connection times for HTTP tunneling").
To load the server name from an XML file:| 1 | In your application's FLA file, click the SimpleConnect component and open the Property Inspector. |
| 2 | In the Application Directory box, enter the following string: fromXML/appName[/appinstanceName/] The"fromXML" string replaces the "rtmp:/[/servername]/" string. |
| 3 | In the directory that contains the SWF file for your application, create a file called settings.xml. This XML file has the following format: <appSetting><serverName>myServerName</serverName></appSettings> where myServerName is an IP address or domain name, such as flashcom.mydomain.com or 10.60.0.124. Do not specify RTMP or RTMPT here, only the address of the server to connect to (SimpleConnect will use RTMP and try RTMPT if needed). |
If you leave ServerName blank, SimpleConnect uses the relative path rtmp:/appName/[appinstanceName/] to connect. For more information on relative paths, see the topic "Designing for portability across servers" in the "Application Development Tips and Tricks" chapter of Developing Communication Applications Help.
Once the XML file is set up, if your server name changes, simply edit the settings.xml file. No changes to the application's FLA or SWF files are needed.
Improved connection times for HTTP tunneling
The addition of support for HTTP tunneling to Flash Communication Server, through the RTMPT protocol, allows RTMP traffic to go through firewalls and proxy servers. As described in the NetConnection.connect entry in the Client-Side Communication ActionScript Dictionary, if you use the default connection path
rtmp:/[/servername]/appName/[appinstanceName/] (RTMP and no port specified)
the Flash Player tries to connect using RTMP on the default port 1935, followed by RTMP on port 443, followed by RTMP on port 80 and finally using RTMPT (tunneling) on port 80. On some systems (especially Macintosh OS X), each of these attempts could take up to 2 minutes to time out. A user behind a firewall might have to wait up to 6 minutes before successfully connecting to Flash Communication Server.
To alleviate this delay, the SimpleConnect component has been improved to make two connection attempts, 250 milliseconds apart: the first uses RTMP and the second uses RTMPT. When one connection succeeds, the other is discarded. This dramatically decreases the time it takes for a connection to be established.
To ensure that the SimpleConnect component makes two connection attempts, open the Property Inspector for the SimpleConnect component and in the Application Directory parameter, specify the default connection path (RTMP and no port) or load the server name from an XML file. See "Loading the server name from an XML file" in these notes.
Note:If you explicitly specify rtmpt:/ in the "Application Directory" parameter, you won't get the improved performance of the SimpleConnect component. In general, an explicit tunneling connection might not perform as well as a regular RTMP connection. Using the default RTMP protocol is recommended whenever possible.
Additional information
For more information on components, please see the main components page.
This content requires Flash
To view this content, JavaScript must be enabled, and you need the latest version of the Adobe Flash Player.
Download the free Flash Player now!
