JSDO properties, methods, and events reference : offline event
  

offline event

Fires when the current JSDOSession or Session object detects that the device on which it is running has gone offline, or that the web application to which it has been connected is no longer available.
This event always fires when the device on which the JSDOSession or Session object is created goes offline (that is, the device is disconnected from the network). For this event to fire when the web application to which it has been connected is no longer available, the JSDOSession or Session object must have previously:
1. Been connected to the web application using the object's login( ) method
2. Not been disconnected from the web application using the object's logout( ) method
Applies to: progress.data.JSDOSession class, progress.data.Session class
The following parameters appear in the signature of any event handler (callback) function (or functions) that you subscribe to this event:

Syntax

function ( session , off-line-reason , request )
session
A reference to the JSDOSession or Session object that has detected the offline condition.
off-line-reason
A string constant indicating the reason that the offline event has been fired. Possible constants include:
*progress.data.Session.APPSERVER_OFFLINE — (OpenEdge Data Object Services only) The other components necessary to run the service are available, but the associated OpenEdge application server is offline.
*progress.data.Session.DEVICE_OFFLINE — The device itself is offline. For example, it might be in airplane mode, or it might be unable to pick up a Wi-Fi or cell signal.
*progress.data.Session.SERVER_OFFLINE — The web server is not available. For a Rollbase Data Object Service, this is the web server for the public or private cloud. For an OpenEdge Data Object Service, this is the Tomcat Java servlet container.
*progress.data.Session.WEB_APPLICATION_OFFLINE — The server is running, but the Java web application that implements the Data Object Service is not deployed.
Note: The progress.data.Session.DEVICE_OFFLINE condition will fire the offline event on a JSDOSession or Session object even if the object has not yet invoked its login( ) method.
You can use the string values of these constants directly to display or log messages, or test the values only and respond to the result in some other way.
request
If the offline 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 offline event is the result of the device going offline 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.
Note: If the underlying database accessed by the Rollbase server or OpenEdge application server is unavailable, this will not cause the offline event to fire, nor will the fact that a particular Data Object Service contained by the hosting web application was not loaded when the application started.

Example

The following code fragment subscribes the function, onSessionOffline, to handle the offline event fired on the session, mySession:
/* subscribe to the offline event */
var mySession = new progress.data.JSDOSession(
{ serviceURI: "http://localhost/CustService",
authenticationModel: progress.data.Session.AUTH_TYPE_FORM
};
mySession.subscribe('offline', onSessionOffline );

/* some code that might cause mySession to detect that the
application is offline */

. . .

function onSessionOffline( session , offlineReason , request ) {

document.write(offLineReason);
  switch( offlineReason ) {
case progress.data.Session.APPSERVER_OFFLINE:
document.write("Check with the server system administrator");
. . .
break;
case progress.data.Session.DEVICE_OFFLINE:
document.write("Ensure that your device is online");
. . .
break;
case progress.data.Session.SERVER_OFFLINE:
document.write("Check with the server system administrator");
. . .
break;
case progress.data.Session.WEB_APPLICATION_OFFLINE:
document.write("Check with the server system administrator");
. . .
break;
default:
document.write("Check with the server system administrator");
};

};

See also:

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