Detect offline sessions
An "offline" session can mean one of many things. The actual meaning depends on your interpretation. It can be:
- an emulation session which is connected to the host but not logged onto the host application
- an emulation session which is disconnected
- a browser session which receives a page with title "Offline"
For 1), you can simply look for text on the screen. This can be done using the OnReceive handler. For 2) you can implement a handler for the OnSessionDisconnect and OnSessionDisconnected events.
This script will detect the "Offline" page in a browser session and will redirect the CETerm browser to the login screen. This is about the same as the user pressing a key mapped to "URL Home".
To download the script, right mouse click and "Save Target As..." SAPOffline.js
/*OnDocumentDone*/
function OnDocumentDone( session )
{
// Get document object
var d=CETerm.Session(session).Browser.Document;
// Compare title
if(d.title.match("Offline"))
{
// Return to home URL
var script = "CETerm.PostIDA('IDA_URL_HOME'," + session + ");";
CETerm.SetTimeout( script, 500 );
}
}