Hi,
I'm currently translating a Java project to Flex 3. A large part of the project involves asynchronous communications.
The program will connect to a stream, start downloading data. Shortly after connecting, it will need to download context data in the same format (a keyframe) by HTTP. At various points during the stream or keyframe, additional HTTP calls may be required, e.g. to get an encryption key.
In Java, I'd use a blocking call to perform the HTTP requests to get the key which would effectively pause the keyframe or stream while the HTTP is completing, which would then carry on where it was.
Unfortunately, Flex being single-threaded, and HTTP requests being implemented with asynchronous call-backs, it's impossible to implement the code in the same way.
Being new to Flex, I'm not sure what the normal practice would be for this. Currently, I'm planning to save the state and exit, relying on the HTTP completion to re-start the paused stream. Or maybe use timers ...
But for the stream, should I decouple the data being received from the processing it and buffer it while the HTTP requests are being processed? Or is it safe to ignore the progress events and let Flex and/or the OS buffer it?
Does anyone have any advice on an architecture which would make all this easier?
Thanks!
EDIT: Thanks for the answers so far ...
dirkgently - I'm not sure I understand what you're getting at, but I'll look into it.
brd6644 - one of the connections (the stream) is already a raw socket. The question was about pausing it and grabbing some other data from another source mid-stream.
CookieOfFortune - that looks useful, thanks.