Fires when the current JSDOSession or Session object detects that the device on which it is running has gone online after it was previously offline, or that the Mobile 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 Session 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 Mobile Web application to which it has been connected is now available after having been unavailable, the 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
3. Detected an offline event as a result of sending a Mobile service request to the Web application or executing the ping( ) method
The following parameters appear in the signature of the event handler function:
Syntax
function ( session , request )
session
A reference to the JSDOSession or Session 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 in OpenEdge Development: Mobile Applications. 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 or Session object even if the object has not yet invoked its login( ) method or has already invoked its logout( ) method .
A JSDOSession or Session object that previously fired its offline event because of a failed attempt to contact a Mobile service has now been used successfully to contact that same Mobile 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.Session; 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.");