This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
46
|
Chapter 2: Communication Components
ConnectionLight
The ConnectionLight component provides a visual aid to indicate the status of the
connection to the server-side FlashCom application.
The status is shown as a colored circle with one of four color states:
Gray
Indicates a connection has yet to be attempted or a prior connection is closed.
Green
Indicates a stable connection (via a NetConnection instance) to the FlashCom
application.
Red
Indicates an attempt to connect to the FlashCom application failed or was
rejected. This color can also indicate that the current connection was unexpect-
edly lost or intentionally closed.
Yellow
After making a successful connection to the FlashCom application, the client
movie may experience delays with packet submissions. If the delay period
exceeds the specified threshold, the light turns yellow.
The ConnectionLight component rechecks the connection’s status (connected or dis-
connected) every half second (500 milliseconds).
If the user clicks the ConnectionLight instance (the colored circle), Flash displays the
information overlay shown in Figure 2-5.
The overlay contains more detailed information about the connection status:
Latency
Average time, in milliseconds (ms), for packets to be transmitted from the client
movie to the FlashCom Server. Higher latency values can indicate a slow connec-
tion (usually on the client side), temporary network congestion, or an overtaxed
FlashCom Server.
Up
The bit rate of data sent from the client movie to the FlashCom Server. Use this
to monitor bandwidth consumed by shared object connections and when pub-
lishing audio and video over a NetStream instance.
Figure 2-5. The information overlay of the ConnectionLight component
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
Summary of Communication Components
|
47
Down
The bit rate of data received by the client from the FlashCom Server. Synchroni-
zation operations with shared object data and subscribed streams contribute to
the overall value.
The Up and Down values are automatically displayed in units of bit/s (bits per sec-
ond), kbit/s (kilobits per second), or mbit/s (megabits per second) based on the con-
nection speed.
Client-side component parameters
The ConnectionLight component has two settings that can be configured at an
instance level in the Properties panel or Component Parameters panel:
Measurement Interval
This parameter, corresponding to the
interval property, specifies the time, in
seconds, that the instance waits to poll the FlashCom Server for updated connec-
tion statistics. The default value is 2 seconds. If you set a higher value, such as 5
or 10 seconds, the component will not consume as much bandwidth for data
transfers as a lower interval such as 1 second. If you do not want to add to the
bandwidth overhead for your application, use higher values.
Latency Threshold
If a packet’s travel time between the Flash movie and FlashCom Server exceeds
this value, in seconds, the ConnectionLight instance’s icon changes from green
to yellow. This parameter corresponds to the
threshold property; the default
value is 0.1 second (100 milliseconds). This value adequately lets you know if
audio/video streaming will have noticeable delays to other participants subscrib-
ing to the stream or if text messages between users in a chat will be delayed.
Any time a Flash movie connects to a FlashCom application, data
packets are sent back and forth to the client in order for the Flash-
Com Server to know that a client still exists. As such, the FlashCom
Server always knows how much latency is present between itself and
any connected client.
How the component works
In order for the ConnectionLight component to function properly, an instance of it
must be connected to the NetConnection object used by the Flash movie using Con-
nectionLight.connect( ). Using a SimpleConnect instance and specifying the Connec-
tionLight instance in its list of communication components invokes ConnectionLight.
connect( ) automatically. Otherwise, you need to invoke connect( ) on the Connec-
tionLight instance manually in your client-side ActionScript code.
Unlike other communication components, the ConnectionLight component does not
use any remote shared objects or NetStream objects. It uses only call( ) to invoke

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

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.