Search in sources :

Example 1 with ReportingService

use of com.faforever.client.reporting.ReportingService in project downlords-faf-client by FAForever.

the class GameServiceImpl method startGame.

/**
 * Actually starts the game, including relay and replay server. Call this method when everything else is prepared
 * (mod/map download, connectivity check etc.)
 */
private void startGame(GameLaunchMessage gameLaunchMessage, Faction faction, RatingMode ratingMode) {
    if (isRunning()) {
        logger.warn("Forged Alliance is already running, not starting game");
        return;
    }
    stopSearchLadder1v1();
    replayService.startReplayServer(gameLaunchMessage.getUid()).thenCompose(aVoid -> iceAdapter.start()).thenAccept(adapterPort -> {
        List<String> args = fixMalformedArgs(gameLaunchMessage.getArgs());
        process = noCatch(() -> forgedAllianceService.startGame(gameLaunchMessage.getUid(), faction, args, ratingMode, adapterPort, clientProperties.getReplay().getLocalServerPort(), rehostRequested, getCurrentPlayer()));
        setGameRunning(true);
        this.ratingMode = ratingMode;
        spawnTerminationListener(process);
    }).exceptionally(throwable -> {
        logger.warn("Game could not be started", throwable);
        notificationService.addNotification(new ImmediateNotification(i18n.get("errorTitle"), i18n.get("game.start.couldNotStart"), ERROR, throwable, Arrays.asList(new ReportAction(i18n, reportingService, throwable), new DismissAction(i18n))));
        setGameRunning(false);
        return null;
    });
}
Also used : Arrays(java.util.Arrays) RehostRequestEvent(com.faforever.client.fa.relay.event.RehostRequestEvent) CompletableFuture.completedFuture(java.util.concurrent.CompletableFuture.completedFuture) LoggerFactory(org.slf4j.LoggerFactory) ReadOnlyBooleanProperty(javafx.beans.property.ReadOnlyBooleanProperty) ReportingService(com.faforever.client.reporting.ReportingService) ConnectionState(com.faforever.client.net.ConnectionState) GameInfoMessage(com.faforever.client.remote.domain.GameInfoMessage) Collections.singletonList(java.util.Collections.singletonList) ListChangeListener(javafx.collections.ListChangeListener) Map(java.util.Map) GameStatus(com.faforever.client.remote.domain.GameStatus) URI(java.net.URI) PlayerService(com.faforever.client.player.PlayerService) Path(java.nio.file.Path) ClientProperties(com.faforever.client.config.ClientProperties) CancellationException(java.util.concurrent.CancellationException) MethodHandles(java.lang.invoke.MethodHandles) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Set(java.util.Set) ObservableMap(javafx.collections.ObservableMap) Observable(javafx.beans.Observable) DismissAction(com.faforever.client.notification.DismissAction) FeaturedMod(com.faforever.client.mod.FeaturedMod) Platform(javafx.application.Platform) Player(com.faforever.client.player.Player) Nullable(org.jetbrains.annotations.Nullable) RatingMode(com.faforever.client.fa.RatingMode) BooleanProperty(javafx.beans.property.BooleanProperty) Slf4j(lombok.extern.slf4j.Slf4j) List(java.util.List) ForgedAllianceService(com.faforever.client.fa.ForgedAllianceService) PostConstruct(javax.annotation.PostConstruct) ModService(com.faforever.client.mod.ModService) Lazy(org.springframework.context.annotation.Lazy) ObservableList(javafx.collections.ObservableList) NotNull(org.jetbrains.annotations.NotNull) PreferencesService(com.faforever.client.preferences.PreferencesService) WeakChangeListener(javafx.beans.value.WeakChangeListener) GameLaunchMessage(com.faforever.client.remote.domain.GameLaunchMessage) LoginMessage(com.faforever.client.remote.domain.LoginMessage) FXCollections(javafx.collections.FXCollections) CompletableFuture(java.util.concurrent.CompletableFuture) ArrayList(java.util.ArrayList) IceAdapter(com.faforever.client.fa.relay.ice.IceAdapter) PlatformService(com.faforever.client.fx.PlatformService) GameUpdater(com.faforever.client.patch.GameUpdater) EventBus(com.google.common.eventbus.EventBus) Inject(javax.inject.Inject) HashSet(java.util.HashSet) NotificationService(com.faforever.client.notification.NotificationService) Service(org.springframework.stereotype.Service) ERROR(com.faforever.client.notification.Severity.ERROR) Subscribe(com.google.common.eventbus.Subscribe) ReportAction(com.faforever.client.notification.ReportAction) Collections.emptyMap(java.util.Collections.emptyMap) Logger(org.slf4j.Logger) Collections.emptySet(java.util.Collections.emptySet) Executor(java.util.concurrent.Executor) JavaFxUtil(com.faforever.client.fx.JavaFxUtil) Action(com.faforever.client.notification.Action) ReplayService(com.faforever.client.replay.ReplayService) IOException(java.io.IOException) MatchmakerMessage(com.faforever.client.rankedmatch.MatchmakerMessage) PersistentNotification(com.faforever.client.notification.PersistentNotification) FafService(com.faforever.client.remote.FafService) Consumer(java.util.function.Consumer) SimpleBooleanProperty(javafx.beans.property.SimpleBooleanProperty) Severity(com.faforever.client.notification.Severity) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) LADDER_1V1(com.faforever.client.game.KnownFeaturedMod.LADDER_1V1) ImmediateNotification(com.faforever.client.notification.ImmediateNotification) NONE(com.faforever.client.fa.RatingMode.NONE) ExternalReplayInfoGenerator(com.faforever.client.replay.ExternalReplayInfoGenerator) VisibleForTesting(com.google.common.annotations.VisibleForTesting) I18n(com.faforever.client.i18n.I18n) MapService(com.faforever.client.map.MapService) Collections(java.util.Collections) NoCatch.noCatch(com.github.nocatch.NoCatch.noCatch) ImmediateNotification(com.faforever.client.notification.ImmediateNotification) DismissAction(com.faforever.client.notification.DismissAction) ReportAction(com.faforever.client.notification.ReportAction) Collections.singletonList(java.util.Collections.singletonList) List(java.util.List) ObservableList(javafx.collections.ObservableList) ArrayList(java.util.ArrayList)

Example 2 with ReportingService

use of com.faforever.client.reporting.ReportingService in project downlords-faf-client by FAForever.

the class JoinGameHelper method join.

public void join(Game game, String password, boolean ignoreRating) {
    Player currentPlayer = playerService.getCurrentPlayer().orElseThrow(() -> new IllegalStateException("Player has not been set"));
    int playerRating = RatingUtil.getRoundedGlobalRating(currentPlayer);
    if (!preferencesService.isGamePathValid()) {
        CompletableFuture<Path> gameDirectoryFuture = new CompletableFuture<>();
        eventBus.post(new GameDirectoryChooseEvent(gameDirectoryFuture));
        gameDirectoryFuture.thenAccept(path -> Optional.ofNullable(path).ifPresent(path1 -> join(game, password, ignoreRating)));
        return;
    }
    if (!ignoreRating && (playerRating < game.getMinRating() || playerRating > game.getMaxRating())) {
        showRatingOutOfBoundsConfirmation(playerRating, game, password);
        return;
    }
    if (game.getPasswordProtected() && password == null) {
        EnterPasswordController enterPasswordController = uiService.loadFxml("theme/enter_password.fxml");
        enterPasswordController.setOnPasswordEnteredListener(this::join);
        enterPasswordController.setGame(game);
        enterPasswordController.setIgnoreRating(ignoreRating);
        enterPasswordController.showPasswordDialog(StageHolder.getStage());
    } else {
        gameService.joinGame(game, password).exceptionally(throwable -> {
            logger.warn("Game could not be joined", throwable);
            notificationService.addNotification(new ImmediateNotification(i18n.get("errorTitle"), i18n.get("games.couldNotJoin"), ERROR, throwable, asList(new DismissAction(i18n), new ReportAction(i18n, reportingService, throwable))));
            return null;
        });
    }
}
Also used : Path(java.nio.file.Path) PreferencesService(com.faforever.client.preferences.PreferencesService) UiService(com.faforever.client.theme.UiService) LoggerFactory(org.slf4j.LoggerFactory) CompletableFuture(java.util.concurrent.CompletableFuture) ReportingService(com.faforever.client.reporting.ReportingService) Scope(org.springframework.context.annotation.Scope) EventBus(com.google.common.eventbus.EventBus) NotificationService(com.faforever.client.notification.NotificationService) Arrays.asList(java.util.Arrays.asList) ERROR(com.faforever.client.notification.Severity.ERROR) PlayerService(com.faforever.client.player.PlayerService) Path(java.nio.file.Path) ReportAction(com.faforever.client.notification.ReportAction) RatingUtil(com.faforever.client.util.RatingUtil) Logger(org.slf4j.Logger) MethodHandles(java.lang.invoke.MethodHandles) Action(com.faforever.client.notification.Action) DismissAction(com.faforever.client.notification.DismissAction) Player(com.faforever.client.player.Player) StageHolder(com.faforever.client.ui.StageHolder) Component(org.springframework.stereotype.Component) Severity(com.faforever.client.notification.Severity) ImmediateNotification(com.faforever.client.notification.ImmediateNotification) Optional(java.util.Optional) GameDirectoryChooseEvent(com.faforever.client.ui.preferences.event.GameDirectoryChooseEvent) I18n(com.faforever.client.i18n.I18n) Player(com.faforever.client.player.Player) CompletableFuture(java.util.concurrent.CompletableFuture) ImmediateNotification(com.faforever.client.notification.ImmediateNotification) DismissAction(com.faforever.client.notification.DismissAction) ReportAction(com.faforever.client.notification.ReportAction) GameDirectoryChooseEvent(com.faforever.client.ui.preferences.event.GameDirectoryChooseEvent)

Example 3 with ReportingService

use of com.faforever.client.reporting.ReportingService in project downlords-faf-client by FAForever.

the class LeaderboardController method onDisplay.

@Override
public void onDisplay(NavigateEvent navigateEvent) {
    Assert.checkNullIllegalState(ratingType, "ratingType must not be null");
    contentPane.setVisible(false);
    leaderboardService.getEntries(ratingType).thenAccept(leaderboardEntryBeans -> {
        ratingTable.setItems(observableList(leaderboardEntryBeans));
        contentPane.setVisible(true);
    }).exceptionally(throwable -> {
        contentPane.setVisible(false);
        logger.warn("Error while loading leaderboard entries", throwable);
        notificationService.addNotification(new ImmediateNotification(i18n.get("errorTitle"), i18n.get("leaderboard.failedToLoad"), Severity.ERROR, throwable, Arrays.asList(new ReportAction(i18n, reportingService, throwable), new DismissAction(i18n))));
        return null;
    });
}
Also used : Arrays(java.util.Arrays) LoggerFactory(org.slf4j.LoggerFactory) ReportingService(com.faforever.client.reporting.ReportingService) Scope(org.springframework.context.annotation.Scope) TableColumn(javafx.scene.control.TableColumn) NavigateEvent(com.faforever.client.main.event.NavigateEvent) Inject(javax.inject.Inject) FXCollections.observableList(javafx.collections.FXCollections.observableList) NotificationService(com.faforever.client.notification.NotificationService) KnownFeaturedMod(com.faforever.client.game.KnownFeaturedMod) TableView(javafx.scene.control.TableView) Pane(javafx.scene.layout.Pane) ReportAction(com.faforever.client.notification.ReportAction) SimpleFloatProperty(javafx.beans.property.SimpleFloatProperty) StringCell(com.faforever.client.fx.StringCell) TextField(javafx.scene.control.TextField) Logger(org.slf4j.Logger) Node(javafx.scene.Node) MethodHandles(java.lang.invoke.MethodHandles) AbstractViewController(com.faforever.client.fx.AbstractViewController) DismissAction(com.faforever.client.notification.DismissAction) Assert(com.faforever.client.util.Assert) Component(org.springframework.stereotype.Component) Severity(com.faforever.client.notification.Severity) Validator(com.faforever.client.util.Validator) ImmediateNotification(com.faforever.client.notification.ImmediateNotification) I18n(com.faforever.client.i18n.I18n) ConfigurableBeanFactory(org.springframework.beans.factory.config.ConfigurableBeanFactory) ImmediateNotification(com.faforever.client.notification.ImmediateNotification) DismissAction(com.faforever.client.notification.DismissAction) ReportAction(com.faforever.client.notification.ReportAction)

Example 4 with ReportingService

use of com.faforever.client.reporting.ReportingService in project downlords-faf-client by FAForever.

the class AbstractChatTabController method sendMessage.

private void sendMessage() {
    TextInputControl messageTextField = messageTextField();
    messageTextField.setDisable(true);
    final String text = messageTextField.getText();
    chatService.sendMessageInBackground(receiver, text).thenAccept(message -> {
        messageTextField.clear();
        messageTextField.setDisable(false);
        messageTextField.requestFocus();
    }).exceptionally(throwable -> {
        logger.warn("Message could not be sent: {}", text, throwable);
        notificationService.addNotification(new ImmediateNotification(i18n.get("errorTitle"), i18n.get("chat.sendFailed"), Severity.ERROR, throwable, Arrays.asList(new ReportAction(i18n, reportingService, throwable), new DismissAction(i18n))));
        messageTextField.setDisable(false);
        messageTextField.requestFocus();
        return null;
    });
}
Also used : TextInputControl(javafx.scene.control.TextInputControl) EventHandler(javafx.event.EventHandler) Arrays(java.util.Arrays) CHAT_TEXT(com.faforever.client.theme.UiService.CHAT_TEXT) UiService(com.faforever.client.theme.UiService) TextInputControl(javafx.scene.control.TextInputControl) PseudoClass(javafx.css.PseudoClass) URL(java.net.URL) ImageUploadService(com.faforever.client.uploader.ImageUploadService) LoggerFactory(org.slf4j.LoggerFactory) ReportingService(com.faforever.client.reporting.ReportingService) StringUtils(org.apache.commons.lang3.StringUtils) CHAT_CONTAINER(com.faforever.client.theme.UiService.CHAT_CONTAINER) CASE_INSENSITIVE(java.util.regex.Pattern.CASE_INSENSITIVE) NavigateEvent(com.faforever.client.main.event.NavigateEvent) AudioService(com.faforever.client.audio.AudioService) TimeService(com.faforever.client.util.TimeService) TabPane(javafx.scene.control.TabPane) Matcher(java.util.regex.Matcher) CharStreams(com.google.common.io.CharStreams) MINUTES(java.time.temporal.ChronoUnit.MINUTES) SimpleIntegerProperty(javafx.beans.property.SimpleIntegerProperty) ITEM_AT_INDEX(javafx.scene.AccessibleAttribute.ITEM_AT_INDEX) ChatPrefs(com.faforever.client.preferences.ChatPrefs) SELF(com.faforever.client.chat.SocialStatus.SELF) PlayerService(com.faforever.client.player.PlayerService) HtmlEscapers.htmlEscaper(com.google.common.html.HtmlEscapers.htmlEscaper) ClientProperties(com.faforever.client.config.ClientProperties) JSObject(netscape.javascript.JSObject) RatingUtil.getLeaderboardRating(com.faforever.client.util.RatingUtil.getLeaderboardRating) MethodHandles(java.lang.invoke.MethodHandles) Collection(java.util.Collection) KeyEvent(javafx.scene.input.KeyEvent) Reader(java.io.Reader) NavigationItem(com.faforever.client.main.event.NavigationItem) DismissAction(com.faforever.client.notification.DismissAction) Platform(javafx.application.Platform) Player(com.faforever.client.player.Player) StageHolder(com.faforever.client.ui.StageHolder) List(java.util.List) Clipboard(javafx.scene.input.Clipboard) FRIEND(com.faforever.client.chat.SocialStatus.FRIEND) Optional(java.util.Optional) Pattern(java.util.regex.Pattern) Joiner(com.google.common.base.Joiner) CHAT_ENTRY(com.faforever.client.theme.UiService.CHAT_ENTRY) PreferencesService(com.faforever.client.preferences.PreferencesService) WeakChangeListener(javafx.beans.value.WeakChangeListener) Worker(javafx.concurrent.Worker) RatingUtil.getGlobalRating(com.faforever.client.util.RatingUtil.getGlobalRating) WebEngine(javafx.scene.web.WebEngine) AnchorLocation(javafx.stage.PopupWindow.AnchorLocation) MouseEvent(javafx.scene.input.MouseEvent) ClassPathResource(org.springframework.core.io.ClassPathResource) UserService(com.faforever.client.user.UserService) Bindings(javafx.beans.binding.Bindings) IntegerProperty(javafx.beans.property.IntegerProperty) ArrayList(java.util.ArrayList) PlatformService(com.faforever.client.fx.PlatformService) TransientNotification(com.faforever.client.notification.TransientNotification) EventBus(com.google.common.eventbus.EventBus) Inject(javax.inject.Inject) NotificationService(com.faforever.client.notification.NotificationService) TabPaneSkin(com.sun.javafx.scene.control.skin.TabPaneSkin) Tooltip(javafx.scene.control.Tooltip) ReportAction(com.faforever.client.notification.ReportAction) KeyCode(javafx.scene.input.KeyCode) Color(javafx.scene.paint.Color) WebView(javafx.scene.web.WebView) Label(javafx.scene.control.Label) PopupWindow(javafx.stage.PopupWindow) Logger(org.slf4j.Logger) ClanService(com.faforever.client.clan.ClanService) IdenticonUtil(com.faforever.client.util.IdenticonUtil) Controller(com.faforever.client.fx.Controller) JavaFxUtil(com.faforever.client.fx.JavaFxUtil) Node(javafx.scene.Node) ReplayService(com.faforever.client.replay.ReplayService) FOE(com.faforever.client.chat.SocialStatus.FOE) IOException(java.io.IOException) WebViewConfigurer(com.faforever.client.fx.WebViewConfigurer) InputStreamReader(java.io.InputStreamReader) Popup(javafx.stage.Popup) ClanTooltipController(com.faforever.client.clan.ClanTooltipController) Preview(com.faforever.client.chat.UrlPreviewResolver.Preview) Stage(javafx.stage.Stage) Severity(com.faforever.client.notification.Severity) Tab(javafx.scene.control.Tab) ImmediateNotification(com.faforever.client.notification.ImmediateNotification) ExternalReplayInfoGenerator(com.faforever.client.replay.ExternalReplayInfoGenerator) VisibleForTesting(com.google.common.annotations.VisibleForTesting) I18n(com.faforever.client.i18n.I18n) ChangeListener(javafx.beans.value.ChangeListener) Image(javafx.scene.image.Image) NoCatch.noCatch(com.github.nocatch.NoCatch.noCatch) ContentDisplay(javafx.scene.control.ContentDisplay) ImmediateNotification(com.faforever.client.notification.ImmediateNotification) DismissAction(com.faforever.client.notification.DismissAction) ReportAction(com.faforever.client.notification.ReportAction)

Aggregations

I18n (com.faforever.client.i18n.I18n)4 DismissAction (com.faforever.client.notification.DismissAction)4 ImmediateNotification (com.faforever.client.notification.ImmediateNotification)4 NotificationService (com.faforever.client.notification.NotificationService)4 ReportAction (com.faforever.client.notification.ReportAction)4 Severity (com.faforever.client.notification.Severity)4 ReportingService (com.faforever.client.reporting.ReportingService)4 Player (com.faforever.client.player.Player)3 PlayerService (com.faforever.client.player.PlayerService)3 PreferencesService (com.faforever.client.preferences.PreferencesService)3 EventBus (com.google.common.eventbus.EventBus)3 MethodHandles (java.lang.invoke.MethodHandles)3 Logger (org.slf4j.Logger)3 LoggerFactory (org.slf4j.LoggerFactory)3 ClientProperties (com.faforever.client.config.ClientProperties)2 JavaFxUtil (com.faforever.client.fx.JavaFxUtil)2 PlatformService (com.faforever.client.fx.PlatformService)2 NavigateEvent (com.faforever.client.main.event.NavigateEvent)2 Action (com.faforever.client.notification.Action)2 UiService (com.faforever.client.theme.UiService)2