I’d like to ‘sense’ if a user is actually working in an open web page (web app), and if they’re idle for X amount of time send them back to login_page.Show()
What has the least overhead way for measuring active interaction(s) from a user, to see if they’ve abandoned the app/page?
Here’s a little thing I wrote - if you have an Admin WebPage, this code in a timer will update a textArea showing a list of the currently logged in users:
Sub Timer.Run() Handles Run
var onlineUsers() as string
var nSessions as integer = app.SessionCount
for each s as session in app.Sessions
onlineUsers.Append(s.Username + If(s.isDisconnected, "(x)", "") + _
+ " " + format(s.lifetimeSeconds, "#") + " seconds " _
+ if(s.currentPage = nil, " - (no page)", " - " + s.CurrentPage.Name ) )
next
lSessionInfo.Value = str(nSessions) + " sessions : " + EndOfLine + string.FromArray(onlineUsers,EndOfLine)
End Sub
Where lifetimeSeconds is a function on the Session object:
Public Function lifetimeSeconds() As double
// how many seconds has this session been alive
dim d as double = system.Microseconds
dim dt as double = d-createdMicroseconds
dim t as double = dt/1.0e6 // convert to seconds
return t
End Function
and createdMicroseconds is set in Session.Opening:
Sub Opening() Handles Opening
createdMicroseconds = system.Microseconds
End Sub