Thursday, July 2, 2009

Overview of the Flex Communication APIs

One of the reasons for starting this blog was to further the available documentation for the Red5 project. Oddly enough, however, even when you ignore the specific server technology you use, there aren't many good overviews of the APIs available to you as a Flex developer. Below is an overview of the available client-side APIs for various server communication functions. This is only meant as a quick reference and not as an instructive guide. To learn each API you will need to review examples and use them in your own programs. Note that depending on which server platform you choose to use, only a subset of these APIs will implemented.

Streaming

NetConnection
A NetConnection is a pipe between a client and a server. It is used for two purposes:
  1. Constructing NetStream objects (see NetStream) and acting as the pipe over which those NetStreams flow.
  2. Calling methods on the server side application class handling the connection via the call() method.
NetStream
A NetStream is a one-way channel created over a NetConnection for the sending or receiving of streaming
data. Streams are sent with publish() and received with play(). The data is usually going to be audio or video, but it is also possible to send objects as well using the send() method. Audio and video streams can be either live or prerecorded (often described as video-on-demand or VOD).

Depending on the usage, the connection over which the NetStream is made can be to a server, a
peer, or the local file system.

RPC

HTTPService
Makes a simple aynchronous HTTP or HTTPS call using the Responder pattern.

WebService
Makes a call to a SOAP web service. Like HTTPService, uses HTTP or HTTPS as the transport.

RemoteObject

A Remote Object is a client-side stub that gives you access to the matching methods on a server-side class as if it were local to the client.

Messaging

Consumer
Used to receive asynchronous messages. Messages can be generated from the server or another client, but must be routed through the server.

Producer
The Producer class sends aynchronous messages. These messages are sent to the server, which can process them and optionally deliver them to other clients.

SharedObject
When used in a remote manner, SharedObject acts sort of like a Producer and Consumer rolled up in one. The SharedObject component does just what you might expect from its name: it maintains a piece of data on a server that appears the same to all connected clients.

DataManagement

DataService
Part of the Data Management Service of LCDS. The DataService API allows you to easily retrieve data from a remote database-connected service.

Low-Level Protocols

Socket
Creates a TCP socket. This isn't usually listed as a communication API in Adobe documentation, probably because there are no default implementations on the server side that don't speak a higher level protocol such as HTTP.

XMLSocket

Speaks a simple custom protocol for exchanging XML messages between a client and server

Further Reading

In writing this article I came across an excellent post that covers getting started with LCDS and gives a quick overview of the APIs available on that platform, as well as references to other places to pick up information.

0 comments:

Post a Comment