use of com.haulmont.cuba.web.security.events.SessionHeartbeatEvent 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));
}
}
use of com.haulmont.cuba.web.security.events.SessionHeartbeatEvent in project cuba by cuba-platform.
the class App method onHeartbeat.
/**
* Called from heartbeat request. <br>
* Used for ping middleware session and show session messages
*/
public void onHeartbeat() {
Connection connection = getConnection();
boolean sessionIsAlive = false;
if (connection.isAuthenticated()) {
// Ping middleware session if connected and show messages
log.debug("Ping middleware session");
try {
String message = userSessionService.getMessages();
sessionIsAlive = true;
if (message != null) {
message = message.replace("\n", "<br/>");
getWindowManager().showNotification(message, Frame.NotificationType.ERROR_HTML);
}
} catch (NoUserSessionException ignored) {
// ignore no user session exception
} catch (Exception e) {
log.warn("Exception while session ping", e);
}
}
if (sessionIsAlive) {
events.publish(new SessionHeartbeatEvent(this));
}
}
Aggregations