punchkick
07-28-2008, 02:43 PM
Is it possible to create the following situation:
A stand-alone, invisible BREW application that acts as the data layer and sets up a local XML socket connection to another stand-alone file on a BREW device. The other stand-alone file would be a Flash Lite application (run as a MOD/MIF set). The Flash Lite application will communicate with the BREW data layer by using an XML socket connection--presumably to "localhost".
Thanks ahead of time for your response.
-Ryan
abhilasha
04-07-2009, 04:10 AM
Anybody has any comments on Ryan solution for communication between Flash and C Code?
punchkick
04-07-2009, 10:29 AM
Hello abhilasha,
I can follow up on this to say that it is possible, because I have done it. I was the Flash Lite engineer on the team, and not the lead C developer, so unfortunately I can not speak to the C source code for the socket (please share if you have an example of this). That said, hopefully this description will be valuable for you...
1. Build a Flash Lite app and compile the MIF/MOD. The pair will have an class ID, something like '0x01075be4'.
2. Write a C application that launches your Flash Lite application. You can do this easily because the Flash Lite MOD is just a C application with a unique class ID (e.g. 0x01075be4). The C application should have no visuals whatsoever, it's simply used for processing data.
3. The data application built in C should immediately setup a socket connection upon launching. Our local socket was on 127.0.0.69:8080. After the socket is initialized, launch the Flash Lite MOD--which has visuals.
4. The Flash Lite application should connect to the socket when launched. After the connection is made, data should be able to back and forth very easily. Just as an FYI, name/value pair data is MUCH cheaper than XML strings. Yes, name/values are harder to manage, but it's worth the extra effort, because Flash Lite maxes out on memory QUICKLY.
5. Regarding the name value pairs, I'd recommend a mock-dictionary. For instance, s0e0=foo&s0e1=bar&
6. Just as an FYI, if your socket is pushing too much data too quickly it will crash your Flash Lite application. Consider having your Flash Lite application send requests based on a timed interval.
7. When you quit the Flash Lite application, you should first send an message to the data application via the socket to close the connection to the socket. fscommand2("Quit"); within Flash Lite automatically will dispatch an event to your C application. Your C application should be setup to quit itself when it receives this event.
8. Another quick note, BREW applications cannot be launched directly from Flash Lite. If you need to launch another application, send a message to the socket with parameters, and have your data application launch whatever is needed. For instance, Flash Lite could send, "//launch|web|http://www.foo.com". We had built an app that did this perfectly. When the launched app was quit, the original Flash Lite application was shown on the screen right where the user had left off.
vBulletin v3.0.13, Copyright ©2000-2009, Jelsoft Enterprises Ltd.