Online State

1 view
Skip to first unread message

tazz_ben

unread,
Jul 18, 2009, 10:31:29 AM7/18/09
to webstorageportabilitylayer
Sorry if this is a dumb question, I'm working on my first Gears/HTML5
app right now.

Am I correct in believing there is no lightweight method that gives
you the online/offline state in Gears and HTML5 (and by extension no
wrapper in WSPL)? I've searched for that but haven't found anything.

From what I've read, people seem to think the way to do this do an XHR
and wait for a failure. Maybe it is that I'm missing something
fundamental about how XHR works when offline, but this seems very
inefficient (the OS would have a lot info like local IP to indicate an
offline state that wouldn't take the time of a request). Am I missing
something here?

Rob

unread,
Jul 26, 2009, 5:26:58 PM7/26/09
to webstorageportabilitylayer
Hi,

It has become apparent to me that my response to this last week
bounced. Apparently I am not familiar with some limitations of Gmail
for Mobile on iPhone. Shame on me. :-(

On Jul 18, 10:31 am, tazz_ben <b...@wbpsystems.com> wrote:
> Sorry if this is a dumb question, I'm working on my first Gears/HTML5
> app right now.

HTML5/Gears etc. is very confusing. There are no dumb questions.

>
> Am I correct in believing there is no lightweight method that gives
> you the online/offline state in Gears and HTML5 (and by extension no
> wrapper in WSPL)?  I've searched for that but haven't found anything.

So up to Iphone OS 2.2.1, the only way to tell is to try to connect to
the server like you say below. At some point (I have not tried this
on OS3 yet because we still support 2.2.1) the online and offline
interfaces listed here: https://developer.mozilla.org/En/Online_and_offline_events
will come to (mobile)webkit and android.

>
> From what I've read, people seem to think the way to do this do an XHR
> and wait for a failure.  Maybe it is that I'm missing something
> fundamental about how XHR works when offline, but this seems very
> inefficient (the OS would have a lot info like local IP to indicate an
> offline state that wouldn't take the time of a request).  Am I missing
> something here?

You are not missing anything other than a very annoying oversight in
earlier webkit versions.

Rob.

tazz_ben

unread,
Jul 27, 2009, 8:07:01 PM7/27/09
to webstorageportabilitylayer
Just for reference, the navigator.online works in iPhone 3 + Android
1.5. I actually decided to up our system requirements to this version
for our mobile app for this reason. My feeling was that if I was
going to depend on XHR requests to determine online state I would have
to do one of two things to keep from having a bunch of XHR requests
using memory all the time, neither of which I liked.
Reply all
Reply to author
Forward
0 new messages