Vaadin 7.2.4 How to get the last interaction-time of an UI-instance?

Hi there,
is there a possibiltiy to get the last interaction-time of an UI-instance(not VaadinSession) ?
Kind regards
Simon

You mean that : getSession().getLastRequestTimestamp() is not what you need ?

Regards

Hi Simon,

I don’t think it is stored anywhere in core Vaadin. The
VaadinSession.getLastRequestTimestamp
and
UI.getLastHeartbeatTimestamp
methods are needed internally to implement the heartbeat mechanism, but there is no similar need for a
UI.getLastRequestTimestamp
. One way to implement this by yourself would be to have a custom
UidlRequestHandler
and override the
synchronizedHandleRequest
method:

class MyTimestampingUidlRequestHandler extends UidlRequestHandler {
    @Override
    public boolean synchronizedHandleRequest(VaadinSession session,
            VaadinRequest request, VaadinResponse response) throws IOException {
        UI uI = session.getService().findUI(request);
        if (uI instanceof MyTimestampedUI) {
            ((MyTimestampedUI) uI).setLastRequestTimestamp(System.currentTimeMillis);
        }
        super.synchronizedHandleRequest(session, request, response);
    }
}

...

class MyVaadinServlet extends VaadinServlet {
    @Override
    public VaadinServletService createServletService() {
        VaadinServletService service = new VaadinServletService() {
            @Override
            public List<RequestHandler> createRequestHandlers() {
                List<RequestHandler> handlers = super.createRequestHandlers();
                // overrides the default UIDL handler
                handlers.add(new MyTimestampingUidlRequestHandler());
             }
        };
        service.init();
        return service;
    }
}

Unfortunately, this is a bit complicated.

Hi Johannes,
that’s exactly what I need.
Thank you for your effort

In order to understand:
When a User opens a Vaadin-App in multiple Tabs of the same Browser,
the User recieves exactly one VaadinSession, but for each Tab a UI instance.
The getSession().getLastRequestTimestamp() returns the LastRequestTimestamp of the last active UI instance.

I want to monitor all UI instances and their LastRequestTimestamp.