This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
Testing and Debugging Network Connections
|
93
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 applica-
tions 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 devel-
oping larger scale multi-instance applications.
The simple test script in Example 3-7 makes two connections to the same chat room
instance.
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.
Testing and Debugging Network
Connections
Networked applications present some additional difficulties when testing or debug-
ging programs, as more than one system is always involved. A connection attempt
may fail for many reasons, including the following:
The target URI may be incorrect (watch for typos).
A username or password may be wrong.
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");

Get Programming Flash Communication Server now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.