Section 5.2. Stream Names

5.2. 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 application is responsible for managing its own streams. This may sound like a drawback, but FlashCom provides resources that give developers the flexibility to design applications 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 that streams will be unintentionally overwritten or deleted. Here are a few ways to allocate relative URIs to streams to avoid name conflicts:

  • In live video conference and chat systems, use each user's unique username or ID to name the stream that each user publishes. If each user publishes more than one stream, use sequence values appended to the user's name. In some cases, the instance name of a movie clip can be appended to the user's name.

  • Use directory names to group streams. For example, each user could record streams to his own directory named after his unique username. You can extend this idea even further by controlling write access to certain directories using a server-side script. For example, if a unique username is assigned to each user, then the code client.writeAccess = "/" + userName; will restrict the Flash movie represented by the client object from writing to anything unless it is within the user's own directory.

  • Use remote method calls to request unique names from the server. See Chapter 8 and Chapter 9 on remote method calls and shared objects. Examples include sequence numbers generated on the server and validating user-suggested stream URIs before they are used to make sure only one user can use a URI.

  • Append a timestamp or other unique sequence value to a stream name.



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