use of com.haulmont.cuba.desktop.Connection in project cuba by cuba-platform.
the class SessionMessagesNotifier method processServerMessage.
protected void processServerMessage(@Nullable String message) {
if (message != null) {
log.debug("Received session message");
Connection connection = App.getInstance().getConnection();
if (connection.isConnected() && timer != null && timer.isRunning()) {
SessionMessageWindow dialog = new SessionMessageWindow(App.getInstance().getMainFrame());
dialog.setMessage(message);
dialog.setVisible(true);
}
}
}
use of com.haulmont.cuba.desktop.Connection in project cuba by cuba-platform.
the class SessionMessagesNotifier method syncMessages.
protected void syncMessages() {
Connection connection = App.getInstance().getConnection();
if (connection.isConnected()) {
log.trace("Check session messages");
asyncMessageLoader = new SwingWorker<String, Void>() {
@Override
protected String doInBackground() throws Exception {
try {
UserSessionService uss = AppBeans.get(UserSessionService.NAME);
return uss.getMessages();
} catch (NoUserSessionException e) {
log.warn("Unable to get messages for session, user session not found");
} catch (Exception e) {
log.warn("Session messages exception: " + e.toString());
}
return null;
}
@Override
protected void done() {
try {
if (!isCancelled()) {
processServerMessage(get());
}
} catch (InterruptedException | ExecutionException ignored) {
// do nothing
} finally {
asyncMessageLoader = null;
}
}
};
asyncMessageLoader.execute();
}
}
Aggregations