Search in sources :

Example 1 with UIRefreshEvent

use of com.haulmont.cuba.web.events.UIRefreshEvent in project cuba by cuba-platform.

the class AppUI method refresh.

@Override
protected void refresh(VaadinRequest request) {
    super.refresh(request);
    boolean sessionIsAlive = true;
    Connection connection = app.getConnection();
    if (connection.isAuthenticated()) {
        // Ping middleware session if connected
        log.debug("Ping middleware session");
        try {
            UserSession session = connection.getSession();
            if (session instanceof ClientUserSession && ((ClientUserSession) session).isAuthenticated()) {
                userSessionService.getUserSession(session.getId());
            }
        } catch (Exception e) {
            sessionIsAlive = false;
            app.exceptionHandlers.handle(new com.vaadin.server.ErrorEvent(e));
        }
        if (sessionIsAlive) {
            events.publish(new SessionHeartbeatEvent(app));
        }
    }
    if (sessionIsAlive) {
        events.publish(new UIRefreshEvent(this));
    }
}
Also used : ClientUserSession(com.haulmont.cuba.client.ClientUserSession) SessionHeartbeatEvent(com.haulmont.cuba.web.security.events.SessionHeartbeatEvent) ClientUserSession(com.haulmont.cuba.client.ClientUserSession) UserSession(com.haulmont.cuba.security.global.UserSession) LoginException(com.haulmont.cuba.security.global.LoginException) UIRefreshEvent(com.haulmont.cuba.web.events.UIRefreshEvent)

Aggregations

ClientUserSession (com.haulmont.cuba.client.ClientUserSession)1 LoginException (com.haulmont.cuba.security.global.LoginException)1 UserSession (com.haulmont.cuba.security.global.UserSession)1 UIRefreshEvent (com.haulmont.cuba.web.events.UIRefreshEvent)1 SessionHeartbeatEvent (com.haulmont.cuba.web.security.events.SessionHeartbeatEvent)1