I gotta keep a list of online users, so when I list all of them I put some green flashling light (or whatever) on the "online" ones.
By online, I mean active, cuz there's no perfect way to tell if a user has its browser open on the website right? So what would be the best way to determine which are the online users?
Thanks,
Christian
-
What is the best way to control online users? (5 messages)
- Posted by: Christian Dechery
- Posted on: March 30 2005 14:13 EST
Threaded Messages (5)
- What is the best way to control online users? by Anil Kumar Sadineni on March 30 2005 16:59 EST
- session timeout? by Christian Dechery on March 31 2005 07:36 EST
- session timeout? by Martin Straus on March 31 2005 09:34 EST
- session timeout? by Christian Dechery on March 31 2005 07:36 EST
- Re: What is the best way to control online users? by Philip Luppens on March 31 2005 10:09 EST
- Re: What is the best way to control online users? by Martin Straus on April 01 2005 08:36 EST
-
What is the best way to control online users?[ Go to top ]
- Posted by: Anil Kumar Sadineni
- Posted on: March 30 2005 16:59 EST
- in response to Christian Dechery
Hi,
You can implement a HttpSessionListener for your web application. When user logs on to the system, create a session and a keep the userid in sesssion scope. In sessionCreated() of HttpSessionListener imlementation class, add the user ID to the ArrayList and maintian it in application scope. Whenever you reach the page to show the online users, cross check all the users with arraylist stored in application scope to show the online users. When user logs out or session time out heppens, the sessionDestroyed() of HttpSessionListener imlementation class will be called and there remove the user ID from the arraylist which is in applicaion scope.
I think this solution works pretty fine.
Anil Sadineni. -
session timeout?[ Go to top ]
- Posted by: Christian Dechery
- Posted on: March 31 2005 07:36 EST
- in response to Anil Kumar Sadineni
I don't think session timeout is a good way to determine if a user is online, cuz that's like 30min. It's too long, maybe a user has been on for as little as 5min, and 25min afterwards it'll still be showing as if he was actually on.
I can't set session timeout to a value like 5min or so or it would keep timing out on users who are actually online an navigating (maybe he stopped to read something, or whatever) on the site.
But comming to think of it, I don't see any other way. :( -
session timeout?[ Go to top ]
- Posted by: Martin Straus
- Posted on: March 31 2005 09:34 EST
- in response to Christian Dechery
Perhaps you could implement your own isOnline() criteria... No matter the session timeout, if the user has not performed any action for some time, show it as "offline" (or "away").
This could be accomplished using a combination of the HttpSessionListener approach described earlier in the thread, an a Filter intercepting user actions (an "action" being every request). You should store the time of the last action in the Session (kind of a parallel timeout, rite?).
Of course, even this crashes if you have any other applications action as client-side, besides your web-app. In this case, you should push this behaviour further down the application layers.
Cheers and happy coding,
Martin -
Re: What is the best way to control online users?[ Go to top ]
- Posted by: Philip Luppens
- Posted on: March 31 2005 10:09 EST
- in response to Christian Dechery
Using a tiny flash movie (or applet) in a frame, you could open an XMLSocket to a server. As soon as the browser window gets closed, it will disconnect. That's probably the most correct way to do it, but it a) might give permission troubles b) requires a custom server, and c) requires the use of Flash, of course.
Then again, I'd go for the session creation/delete approach, much cleaner, less to worry about. -
Re: What is the best way to control online users?[ Go to top ]
- Posted by: Martin Straus
- Posted on: April 01 2005 08:36 EST
- in response to Philip Luppens
Hmmm... clever... Kind of dirty, but clever, I'll give you dat. A nice, little, invisible agent in the client. Still, there's a lot to consider with this approach, I think. Didn't thought about it long enough, but I sense that openning two browsers windows your give you some hard time... I mean, 2 applets, 2 sockets, blah blah....
Have you actually implemented this?
Cheers and happy coding,
Martin