RE: online/offline Events

2012-11-14 Thread Leutwyler, Markus
In lib/common/plugin/network.js on Line 49

if (info === none) {

Am I wrong or will this statement never be true since the plugins return the 
connection as Connection.NONE?

What I'm seeing is that the event online is fired as Connection.NONE is passed 
in

Markus

-Original Message-
From: agri...@google.com [mailto:agri...@google.com] On Behalf Of Andrew Grieve
Sent: Dienstag, 13. November 2012 18:41
To: dev
Subject: Re: online/offline Events

The spec says to fire an online event whenever the connection type changes, and 
to fire an offline event only when you lose your connection. It's not the most 
obvious, but probably your multiple event firing is working as intended.

To answer your second question, I think what you're looking for is 
navigator.onLine. It's derived from the connection type here:
https://git-wip-us.apache.org/repos/asf?p=incubator-cordova-js.git;a=blob;f=lib/common/plugin/network.js;h=63736a954762b17d4383239a8afa46a81ce88a3a;hb=HEAD#l31



On Tue, Nov 13, 2012 at 9:00 AM, Leutwyler, Markus
markus.leutwy...@hp.comwrote:

 I'm able to successfully setup  a webOS specific service call in the
 initialize() function in platform.js ... this will keep track of any 
 connection changes but fires multiple events in case Wifi is turned on 
 (and not connected to an AP) and then again if connected with an AP. I 
 convert those events to offline/online document events (via 
 cordova.fireDocumentEvent). Is there a way to add a global 
 online/offline status/variable somewhere and only fire document events 
 if there's an actual change from offline to online?

 Markus

 -Original Message-
 From: agri...@google.com [mailto:agri...@google.com] On Behalf Of 
 Andrew Grieve
 Sent: Mittwoch, 7. November 2012 16:27
 To: dev
 Subject: Re: online/offline Events

 Here's the Android impl:

 https://git-wip-us.apache.org/repos/asf?p=incubator-cordova-android.gi
 t;a=blob;f=framework/src/org/apache/cordova/NetworkManager.java;h=5d87
 91809227877d604c98cf029c26242d9642b8;hb=HEAD

 The JS performs a Connection.getConnectionInfo(), and then the native 
 plugin returns the connection status but sets keepCallback to true. 
 Then, whenever the connection type changes, it sends another plugin 
 result and always sets keepCallback to true.


 On Wed, Nov 7, 2012 at 9:57 AM, Leutwyler, Markus
 markus.leutwy...@hp.comwrote:

  I saw that ... but how is that handled by the platform specific plugins?
 
  Markus
 
  -Original Message-
  From: Simon MacDonald [mailto:simon.macdon...@gmail.com]
  Sent: Mittwoch, 7. November 2012 15:56
  To: dev@cordova.apache.org
  Subject: Re: online/offline Events
 
  lolz I didn't read what list this was on. The src for network.js is at:
 
 
  https://git-wip-us.apache.org/repos/asf?p=incubator-cordova-js.git;a
  =b
  lob;f=lib/common/plugin/network.js;h=adaba5ae8b6ec825986712d8b99e660
  10
  5e56ae9;hb=HEAD
 
  The way we have it setup is the native side sends the JS side an 
  update whenever the network connection changes. If the type == 'none'
  then we fire an offline event. Otherwise you fire the online event.
 
  Simon Mac Donald
  http://hi.im/simonmacdonald
 
 
  On Wed, Nov 7, 2012 at 9:47 AM, Leutwyler, Markus
  markus.leutwy...@hp.comwrote:
 
   I was actually looking for a code example (in cordova-js) of a 
   platform that sends out those events (because I'm investigating 
   how to add support for those to webOS)
  
   Markus
  
   -Original Message-
   From: Simon MacDonald [mailto:simon.macdon...@gmail.com]
   Sent: Mittwoch, 7. November 2012 15:39
   To: dev@cordova.apache.org
   Subject: Re: online/offline Events
  
   http://docs.phonegap.com/en/2.2.0/cordova_events_events.md.html#on
   li
   ne
   http://docs.phonegap.com/en/2.2.0/cordova_events_events.md.html#of
   fl
   in
   e
  
   Simon Mac Donald
   http://hi.im/simonmacdonald
  
  
   On Wed, Nov 7, 2012 at 9:36 AM, Leutwyler, Markus
   markus.leutwy...@hp.comwrote:
  
Is there a platform that sends out online/offline event to the 
document when the connection status changes? I didn't find any 
examples
   
Thanks
   
Markus
   
  
 



Re: online/offline Events

2012-11-14 Thread Simon MacDonald
Well that's not the way it works on Android. From the Java side we return
constants like none, 3g, wifi, etc. so the comparison will work
properly. As well the constant Connection.NONE evaluates to none so even
if you were using the constant for comparison purposes it should still work.

Simon Mac Donald
http://hi.im/simonmacdonald


On Wed, Nov 14, 2012 at 6:33 AM, Leutwyler, Markus
markus.leutwy...@hp.comwrote:

 In lib/common/plugin/network.js on Line 49

 if (info === none) {

 Am I wrong or will this statement never be true since the plugins return
 the connection as Connection.NONE?

 What I'm seeing is that the event online is fired as Connection.NONE is
 passed in

 Markus

 -Original Message-
 From: agri...@google.com [mailto:agri...@google.com] On Behalf Of Andrew
 Grieve
 Sent: Dienstag, 13. November 2012 18:41
 To: dev
 Subject: Re: online/offline Events

 The spec says to fire an online event whenever the connection type
 changes, and to fire an offline event only when you lose your connection.
 It's not the most obvious, but probably your multiple event firing is
 working as intended.

 To answer your second question, I think what you're looking for is
 navigator.onLine. It's derived from the connection type here:

 https://git-wip-us.apache.org/repos/asf?p=incubator-cordova-js.git;a=blob;f=lib/common/plugin/network.js;h=63736a954762b17d4383239a8afa46a81ce88a3a;hb=HEAD#l31



 On Tue, Nov 13, 2012 at 9:00 AM, Leutwyler, Markus
 markus.leutwy...@hp.comwrote:

  I'm able to successfully setup  a webOS specific service call in the
  initialize() function in platform.js ... this will keep track of any
  connection changes but fires multiple events in case Wifi is turned on
  (and not connected to an AP) and then again if connected with an AP. I
  convert those events to offline/online document events (via
  cordova.fireDocumentEvent). Is there a way to add a global
  online/offline status/variable somewhere and only fire document events
  if there's an actual change from offline to online?
 
  Markus
 
  -Original Message-
  From: agri...@google.com [mailto:agri...@google.com] On Behalf Of
  Andrew Grieve
  Sent: Mittwoch, 7. November 2012 16:27
  To: dev
  Subject: Re: online/offline Events
 
  Here's the Android impl:
 
  https://git-wip-us.apache.org/repos/asf?p=incubator-cordova-android.gi
  t;a=blob;f=framework/src/org/apache/cordova/NetworkManager.java;h=5d87
  91809227877d604c98cf029c26242d9642b8;hb=HEAD
 
  The JS performs a Connection.getConnectionInfo(), and then the native
  plugin returns the connection status but sets keepCallback to true.
  Then, whenever the connection type changes, it sends another plugin
  result and always sets keepCallback to true.
 
 
  On Wed, Nov 7, 2012 at 9:57 AM, Leutwyler, Markus
  markus.leutwy...@hp.comwrote:
 
   I saw that ... but how is that handled by the platform specific
 plugins?
  
   Markus
  
   -Original Message-
   From: Simon MacDonald [mailto:simon.macdon...@gmail.com]
   Sent: Mittwoch, 7. November 2012 15:56
   To: dev@cordova.apache.org
   Subject: Re: online/offline Events
  
   lolz I didn't read what list this was on. The src for network.js is at:
  
  
   https://git-wip-us.apache.org/repos/asf?p=incubator-cordova-js.git;a
   =b
   lob;f=lib/common/plugin/network.js;h=adaba5ae8b6ec825986712d8b99e660
   10
   5e56ae9;hb=HEAD
  
   The way we have it setup is the native side sends the JS side an
   update whenever the network connection changes. If the type == 'none'
   then we fire an offline event. Otherwise you fire the online event.
  
   Simon Mac Donald
   http://hi.im/simonmacdonald
  
  
   On Wed, Nov 7, 2012 at 9:47 AM, Leutwyler, Markus
   markus.leutwy...@hp.comwrote:
  
I was actually looking for a code example (in cordova-js) of a
platform that sends out those events (because I'm investigating
how to add support for those to webOS)
   
Markus
   
-Original Message-
From: Simon MacDonald [mailto:simon.macdon...@gmail.com]
Sent: Mittwoch, 7. November 2012 15:39
To: dev@cordova.apache.org
Subject: Re: online/offline Events
   
http://docs.phonegap.com/en/2.2.0/cordova_events_events.md.html#on
li
ne
http://docs.phonegap.com/en/2.2.0/cordova_events_events.md.html#of
fl
in
e
   
Simon Mac Donald
http://hi.im/simonmacdonald
   
   
On Wed, Nov 7, 2012 at 9:36 AM, Leutwyler, Markus
markus.leutwy...@hp.comwrote:
   
 Is there a platform that sends out online/offline event to the
 document when the connection status changes? I didn't find any
 examples

 Thanks

 Markus

   
  
 



Re: online/offline Events

2012-11-13 Thread Andrew Grieve
The spec says to fire an online event whenever the connection type changes,
and to fire an offline event only when you lose your connection. It's not
the most obvious, but probably your multiple event firing is working as
intended.

To answer your second question, I think what you're looking for is
navigator.onLine. It's derived from the connection type here:
https://git-wip-us.apache.org/repos/asf?p=incubator-cordova-js.git;a=blob;f=lib/common/plugin/network.js;h=63736a954762b17d4383239a8afa46a81ce88a3a;hb=HEAD#l31



On Tue, Nov 13, 2012 at 9:00 AM, Leutwyler, Markus
markus.leutwy...@hp.comwrote:

 I'm able to successfully setup  a webOS specific service call in the
 initialize() function in platform.js ... this will keep track of any
 connection changes but fires multiple events in case Wifi is turned on (and
 not connected to an AP) and then again if connected with an AP. I convert
 those events to offline/online document events (via
 cordova.fireDocumentEvent). Is there a way to add a global online/offline
 status/variable somewhere and only fire document events if there's an
 actual change from offline to online?

 Markus

 -Original Message-
 From: agri...@google.com [mailto:agri...@google.com] On Behalf Of Andrew
 Grieve
 Sent: Mittwoch, 7. November 2012 16:27
 To: dev
 Subject: Re: online/offline Events

 Here's the Android impl:

 https://git-wip-us.apache.org/repos/asf?p=incubator-cordova-android.git;a=blob;f=framework/src/org/apache/cordova/NetworkManager.java;h=5d8791809227877d604c98cf029c26242d9642b8;hb=HEAD

 The JS performs a Connection.getConnectionInfo(), and then the native
 plugin returns the connection status but sets keepCallback to true. Then,
 whenever the connection type changes, it sends another plugin result and
 always sets keepCallback to true.


 On Wed, Nov 7, 2012 at 9:57 AM, Leutwyler, Markus
 markus.leutwy...@hp.comwrote:

  I saw that ... but how is that handled by the platform specific plugins?
 
  Markus
 
  -Original Message-
  From: Simon MacDonald [mailto:simon.macdon...@gmail.com]
  Sent: Mittwoch, 7. November 2012 15:56
  To: dev@cordova.apache.org
  Subject: Re: online/offline Events
 
  lolz I didn't read what list this was on. The src for network.js is at:
 
 
  https://git-wip-us.apache.org/repos/asf?p=incubator-cordova-js.git;a=b
  lob;f=lib/common/plugin/network.js;h=adaba5ae8b6ec825986712d8b99e66010
  5e56ae9;hb=HEAD
 
  The way we have it setup is the native side sends the JS side an
  update whenever the network connection changes. If the type == 'none'
  then we fire an offline event. Otherwise you fire the online event.
 
  Simon Mac Donald
  http://hi.im/simonmacdonald
 
 
  On Wed, Nov 7, 2012 at 9:47 AM, Leutwyler, Markus
  markus.leutwy...@hp.comwrote:
 
   I was actually looking for a code example (in cordova-js) of a
   platform that sends out those events (because I'm investigating how
   to add support for those to webOS)
  
   Markus
  
   -Original Message-
   From: Simon MacDonald [mailto:simon.macdon...@gmail.com]
   Sent: Mittwoch, 7. November 2012 15:39
   To: dev@cordova.apache.org
   Subject: Re: online/offline Events
  
   http://docs.phonegap.com/en/2.2.0/cordova_events_events.md.html#onli
   ne
   http://docs.phonegap.com/en/2.2.0/cordova_events_events.md.html#offl
   in
   e
  
   Simon Mac Donald
   http://hi.im/simonmacdonald
  
  
   On Wed, Nov 7, 2012 at 9:36 AM, Leutwyler, Markus
   markus.leutwy...@hp.comwrote:
  
Is there a platform that sends out online/offline event to the
document when the connection status changes? I didn't find any
examples
   
Thanks
   
Markus
   
  
 



Re: online/offline Events

2012-11-07 Thread Simon MacDonald
lolz I didn't read what list this was on. The src for network.js is at:

https://git-wip-us.apache.org/repos/asf?p=incubator-cordova-js.git;a=blob;f=lib/common/plugin/network.js;h=adaba5ae8b6ec825986712d8b99e660105e56ae9;hb=HEAD

The way we have it setup is the native side sends the JS side an update
whenever the network connection changes. If the type == 'none' then we fire
an offline event. Otherwise you fire the online event.

Simon Mac Donald
http://hi.im/simonmacdonald


On Wed, Nov 7, 2012 at 9:47 AM, Leutwyler, Markus
markus.leutwy...@hp.comwrote:

 I was actually looking for a code example (in cordova-js) of a platform
 that sends out those events (because I'm investigating how to add support
 for those to webOS)

 Markus

 -Original Message-
 From: Simon MacDonald [mailto:simon.macdon...@gmail.com]
 Sent: Mittwoch, 7. November 2012 15:39
 To: dev@cordova.apache.org
 Subject: Re: online/offline Events

 http://docs.phonegap.com/en/2.2.0/cordova_events_events.md.html#online
 http://docs.phonegap.com/en/2.2.0/cordova_events_events.md.html#offline

 Simon Mac Donald
 http://hi.im/simonmacdonald


 On Wed, Nov 7, 2012 at 9:36 AM, Leutwyler, Markus
 markus.leutwy...@hp.comwrote:

  Is there a platform that sends out online/offline event to the
  document when the connection status changes? I didn't find any
  examples
 
  Thanks
 
  Markus
 



RE: online/offline Events

2012-11-07 Thread Leutwyler, Markus
I saw that ... but how is that handled by the platform specific plugins?

Markus

-Original Message-
From: Simon MacDonald [mailto:simon.macdon...@gmail.com] 
Sent: Mittwoch, 7. November 2012 15:56
To: dev@cordova.apache.org
Subject: Re: online/offline Events

lolz I didn't read what list this was on. The src for network.js is at:

https://git-wip-us.apache.org/repos/asf?p=incubator-cordova-js.git;a=blob;f=lib/common/plugin/network.js;h=adaba5ae8b6ec825986712d8b99e660105e56ae9;hb=HEAD

The way we have it setup is the native side sends the JS side an update 
whenever the network connection changes. If the type == 'none' then we fire an 
offline event. Otherwise you fire the online event.

Simon Mac Donald
http://hi.im/simonmacdonald


On Wed, Nov 7, 2012 at 9:47 AM, Leutwyler, Markus
markus.leutwy...@hp.comwrote:

 I was actually looking for a code example (in cordova-js) of a 
 platform that sends out those events (because I'm investigating how to 
 add support for those to webOS)

 Markus

 -Original Message-
 From: Simon MacDonald [mailto:simon.macdon...@gmail.com]
 Sent: Mittwoch, 7. November 2012 15:39
 To: dev@cordova.apache.org
 Subject: Re: online/offline Events

 http://docs.phonegap.com/en/2.2.0/cordova_events_events.md.html#online
 http://docs.phonegap.com/en/2.2.0/cordova_events_events.md.html#offlin
 e

 Simon Mac Donald
 http://hi.im/simonmacdonald


 On Wed, Nov 7, 2012 at 9:36 AM, Leutwyler, Markus
 markus.leutwy...@hp.comwrote:

  Is there a platform that sends out online/offline event to the 
  document when the connection status changes? I didn't find any 
  examples
 
  Thanks
 
  Markus
 



Re: online/offline Events

2012-11-07 Thread Andrew Grieve
Here's the Android impl:
https://git-wip-us.apache.org/repos/asf?p=incubator-cordova-android.git;a=blob;f=framework/src/org/apache/cordova/NetworkManager.java;h=5d8791809227877d604c98cf029c26242d9642b8;hb=HEAD

The JS performs a Connection.getConnectionInfo(), and then the native
plugin returns the connection status but sets keepCallback to true. Then,
whenever the connection type changes, it sends another plugin result and
always sets keepCallback to true.


On Wed, Nov 7, 2012 at 9:57 AM, Leutwyler, Markus
markus.leutwy...@hp.comwrote:

 I saw that ... but how is that handled by the platform specific plugins?

 Markus

 -Original Message-
 From: Simon MacDonald [mailto:simon.macdon...@gmail.com]
 Sent: Mittwoch, 7. November 2012 15:56
 To: dev@cordova.apache.org
 Subject: Re: online/offline Events

 lolz I didn't read what list this was on. The src for network.js is at:


 https://git-wip-us.apache.org/repos/asf?p=incubator-cordova-js.git;a=blob;f=lib/common/plugin/network.js;h=adaba5ae8b6ec825986712d8b99e660105e56ae9;hb=HEAD

 The way we have it setup is the native side sends the JS side an update
 whenever the network connection changes. If the type == 'none' then we fire
 an offline event. Otherwise you fire the online event.

 Simon Mac Donald
 http://hi.im/simonmacdonald


 On Wed, Nov 7, 2012 at 9:47 AM, Leutwyler, Markus
 markus.leutwy...@hp.comwrote:

  I was actually looking for a code example (in cordova-js) of a
  platform that sends out those events (because I'm investigating how to
  add support for those to webOS)
 
  Markus
 
  -Original Message-
  From: Simon MacDonald [mailto:simon.macdon...@gmail.com]
  Sent: Mittwoch, 7. November 2012 15:39
  To: dev@cordova.apache.org
  Subject: Re: online/offline Events
 
  http://docs.phonegap.com/en/2.2.0/cordova_events_events.md.html#online
  http://docs.phonegap.com/en/2.2.0/cordova_events_events.md.html#offlin
  e
 
  Simon Mac Donald
  http://hi.im/simonmacdonald
 
 
  On Wed, Nov 7, 2012 at 9:36 AM, Leutwyler, Markus
  markus.leutwy...@hp.comwrote:
 
   Is there a platform that sends out online/offline event to the
   document when the connection status changes? I didn't find any
   examples
  
   Thanks
  
   Markus