Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to count the active users

 
Sarah Jones
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have to count the number of active users.
The main problem is how to trace the users who just close the browser window. The session will still alive. In my application the session time out is 4 hours. We cannot reduce that.
The main requirement is to show the message "SYSTEM IS BUSY" when the number of users exceed a particular limit.
 
Santosh Maskar
Ranch Hand
Posts: 226
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
You can use the javascript function to track the Browsers close button,
other wise trap the onclose event geneaqted by the browser and invalidate the session for that active user ,

but this not the soluiton ultimatly. u need to do the server side track

other wise implemnt the forcefully login when user close the browser ,

using onclose u can open the same page and ask him for log off , if u dont have the security filets.
 
Jeroen Wenting
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
tracking browser close events isn't guaranteed to work as the browser may or may not fire an onclose event to the currently loaded page on closing.

Short: there's NO way to guarantee that a session on the server indeed has a browser associated with it, you always have to assume it has.

4 hour timeouts are excessive, 30 minutes is pretty much standard and busy sites may reduce that to 5-10 minutes only.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13058
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I suppose you could create a "heartbeat" request fired automatically from the client browser every N seconds with either JavaScript or an applet. If the heartbeat does not show up, assume the user is inactive.
Bill
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To take a possibly wild left turn ... is the real measure of a busy system the number of users? Maybe you can think of another measure - hits or throughput over last n minutes or users who did something in the last n minutes. Any other ideas?
 
Sonny Gill
Ranch Hand
Posts: 1211
IntelliJ IDE Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by William Brogden:
I suppose you could create a "heartbeat" request fired automatically from the client browser every N seconds with either JavaScript or an applet. If the heartbeat does not show up, assume the user is inactive.
Bill


Hi Bill,

I have used this approach with a self-refreshing page, first in a normal frame 1 pixel wide so it wont show, and then in an inline frame.
I didnt like the idea too much, but it was a must-have requirement, because the application license a placed a max-users limit.
One issue with this was that if the user opens up more than one windows, there are that many more 'heartbeats' going, leading to more network traffic that originally planned for.

Will using an applet instead of the periodically refreshing page in the frame provide any benefits?

thanks

Sonny
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic