Products
Purchase
Support
Download
About
Contact
Connection Management

Project: Implement a script which monitors a session’s activity. When there has been no change in the session for a specified period of time, log out and disconnect the session to free resources for other users.

Algorithm: Since multiple sessions can be connected, the script needs some means of identifying the appropriate session window, and whether it is connected. Then the script waits for an idle period of no data received for the specified period. This value can be fixed, or read from an INI file.

Relevant Commands and Functions:

CONNECT( ) — Returns connection state of session
WINDOWHND( ) — Returns window handle based on window title
CONNECT — Connect a session and load it if not open
WHEN QUIET — Activates after specified time elapses without character transmission
WAIT RESUME — Pauses until Resume command is executed
SEND — Sends characters to a host system
WAIT STRING — Waits for a specified prompt from host
DISCONNECT — Disconnects a session
WINDOW CLOSE — Closes a child window
GETPROFILEDATA( ) — Returns string from Registry or INI file.
SHOW — Display each script command as it is executed.

See Also:

LOAD — Opens a session file
WINDOW OPEN — Opens a child window
WHEN DISCONNECT — Triggers when session is disconnected
Table Commands — As illustrated in Data Tables example

A Brief Example

SHOW
WAIT DELAY "2"
%WindowHandle = ACTIVE()
$ini_location = DIRECTORY(DYNASYS)
$timeout = GETPROFILEDATA("GENERAL", "Session Timeout", \
$ini_location| "MY_INI.INI")
IF $timeout = ""
$timeout = "00:10:00"
WHEN QUIET $timeout
BEGIN
IF CONNECT()
BEGIN
SEND NOCR "^C" WINDOW %WindowHandle
SEND "exit" WINDOW %WindowHandle
WAIT DELAY "00:00:05"
END

SAVE
WINDOW CLOSE %WindowHandle
RESUME
END

WAIT RESUME
CANCEL

In this example, we once again take advantage of associating a Startup Script with a session in Session:Properties, General tab. When the session is opened, the script waits a few seconds for the session to open and connect to the host. Then it reads the window handle value of the active window to be stored in an integer variable and used for the rest of the script. The timeout period is read from a custom INI file in the main DCSeries directory that looks like:

[GENERAL]
Session Timeout=00:15:00
If this entry or INI file is not found, a default value of 10 minutes is used. At this point, the script waits until the period elapses with no character transmission. At that point, the script executes the commands in the WHEN QUIET block, checking if the session is connected, sending commands to the host to log out, closing the session within DynaComm, and terminating the script.

Further Development: