Testing your CommandProxy-based AIR app.
I watched a Battlestar Galactica episode recently, and I got to wondering what that soupy bathwater is that the cylons keep waking up in. Sometimes, I feel like all AIR developers are drifting asleep in that same soupy spa, dreaming of the day they can launch processes directly from AIR.
But most AIR developers have woken up gasping and screaming like on the TV show (why can’t they just shake them gently and say “you’ve been downloaded and reborn…there there…want some toast?”) with the realization that AIR does not let you do things like launch processes or have command-line access.
Personally I think the AIR team will someday address this issue, but until then you’ll need to use something like the CommandProxy pattern as suggested by Mike Chambers.
Chamber’s code will get you up-and-running, you just need to figure out how to compile it within C# and use the command classes he’s suggested for communicating with the proxy. (As well as think about the security issues some have raised, see Chamber’s follow-up post.)
However, using the CommandProxy will affect your testing if you chose to run your AIR app with the AIR Debug Launcher (ADL).
As most of you probably know, you can get debug messages out of an installed AIR app by running it via ADL. You’ll have to:
- Make sure the ADL.exe is in your classpath
- Add the AIR .xml application description file to your installation directory if it’s not already there
- Run the app not by clicking the .exe but by typing “ADL myAppName-app.xml”
But remember, these days you’re floating in soupy bathwater: if you’re using CommandProxy, you have to change the launch code inside the proxy to get ADL to launch your app.
To this, modify the lines in the LaunchAndRun() method in the CommandProxy.cs file to get the proxy to launch ADL rather than the .exe directly.
I did this by simply changing the processPath variable to “adl.exe”
processPath = "adl.exe";
and then modifying the following line
p.StartInfo.Arguments = authToken + " " + port;
to this…
p.StartInfo.Arguments = "myApp-app.xml -- " + authToken + " " + port;
You could probably figure out a cleaner way to do this — perhaps setting a boolean in your csproxy.cs class to quickly switch between testing to implementation builds of the CommandProxy.
