-
2 Apr 2012 7:52 AM #1
Answered: Server TimeOut function for connectivity?
Answered: Server TimeOut function for connectivity?
I'm in the process of building a sencha app that will have a fall back offline feature. Looking at a few other discussions and articles it appears there are a few different ways of detecting internet connectivity and when it's it lost.
The basic suggestion was using:
Though reports say this is usually based off if a device is in airplane mode or offline mode rather than if there is an actual drop in connectivity.Code:navigator.onLine
I'm thinking the best route might be to set some sort of ping function to the server in which I'm grabbing JSON data from, then setting an aggressive timeout for it. If the time out is met then I can call a function to change the header and alter the content displayed. At least that's what I'm thinking and wondering if anyone has already built something along these lines?
Am I missing any other built in functions that might be able to easily do this? Any other recommendations?
Thanks in advance!
-
Best Answer Posted by mitchellsimoens
navigator.onLine should take into account if the device looses connection in any way, this is up to the platform and browser though.
You can do a ping Ajax call. Ajax calls do have a timeout that will fire the failure callback.
-
2 Apr 2012 7:58 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,656
- Vote Rating
- 435
- Answers
- 3108
navigator.onLine should take into account if the device looses connection in any way, this is up to the platform and browser though.
You can do a ping Ajax call. Ajax calls do have a timeout that will fire the failure callback.Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
2 Apr 2012 8:06 AM #3
Thanks for the heads up. I tested the navigator.online feature with a basic two tab page. The first page said welcome and the second would display online/offline based on status. I switched to airplane mode and my second page still said I was online.
Code:cls:'status', title: '?', html: navigator.onLine?'online':'offline'
-
27 Jun 2012 10:44 AM #4
Revisiting this particular piece of this project, I am still getting the same issue. However when it comes to testing this, I now think I will have to deploy as an iOS app and sync over. When I save the site to my home screen and leave the app to turn on airplane mode. The app will not launch since it's trying to access the website anyways.
Testing this in browser, I am able to get the result I need.


Reply With Quote