This content has been marked as final. Show 1 reply
There are many ways to approach this particular problem.. These are my takes on this.
First, I don't think you'll need to create a separate interface for the air application. You can use your current interface if you want, and I guess it would save you a lot of time on building a separate interface.
Since you'll be loading external content, you'll need to use two sandboxes: the main application sandbox and the non-application (iframe) sandbox--but I guess you already know that. You'll have to use these two separate (albeit connected) sandboxes to your advantage.
The algorithm goes something like this: When the user starts the application, the main application sandbox should check whether or not the user is connected to the internet (via the URLMonitor subclass of the ServiceMonitor Class). If the user is online, then it will proceed and trigger an event (or function) from the non-application sandbox that will tell it to load the content from the external website. When the content is loaded, the app should then perform a silent caching of the loaded data, storing it on the local computer. If the user is offline, then the app should load cached local data instead or if there is no cached data, then a helpful dummy page should then be loaded.
You can then monitor the events in the non-application sandbox. If the user is online and tries to click a link, then proceed with the normal functions and routine loading. If the user is offline, then the application should then cancel the event and proceed with any functions that handle loading cached pages or showing error (non-connectivity) messages.
This approach works well in the sense that you almost won't have to change any code on your website. All of the event handling, monitoring and checking will be done by the air application and the code in the application sandbox. Which means you can use the code on your website as it is without any further changes.
The cons of this approach it that you'll probably spend a lot of time in fine-tuning your application sandbox code to handle certain events. But when you actually get the basic code, it's almost smooth sailing from there.
The other approach I can suggest is that you'll use the non-application sandbox code to detect whether the user is using a regular browser or the air app in loading the website. After detecting this, you can use separate functions to handle loading pages depending on whether or not the user is offline. For instance, after determining that the user is using an air app, a function in the non-application sandbox can then ping the application sandbox (via a script through the sandbox-bridge) to see if the app is online. If it is, then you can proceed with normal loading. If not, you can then again access another function via the sandbox bridge to load content from the catch.
Hope this helps!