authentication - How to check User Online Status with Spring Security in Grails? -


we use grails spring security in our application perform user authentication. if user loggs in our application, rememberme cookie saved. means, user remain logend in between browser sessions.

how can check users online? read can retrieve information session using sessionregistryimpl or httpsessionlistener have no idea how implement that. found post not sure how transform grails: online users spring security

any idea?

i built dating application relies on online users. created grails' service keeps track of online users. have create service keeps concurrent hash map, service singleton 1 instance whole web application. when user log-in first time, set user id, , future time in hash map. example:

key = userid value = + 30min

so when user logs in, increment log-in time 30min , insert in hash map. every request user sends, update value of hash map looking expiry time using user id. if user closes browser, not going update expiry , online status going invalid. can have job runs every 30min , remove keys have expiry date of less now. or if wanna count online users, loop through map , count entries expiry date greater now.

it's hash map in memory, easy access , manipulate, , it's fast. works great me, , since i'm using concurrent hash map, updates , reads safe. hope helps want. sorry answer late saw question :)


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -