Announcement Announcement Module
Collapse
No announcement yet.
Counting number of users online? Page Title Module
Move Remove Collapse
This topic is closed
X
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Counting number of users online?

    Hey there,

    Was just brainstorming how to track the number of online users with acegi? Any ideas? My first instinct was to make an imp-lementation of AuthenticationDao to add some data to a database table indicating that the user was logged on, and also have similar code in my logoff to delete the entry from the database table.

    I did a search and found nothing on the forums. Surely someone has had to have implemented something like this? Does my idea seem sound? I don't like it, because if a User doesn't logoff through the logout page, the system will think they are still logged in.

    Thank for any help!

    ..jordan willms

  • #2
    Why don't you use a SessionListener - each time a new session is created you just increment the counter. Maybe I'm mistaken but I see this facility (counting users) outside Acegi.
    For sure there are some nice libraries out-there for counting/tracking users. For example take a look at http://www.opensymphony.com/clickstream/
    Utility to track the current users on your site, and where they've been in detail. This allows you to track 'click streams' or 'traffic paths' across your site. Please visit the JIRA change log to see the latest developments in Clickstream.
    Features

    * Start tracking click stream when users' sessions begin (via a Listener).
    * Track information with each click the user makes (via a Servlet Filter).
    * Log the complete click stream to a file or PrintStream when the users' session ends.
    * Try to discover whether the user is a bot, and filter appropriately (currently 252 bots are detected).
    * JSP and/or Servlet front-ends to browse the currently active click streams.

    Comment


    • #3
      well, let me elaborate

      Let me elaborate,

      I basically need to the ability to test whether user <username> is online or not. I'm not sure if clickstream will allow me to do this.

      Any thoughts?

      ..jay @ pixelknowledge.com

      Comment


      • #4
        See these threads:

        http://forum.springframework.org/viewtopic.php?t=1261
        http://forum.springframework.org/viewtopic.php?t=1711

        Comment


        • #5
          So.....

          trying to wrap my head around this.

          In order to track what users are logged in at any given time:

          Basically, first step is to update my Authentication request object to contain the HttpSession ID. (I'll need to edit t.sf.acegisecurity.ui.webapp.AuthenticationProcess ingFilter)

          Second step would be to write an ApplicationListener. It would listen for net.sf.acegisecurity.providers.dao.event.Authentic ationSuccessEvent and update my authentication repository with the session ID contained in the event for the user subject of the authentication. Does this mean I have a table, perhaps called online_users, with simply {userid, sessionid} ?

          Lastly, in order to know when a user has 'logged out', I'll use HttpSessionListener to catch the timeout event and set the sessionId = null in the database, or just delete the row in the table aformentioned.

          Is this a potential solution to my problem?

          ..jordan willms

          Comment


          • #6
            You've pretty much got a plan there, except you override AuthenticationProcessingFilter.setDetails() to actually modify what is stored in the authentication request object.

            Comment


            • #7
              Counting number of users online???

              I am very glad that I happened upon this thread. I was trying to do the same thing and this was exactly the kind of advice that I was looking for.

              I did decide to implement this a little bit differently. Instead of using Acegi, I decided to use a combination of ServletContextListener and HttpSessionAttributeListener. I modeled the solution after something that I found in AppFuse called the UserCounterListener. This object will actually keep track of which users are currently logged into the system.

              I hope this helps someone in the future.

              Thanks
              Carlus

              Comment


              • #8
                Counting Active Users

                Hi,

                I use jsf and facelets and I want to count active users on my web application using filter and a jsf page.

                thanks for any suggestions for me?

                Comment

                Working...
                X