Section 3.4. Multiple Simultaneous NetConnection Objects

3.4. Multiple Simultaneous NetConnection Objects

Macromedia recommends against making multiple connections from a single Flash movie to a FlashCom Server or Servers at the same time. First of all, each server can handle only so many simultaneous connections and the data transfer overhead that goes with them. Furthermore, FlashCom is licensed by the number of simultaneous connections. Therefore, whenever possible, avoid designing communication applications that require multiple simultaneous connections. However, a Flash movie can connect simultaneously to different applications or different instances of the same application; it can also connect multiple times to the same application instance, if necessary. This is an especially useful feature when testing applications and in developing larger scale multi-instance applications.

The simple test script in Example 3-7 makes two connections to the same chat room instance.

Example 3-7. Using more than one NetConnection object
 NetConnection.prototype.onStatus = function (info) {   trace(this.name + ": " + info.code); }; nc1 = new NetConnection( ); nc1.name = "First connection"; nc2 = new NetConnection( ); nc2.name = "Second connection"; nc1.connect("rtmp:/testChat/room1", "Guest", "Guest"); nc2.connect("rtmp:/testChat/room1", "Guest", "Guest"); 

Assuming there are no problems with the network or server, the trace output from this test will look like this:

 First connection: NetConnection.Connect.Success Second connection: NetConnection.Connect.Success 

Multiple connections are useful when debugging, the topic of the next section.



Programming Flash Communication Server
Programming Flash Communication Server
ISBN: 0596005040
EAN: 2147483647
Year: 2003
Pages: 203

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net