Chapter 6. Network communication

 

Suppose for a moment that you’re building an application that allows users to edit text documents that live on a server connected to the internet. When the user starts the application, it connects to the server and retrieves a list of available documents. She can select a file, and the text is downloaded and made available for editing. When she saves the file, the application sends the new text to the server, where it’s saved. That application may work perfectly when the user is connected to the internet. But when the user isn’t connected, there’s a problem: she has no way to edit or save files, because those behaviors require an internet connection. Using AIR, you can build a better application, one that knows when the user is connected to the internet. By detecting whether the user is connected to the internet or whether a particular internet resource is available, the AIR application can respond appropriately. You can build the application to take different actions depending on network availability. For example, if a user of the text document–editing application starts the application while connected to the internet, she can start to edit a file. But if she has disconnected before trying to save the file (perhaps she has gotten on a plane), then it saves the data to a local database until the network is available again.

6.1. Monitoring network connectivity

6.2. Adding network monitoring to AirTube

6.3. Summary