FlightGear has a neat built-in HTTP server that lets you view and alter properties of the simulation.
http://wiki.flightgear.org/Property_Tree
The server will spit the entire tree (and some rudimentary controls for changing values) out if you open the root folder, but the wiki implies that getting/setting individual variables over HTTP (without needing to manually navigate to each property and click a button to set a new value) should be possible.
I think that pitching the server the name of the node that contains the property I want will cause the server to return the current value, and somehow sending the node name paired with a value will set the value. I can’t figure out how to do this.
My knowledge of HTTP is pretty weak so I spent a little bit of time noodling through some info. Once I was able to refine some search parameters I gleaned enough to write this script that should at least dump the base web page HTML (and the headers) at me:
<html> <body> <script> var req = new XMLHttpRequest(); req.open('GET', 'HTTP://192.168.1.5:5500', false, 'localhost'); req.send(); </script> </body> </html>
This doesn’t seem to work once req.send() is run. I get an error in the Javascript console that says Access-Allow-Control-Origin doesn’t allow someone on my domain to make the request. This doesn’t make sense since I’m on the same computer, which is the same domain (localhost)…. right? Like I said, my HTTP/Javascript/etc knowledge is super weak. I’m not even sure if I’m using the terminology right.
I checked the source of the FlightGear HTTP server and sure enough it doesn’t include in the returned header a special allowance to enable cross-domain scripting. I suppose I could submit a feature request. I also suppose I could see if I can compile the source and make the change myself (a trivial two-line add).
It’s more likely that I’m doing this all wrong. Maybe some sleep will help.