What I did was simulate a "ping" of sorts to see if we're still online
or not.

Basically, use ajax to request a file that is only available online
(and is not cached in Gears through the manifest file) every 2
seconds. With jQuery you can specify a request timeout which you could
set to 1 second. Keep count of the failed requests. If the
"failedRequests" counter reaches 3 or whatever number you want, you
could go into offline mode and change a visual indicator.

Personally, I use the failedRequests counter to account for temporary
hiccups in the connection. Only if there have been 3 failed "pings"
over the course of ~6 seconds, I want to go offline.

Don't forget that when you encounter a successful ping attempt, you
need to reset the failedRequests counter to zero.

On Aug 19, 11:21 am, yosrbnrt <[email protected]> wrote:
> Hello,
>
> On Gmail and other sites that use Google gears like:www.rememberthemilk.com
> there is a offline / online indicator on the top of the page which
> also gives info on the last time a synch was done.
>
> Is there a ready plug-in code or API to build these indicators? we
> started using gears on our site and I need some help in building this
> feature.
>
> Thanks for your help
> Yossi.

Reply via email to