If you're looking for a way to use Gears to get the network connection
status directly, there isn't a way to do that at the moment -- at
least, not that I know of. I think it's pretty much left up to the
developers to figure out how they want to detect network connection.
If the browser has a way to detect network status from the OS (or
whatever), and there's a way to figure out from the browser whether
the device is online or offline, that would probably work, but I'm not
sure if there are any browsers that have that capability.

On Sep 12, 9:33 am, Steve Patrick <[email protected]>
wrote:
> Hi everybody
> my question is: is it possible to develope a function isConnected()
> that returns a boolean (true if the user have network connection...)??
> I know there is a function that updates network state every "n"
> seconds but I don´t want that, I want a function that returns a
> boolean with the actual network status.
> Looks easy, I have tryed this:
>
> var connected=false;//global variable initializated
> function isConnected()
> {
>         var resource_to_test = "resource.txt";
>         try{
>                 var req=getXHR();
>                 req.open('GET',resource_to_test);
>                 req.onreadystatechange = function()
>                                 {
>                                   if (req.readyState == 4)
>                                    {
>                                          if (req.status == 200)
>                                                  {
>                                                         
> connected=true;//update value
>                                                 }
>                                  else
>                                   {
>                                       connected=false;//update value
>                                   }
>                                  }
>                 };
>         req.send(null);
>         return connected;// return the boolean, always return false
> (initializated vaule)...
>
> }
>
> but the variable "connected" is updated by onreadystatechange event
> AFTER the function isConnected() returns the value.
> Is there a wat to do that?
> Does Gears provide another way to develope a boolean function that
> updates network state?
> Thanks!

Reply via email to