This content has been marked as final.
Show 2 replies
-
1. Re: Online users counter
trong.tran Aug 17, 2011 11:36 PM (in response to iceall)Counting users online would not be done in portlet and I also don't think it's possible. The portlet is just for presenting in this case.
The good way is to create two listeners which extends from org.exoplatform.services.listener.Listener<ConversationRegistry, ConversationState>, then register them to ConvesationRegistry service with name "exo.core.security.ConversationRegistry.register" and "exo.core.security.ConversationRegistry.unregister". These two listeners will be triggered whenever user log-in and log-out from Portal correspondingly.
For example, let's say you have :
public class LoginListener extends Listener<ConversationRegistry, ConversationState> { public LoginListener() throws Exception { } @Override public void onEvent(Event<ConversationRegistry, ConversationState> event) throws Exception { // save user logged-in somehow }
and
public class LogoutListener extends Listener<ConversationRegistry, ConversationState> { public LogoutListener() throws Exception { } @Override public void onEvent(Event<ConversationRegistry, ConversationState> event) throws Exception { // remove user logged-out }
You would register them by configuration like following :
<external-component-plugins> <target-component>org.exoplatform.services.listener.ListenerService</target-component> <component-plugin> <name>exo.core.security.ConversationRegistry.register</name> <set-method>addListener</set-method> <type>LoginListener</type> <description>increase number of online users</description> </component-plugin> <component-plugin> <name>exo.core.security.ConversationRegistry.unregister</name> <set-method>addListener</set-method> <type>LogoutListener</type> <description>decrease number of online users</description> </component-plugin> </external-component-plugins>
-