Fórum

Programmatically identify number of users accessing a liferay page

thumbnail
Amith ., modificado 7 Anos atrás.

Programmatically identify number of users accessing a liferay page

New Member Postagens: 8 Data de Entrada: 10/09/13 Postagens Recentes
Hi,

I am wondering is there any way in liferay to programmatically identify the number of people (liferay user or guest) viewing a particular liferay public or private page?

I need to restrict page access if current page view count is greater than 100.

Any suggestion would help.
thumbnail
Milen Dyankov, modificado 7 Anos atrás.

RE: Programmatically identify number of users accessing a liferay page

Expert Postagens: 310 Data de Entrada: 30/10/12 Postagens Recentes
IMHO, you need to refine your requirements. Right now what I understand is that if 100 people open a page and keep it open whole day/week no one else will be able to see the page during that period. Is that really what you are looking for?
thumbnail
Amith ., modificado 7 Anos atrás.

RE: Programmatically identify number of users accessing a liferay page

New Member Postagens: 8 Data de Entrada: 10/09/13 Postagens Recentes
Yes, you are right. I am looking for something like what you understood.
thumbnail
Milen Dyankov, modificado 7 Anos atrás.

RE: Programmatically identify number of users accessing a liferay page

Expert Postagens: 310 Data de Entrada: 30/10/12 Postagens Recentes
First thing I need to say is I hope you are aware you will be opening your server to DoS attacks by doing this.

You need :
  • something that tells you the page is still being displayed on some screen. You may need to use Javascript on the page to periodically call the server to let it know the page is still open.
  • something on the server side that will receive those calls and increase a counter per page. You can use ServiceBuilder to create own service with persistence or you can store the data in page's custom attributes
  • something on the server side that will periodically check and reduce counters for any page view that was not updated in defined time period. You can use Liferay's scheduler for that.