use of com.faforever.client.notification.Action in project downlords-faf-client by FAForever.
the class SettingsController method onLanguageSelected.
public void onLanguageSelected() {
LocalizationPrefs localizationPrefs = preferencesService.getPreferences().getLocalization();
if (Objects.equals(languageComboBox.getValue(), localizationPrefs.getLanguage())) {
return;
}
log.debug("A new language was selected: {}", languageComboBox.getValue());
localizationPrefs.setLanguage(languageComboBox.getValue());
preferencesService.storeInBackground();
notificationService.addNotification(new PersistentNotification(i18n.get("settings.languages.restart.message"), Severity.WARN, Collections.singletonList(new Action(i18n.get("settings.languages.restart"), event -> {
Platform.exit();
// FIXME reload application (stage & application context)
}))));
}
use of com.faforever.client.notification.Action in project downlords-faf-client by FAForever.
the class ReplayServerImpl method start.
@Override
public CompletableFuture<Void> start(int gameId) {
stoppedGracefully = false;
CompletableFuture<Void> future = new CompletableFuture<>();
new Thread(() -> {
Integer localReplayServerPort = clientProperties.getReplay().getLocalServerPort();
String remoteReplayServerHost = clientProperties.getReplay().getRemoteHost();
Integer remoteReplayServerPort = clientProperties.getReplay().getRemotePort();
log.debug("Opening local replay server on port {}", localReplayServerPort);
log.debug("Connecting to replay server at '{}:{}'", remoteReplayServerHost, remoteReplayServerPort);
try (ServerSocket localSocket = new ServerSocket(localReplayServerPort);
Socket remoteReplayServerSocket = new Socket(remoteReplayServerHost, remoteReplayServerPort)) {
this.serverSocket = localSocket;
future.complete(null);
recordAndRelay(gameId, localSocket, new BufferedOutputStream(remoteReplayServerSocket.getOutputStream()));
} catch (ConnectException e) {
// TODO record locally even though remote is down.
log.warn("Could not connect to remote replay server", e);
notificationService.addNotification(new PersistentNotification(i18n.get("replayServer.unreachable"), Severity.WARN));
future.complete(null);
} catch (IOException e) {
if (stoppedGracefully) {
return;
}
future.completeExceptionally(e);
log.warn("Error in replay server", e);
notificationService.addNotification(new PersistentNotification(i18n.get("replayServer.listeningFailed", localReplayServerPort), Severity.WARN, Collections.singletonList(new Action(i18n.get("replayServer.retry"), event -> start(gameId)))));
}
}).start();
return future;
}
use of com.faforever.client.notification.Action in project downlords-faf-client by FAForever.
the class ClientUpdateServiceImpl method downloadAndInstallInBackground.
private void downloadAndInstallInBackground(UpdateInfo updateInfo) {
DownloadUpdateTask task = applicationContext.getBean(DownloadUpdateTask.class);
task.setUpdateInfo(updateInfo);
taskService.submitTask(task).getFuture().thenAccept(this::install).exceptionally(throwable -> {
logger.warn("Error while downloading client update", throwable);
notificationService.addNotification(new PersistentNotification(i18n.get("clientUpdateDownloadFailed.notification"), WARN, singletonList(new Action(i18n.get("clientUpdateDownloadFailed.retry"), event -> downloadAndInstallInBackground(updateInfo)))));
return null;
});
}
Aggregations