3 Replies Latest reply on Jan 20, 2008 12:44 PM by jacob.orshalick

    How to reliably count active sessions and connected users ?

    gaboo

      Hello.

      I'm using seam 2.0.0 and I'd like to cound the active sessions and connected users.

      For session, I'm using two observer methods in an application scoped ejb to count :

      @Observer("org.jboss.seam.postCreate.org.jboss.seam.web.session")
      public void increaseUserCount() {
       userCount++;
      }
      
      @Observer("org.jboss.seam.preDestroyContext.SESSION")
      public void decreaseUserCount() {
       userCount--;
      }


      For connected users, I use those two seam security events :

      @Observer("org.jboss.seam.security.loginSuccessful")
      public void increaseConnectedUserCount() {
       connectedUserCount++;
      }
      
      @Observer("org.jboss.seam.security.loggedOut")
      public void decreaseConnectedUserCount() {
       connectedUserCount--;
      }


      Both solutions aren't ok. For example, sometimes I have a number of -1 for connected users. And for sessions, the number keeps high, so I don't know If a really catch all session ending.

      Do you have / know a better idea ?