Session timeout handling via AJAX Push

119 views
Skip to first unread message

Yogesh Patel

unread,
May 2, 2011, 12:55:14 PM5/2/11
to GWTEventService
Hi,
We are using GWTEventService in our project for Reverse AJAX. Its
fulfill all our requirement.
Currently we are identifying the possibilities to use GWTEventService
to handle the session time out condition.

We have tried following approach to implement it:-
1. In eventservice.properties :-
# Time to wait at maximum (canceled when an event occurred)
time.waiting.max=30000
# Time to wait at minimum (even when events have already occurred)
time.waiting.min=0
# Time till timeout (when the time is reached, the user will be
removed from listening for events)
time.timeout=1800000
2. In Tomcat:-
<session-timeout>25</session-timeout>
3. We have class which implements HttpSessionListener, and on
sessionDestroyed() we are pushing an Event. Here is the code of it:-

public void sessionDestroyed(HttpSessionEvent sessionEvent) {

String sessionId = sessionEvent.getSession().getId();
System.out.println("Session Destroyed:----"+sessionId);
log.debug("Session Destroyed:----"+sessionId);
if (EventRegistryFactory.getInstance().getEventRegistry()
.isUserRegistered(sessionId)) {
EventRegistryFactory.getInstance().getEventRegistry()
.addEventUserSpecific(sessionId, new SessionTimeoutEvent());
System.out.println("Message Pused:----"+sessionId);
log.debug("Message Pused:----"+sessionId);
}
}


But somehow, its not working.
Is there any inbuilt feature to achieve the same in GWTEventService? I
have gone through 'Timeout-Concept', but I am not sure how it can be
used for session timeout only. Because we want to send an Event as
soon as there is session timeout.

Thanks in advance.



Sven S.

unread,
May 7, 2011, 8:59:47 AM5/7/11
to gwteven...@googlegroups.com
Hi,

the code looks good, but which user/client should get the event? At the moment your code tries to send an event to the user with the destroyed session and I think it isn't possible to send/receive events when the session is already destroyed. If you want to send the session-timeout event to all users/clients of a domain, you shoudn't use addEventUserSpecific. When only the client of the session-timeout should get informed, you can use the timeout listening functionality of GWTEventService by implementing an UnlistenListener and register it to the the timeout scope (you should set the timeout time smaller than the session-timeout, so client has the chance to receive the event before the session is timed out).

Regards,

Sven S.

2011/5/2 Yogesh Patel <yogesh1...@gmail.com>



--
You received this message because you are subscribed to the Google Groups "GWTEventService" group.
To post to this group, send email to gwteven...@googlegroups.com.
To unsubscribe from this group, send email to gwteventservi...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gwteventservice?hl=en.


Reply all
Reply to author
Forward
0 new messages