I need to implement a “Live Update” feature to my application…basically what I need to happen is whenever the xml files used to generate the floorplan that my application builds are changed, I need the application to seamlessly update the floorplan with the most up to date data…
As a first step I was going to implement a button that would flash red if the application decided that the xmls were altered…then the user would click the button to refresh the floorplan…my flash app would check to see if any changes have been made every 3 minutes or so…Ultimately I want the application to auto update without the user even knowing its happening…or with minimal interruption to the user…
I want to know if this is possible? And if so, will I need special hardware (servers) to get this done?
Checking every 3 minutes would be easy, just reload the XML and do a compare. Or have a call to the server that provides info on when they were changed last and request the entire XML then. You could also look at Blaze DS from Adobe and the network shared objects there, that would give you instantaneous notification, if I’m not mistaken.
Blaze DS will allow you to use the push method instead of the pull method.
For example, you can set up a socket connection that will allow Flash to listen for event from the server. If you only need to make the call every 3 minutes you shouldn’t have any server issues though. But let’s say you’re planning on having a ton of users and constantly ask for updates from the XML file you may run into problems.
Stratifacation probably gave the best option, just reload and compare.
Ok, i like the reload and compare method…however…will I be able to do this seamlessly without any interruption to the user? Say someone is looking at the floorplan (a layout of a hall with exhibitors booths inside where some booths are rented and some booths are available)…and the user is looking at an available booth and wants to rent it…but someone had just rented it with the CAD software that outputs my XMLS…the file gets updated and my app rechecks the xml…will this cause a pause or something for the user? The XMLs take a few seconds to load in initially…i do not want the XML to reload completely every 3 minutes if there are no changes to it…because I think with this solution I will have a pause as the XMLs are read back in…am I mistaken?
You shouldn’t really have a pause, since XML is loaded in and has an event when it’s finished it shouldn’t cause problems. However, if the XML takes a few seconds to read in initially then size may become an issue. If the files are pretty good sized then sending them all again every few minutes could get costly. If the system that generates the XML could place a file somewhere, or respond to a query with the time of the last update you could check that first and only re-load if there’s actually been a change.
If your xml comes from a server then you are in luck… simply have the server do a md5 hash on the xml file and send you the value along with the xml file (only first time).
you save it to client’s machine somewhere (sharedobject)
next time you request with this value … server checks to see if the md5 value that you are sending and of the xml file on the server noware different … then it send you the file else sends a response saying… no update needed.
md5 is available on flash toonowdays on many open source sites