Let’s focus on what happens between Hugo, the user and NetConnection: What are the options for exchanging data between red5 and Flex?
(click image to enlarge)
- All of these options are asynchronous.
- Besides loading video or audio streams, I also save some other loading mechanisms for future blogs:
- URLLoader: Loading text or binary data
- Note that RemoteClass is a different story. This is a metadata tag in ActionScript and tells Flex and red5 that a class in ActionScript corresponds to a class on the Java-side. You can use RemoteClasses with all options except Messaging (I believe).
- Sources are Joachim’s tutorials, Create new Java red5 application, Flex docs , particularly the API, red5 mailing list and red5 wiki.
1. Remote Shared Object (RSO)
- Flex API: SharedObject
- red5 API: SharedObject
- See previous entry.
- Some explanations to the drawing: Each dinosaur represents objects like a string, number, xml, class, etc. There is only one real group of dinosaurs. However, Hugo, Fiona and the server have one local copy of the group. As soon as anybody changes the SharedObject, it is automatically communicated to the others.
- Anna does not have the same SharedObject, so she knows nothing about dinosaurs.
- You can have any number SharedObjects in your system only limited by resource restrictions (pretty much the same as with groups of dinosaurs on earth).
- Groups of dinosaurs live in the wild (everybody can access them) or locked in the zoo (restrict access on the server)
2. Remote Procedure Call (RPC), Flex to red5
- Flex API: netConnection.call(command:String, responder:Responder, … arguments) : void
- red5 API: public member in class that is declared in red5-web.xml or in code
- It looks to me like this is the poor-mans way of communication while the Remote Objects seems to be the Rolls-Royce.
- A response is optional.
3. Remote Procedure Call (RPC), red5 to Flex
- Flex API: set netConnection.client = class with the public method “flexMethodName”
- red5 API: iServiceCapableConnection.invoke(”flexMethodName”)
- It’s basically the same as option 2. The main difference is that you need a ServiceCapableConnection. This can be done with all options 1-5 from here, but I suspect very different loads of network traffic. (Has anybody analyzed this?)
- As above, see Joachim’s guide.
4. Remote Object
- Flex API: RemoteObject, sample of a call
- red5: declarative, in code?
- This is the newest baby of red5. It has been just implemented. You find a sample in the echo application in red5.
- The dinosaurs symbolize an ancient Java object that hasn’t been necessarily created by the red5 programmer. In other words, you can use POJOs for RemoteObjects including Java classes from third-party libraries.
- RemotObjects are basically the same as RPC in option 2. It is nicely integrated into Flex so it looks like the other RPC services HTTPService and WebService.
5. Messaging
- Flex API: Producer, Consumer
- red5: ???
- The entire infrastructure like AsyncMessage exists in red5 but I haven´t invested in the how-to/whether.
- Consumer confirm each message with an ACK. I assume that the acknowledgment does not only go to the server but also to the Producer?
- Besides the ACK, messaging is a one-way communication. However, nobody will hold you off establishing Consumers also as Producers.
- There is always one Producer and 0 to infinite Consumer.
Suggestions, corrections, etc are welcome.
18 July 2007 at 7:29 |
[...] How Flex talks to red5 Update 16 July: see also How Flex exchanges data with red5 [...]