[Building Sakai] Count user online in Sakai.

Steve Swinsburg steve.swinsburg at gmail.com
Wed Apr 4 04:28:33 PDT 2012


A quicker way to do this across the entire environment (since PresenceService is site based) is to use the ActivityService:

org.sakaiproject.event.api 
Interface ActivityService

public interface ActivityService
ActivityService provides the ability to check if users are online and when they were last active.

Users are registered and updated each time they publish an event. As such you can tell if a user is active and when they were last active (last event time).

For clustered environments, you may experience discrepancies when a new node comes online as the cache will start afresh so users will only be repopulated into the cache once they start publishing events.


Method Summary
 List<String>	getActiveUsers(List<String> userIds) 
          Get the list of users with active Sakai sessions, given the supplied list of userIds.
 Long	getLastEventTimeForUser(String userId) 
          Get last event time for the given user
 Map<String,Long>	getLastEventTimeForUsers(List<String> userIds) 
          Get last event time for the given list of users
 boolean	isUserActive(String userId) 
          Check if a userId has an active Sakai session.


cheers,
Steve

On 04/04/2012, at 7:10 PM, David Wafula wrote:

> I usually inject PresenceService into the tool then:
> 
> List<String> locationIds = presenceService.getLocations();
> 
>        for (String locationId : locationIds) {
>            List<UsageSession> usageSessions =
> presenceService.getPresence(locationId);
>            for (UsageSession usageSession : usageSessions) {
>                String userEid = usageSession.getUserEid();   //or
> userid
>              //i then total up the unique users somewhere from here.
>             }
>         }
> 
> Regards,
> dww.
> 
> On Wed, Apr 4, 2012 at 9:59 AM, Tram Bao <baotram144 at gmail.com> wrote:
>> Dear all,
>> 
>> I want to count user online in Sakai.
>> Does Sakai has a API to do that?
>> 
>> Thanks,
>> TramBao.
>> 
>> _______________________________________________
>> sakai-dev mailing list
>> sakai-dev at collab.sakaiproject.org
>> http://collab.sakaiproject.org/mailman/listinfo/sakai-dev
>> 
>> TO UNSUBSCRIBE: send email to sakai-dev-unsubscribe at collab.sakaiproject.org
>> with a subject of "unsubscribe"
> 
> 
> 
> -- 
> David Wafula
> _______________________________________________
> sakai-dev mailing list
> sakai-dev at collab.sakaiproject.org
> http://collab.sakaiproject.org/mailman/listinfo/sakai-dev
> 
> TO UNSUBSCRIBE: send email to sakai-dev-unsubscribe at collab.sakaiproject.org with a subject of "unsubscribe"

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://collab.sakaiproject.org/pipermail/sakai-dev/attachments/20120404/29be61da/attachment.html 


More information about the sakai-dev mailing list