skip to main content
OpenEdge Mobile 11.5.1 Updates : Session management updates : JSDOSession events : 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 Mobile 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 Mobile 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 the event handler function:

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 Mobile 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.
This condition will fire the offline event on a JSDOSession or Session object even if the object has not yet invoked its login( ) method.
*progress.data.Session.SERVER_OFFLINE — The Web server is not available. For a Rollbase Mobile service, this is the Web server for the public or private cloud. For an OpenEdge Mobile 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 Mobile service is not deployed.
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 in OpenEdge Development: Mobile Applications. 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 cloud or the OpenEdge AppServer is unavailable, this will not cause the offline event to fire, nor will the fact that a particular Mobile 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.Session;
mySession.subscribe('offline', onSessionOffline );

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

. . .

function onSessionOffline( session , offlineReason , request ) {

  switch( offlineReason ) {
case progress.data.Session.APPSERVER_OFFLINE:
document.write(progress.data.Session.APPSERVER_OFFLINE);
. . .
break;
case progress.data.Session.DEVICE_OFFLINE:
document.write(progress.data.Session.DEVICE_OFFLINE);
. . .
break;
case progress.data.Session.SERVER_OFFLINE:
document.write(progress.data.Session.SERVER_OFFLINE);
. . .
break;
case progress.data.Session.WEB_APPLICATION_OFFLINE:
document.write(progress.data.Session.WEB_APPLICATION_OFFLINE);
. . .
break;
default:
document.write("ERROR: An offline event returned an unknown reason: " + offLineReason);
};

};

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)