This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
Stream Names
|
157
Following through on the stream names used in Figure 5-1, if the remoteUserName
variable contains the string “robert”, then the relative URI of the stream being
requested via play( ) will be public/robert. If no stream of that name exists, no error
will be returned. Instead, the application will simply return data from a stream of
that name if and when one is published.
This short demonstration script can be used by two people to have a video, audio,
and text conversation, but it does suffer from some serious limitations. For example,
text messages appear only in the subscriber’s text field and there is no way for either
user to know the other is available and wants to chat. Also, the program should not
rely on both users entering both usernames in order to chat. Some additional pro-
gramming, most often using remote method calls and/or shared objects, is required
to overcome these limitations. Keeping track of and managing streams using shared
objects was first introduced in the helloVideo application in Chapter 1 and is
described in detail in Chapter 8.
Stream Names
There is no stream name management system directly available in either client- or
Server-Side ActionScript, though some stream management features are available
through the server management application programming interface (API) as
described in Chapter 10. When a movie connects to an application instance, there is
no built-in way for the movie to discover what live streams may be available, what
stream names it can use to publish without conflicting with another movie’s stream
names, and what recorded streams are available for playback. Instead, each applica-
tion is responsible for managing its own streams. This may sound like a drawback,
but FlashCom provides resources that give developers the flexibility to design appli-
cations with a wide variety of behaviors. When applications must provide the names
of the live streams currently being published, a shared object is often used. As
streams are published, the name of each stream is added to the shared object. When
a published stream is closed or the publishing movie disconnects, the stream name is
removed from the shared object. Collisions between stream names are often avoided
by centralizing stream naming within the application instance or by allocating a
unique name to each client. For example, a stream name can be based on a user’s
unique username or ID number. Alternately, a unique stream name, based on some
other scheme such as a sequence number, can be requested from the application via
a remote method call.
You can run into two related problems when stream names collide. With live
streams, if two movies attempt to publish streams with the same URI, the first
stream will succeed and the second will fail. Recorded streams add the possibility

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.