O'Reilly logo

Agile Enterprise Application Development with Flex by Tony Hillerson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

A Server As a Command Center

Strange as it sounds, a clock is another excellent example of streaming. Using a streaming AMF channel to deliver the server time, you can create a clock that updates its display every second. As a bonus, the clock application demonstrates another useful concept: the reverse remote procedure call (RPC).

Reverse RPC

A remote procedure call is when a client invokes a function on the server-side object. For example, you can create an instance of the RemoteObject that points at a destination (a Java class) configured in the server-side BlazeDS. Then this Flex client calls a method on this destination.

The example clock application instructs a server to control the client when it wants, the way it wants. This is a reverse RPC: the server calls a client. Traditional server-side destinations are usually preconfigured in XML files, such as remoting-config.xml; however, you don’t have this luxury on the client. Instead, during runtime you need to pass the name of the client destination, the method to call, and an array of parameters, if any. Here, the AMF protocol becomes quite handy once again. Remember, it offers an easy way to serialize a Java object on the server and deserialize it as an ActionScript object on the client.

If you understand the concept of DTO being an exchange currency between Java and ActionScript, the rest of this section won’t be difficult. Just think outside the box and create a DTO that will carry not some application-specific data (e.g.,the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required