I have a few methods that are constantly run; they wrap commands like
Alert and Confirm, are called in the On Load event of almost every form
(to set up menubars, etc.), or are called when the user opens a module or
performs a search. Altogether I think there are eight or nine methods
that it would be almost impossible not to run in a session of any
meaningful duration.
What I did is add this line to each of those nine "common, frequent, and
essential" methods:
CheckSessionTime ("Renew")
This method looks like this:
<>InactivityLogoffTime:=Current time+(<>UserSessionResetInterval*60)
//<>UserSessionResetInterval is in minutes, convert to seconds in order to
add to current time
...where it basically computes a time of day when the session would be
regarded as 'stale'. <>UserSessionResetInterval is typically set at one
hour, but it can be changed from user to user to allow some to have longer
inactivity times (like the boss).
When 4D starts, I open a process from the startup process that does the
following in a loop that lasts until the user logs off OR is forced off:
1. Check <>InactivityLogoffTime, if it is in the past, then I put up a
message box telling the user to do something in the next 10 minutes or
he'll be logged out
2. Wait 10 minutes, then call QUIT 4D if nothing happens or go back to
sleep if something happens
3. Delay process for 10 minutes
4. Repeat
This code looks like this:
Repeat
DELAY PROCESS(Current process;<>UserSessionResetInterval*60*(60/2))
//convert mins to ticks; delay for one half the session reset interval
If (<>InactivityLogoffTime<Current time)
ON EVENT CALL("KeepSessionAlive") //if user hits any key when
Message window is open, the event calls KeepSessionAlive, which resets the
counter.
Open window(200;225;200+320;225+100) //can't use
MyOpenProgressWindow because this resets the timer
For ($Time;1;$NumPromptSeconds) //give user prompt and time to
strike any key. to keep session alive
ERASE WINDOW
GOTO XY(0;1)
$Msg:="This session has been inactive for
"+String(<>UserSessionResetInterval)+" minutes."+<>CR2
MESSAGE($Msg+"Hit any key to prevent shutdown in "+Time
string($NumPromptSeconds-$Time))
If (<>InactivityLogoffTime>Current time) //indicates user hit a
key and KeepSessionAlive called CheckSessionTime("Renew") to reset
<>InactivityLogoffTime
$Time:=$NumPromptSeconds+1 //end loop
Else
DELAY PROCESS(Current process;60*2) //delay 2 seconds
End if
End for
CLOSE WINDOW
ON EVENT CALL("")
If (<>InactivityLogoffTime<Current time)
C_LONGINT($ProcessState;$ProcTime)
C_TEXT($ProcessName)
PROCESS PROPERTIES(Current
process;$ProcessName;$ProcessState;$ProcTime) //new 10/22/2014
...maybe save user preferences here...
...below: I log the event so I know how often users are "really"
being forced off
CreateTransactionMessage ("Log";"User logged off after inactivity
timeout ("+String(<>UserSessionResetInterval)+" minutes)")
DELAY PROCESS(Current process;60*2) //delay 2 seconds
QUIT 4D
End if
End if
Until (<>ShutDownPending | <>StopCheckSessionTime)
Hope this helps!
Bob Miller
Chomerics, a division of Parker Hannifin Corporation
**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ: http://lists.4d.com/faqnug.html
Archive: http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub: mailto:[email protected]
**********************************************************************