Fires when the current JSDOSession object detects that the device on which it is running has gone online after it was previously offline, or that the web application to which it is connected is now available after it was previously unavailable.

This event always fires when the device on which the JSDOSession object is created goes online after having been offline (that is, the device is reconnected to the network). For this event to fire when the web application to which it has been connected is now available after having been unavailable, the JSDOSession object must have previously:

  1. Been instantiated using getSession( )
  2. Not been disconnected from the web application using the object's logout( ) method
  3. Detected an offline event as a result of sending a Data Object Service request to the web application or executing the ping( ) method

Applies to: progress.data.JSDOSession class

Syntax

The following parameters appear in the signature of any event handler (callback) function (or functions) that you subscribe to this event:

function ( jsdosession , request )
session
A reference to the JSDOSession object that has detected the online condition.
request
If the online condition was detected as a result of a request sent on behalf of a JSDO, this is a reference to the request object used to make the request. For more information, see the description of the request object. If the online event is the result of the device itself coming back online or because of a call to the ping( ) method (either directly or because the pingInterval property is set greater than 0), this parameter is null.

This event can fire because:

  • The device on which the app is running was previously offline (in airplane mode or could not connect to a Wi-Fi network), but is now online again.
    Note: This condition will fire the online event on a JSDOSession object.
  • A JSDOSession object that previously fired its offline event because of a failed attempt to contact a Data Object Service has now been used successfully to contact that same Data Object Service.

Example

The following code fragment subscribes the function, onSessionOnline, to handle the online event fired on the session, mySession:

/* subscribe to the online event */
                  var mySession = new progress.data.JSDOSession(
                  { serviceURI: "http://localhost/CustService",
                  authenticationModel: progress.data.Session.AUTH_TYPE_FORM
                  };
                  mySession.subscribe('online', onSessionOnline );
                  
                  /* some code that might cause mySession to detect that the 
                  application is online */
                  
                  . . .
                  
                  function onSessionOnline( session , request ) {
                  
                  document.write("Your best mobile app is back to work! " 
                  + "You might be prompted to login again.");
                  
                  };

See also:

connected property, login( ) method (JSDOSession class), logout( ) method (JSDOSession class), offline event, ping( ) method (JSDOSession class), subscribe( ) method (JSDOSession class), unsubscribe( ) method (JSDOSession class)