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 ...
Get Agile Enterprise Application Development with Flex 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.