use of com.faforever.client.fa.relay.event.GameFullEvent in project downlords-faf-client by FAForever.
the class OnGameFullNotifierTest method testAlreadyFocusedDoesntTriggerNotification.
@Test
public void testAlreadyFocusedDoesntTriggerNotification() throws Exception {
Game game = GameBuilder.create().defaultValues().get();
when(gameService.getCurrentGame()).thenReturn(game);
when(platformService.isWindowFocused("Forged Alliance")).thenReturn(true);
instance.onGameFull(new GameFullEvent());
verifyZeroInteractions(notificationService);
}
use of com.faforever.client.fa.relay.event.GameFullEvent in project downlords-faf-client by FAForever.
the class OnGameFullNotifierTest method testOnGameFull.
@Test
public void testOnGameFull() throws Exception {
Game game = GameBuilder.create().defaultValues().get();
when(gameService.getCurrentGame()).thenReturn(game);
when(platformService.isWindowFocused("Forged Alliance")).thenReturn(false);
CountDownLatch countDownLatch = new CountDownLatch(1);
doAnswer(invocation -> {
countDownLatch.countDown();
return null;
}).when(platformService).stopFlashingWindow("Forged Alliance");
instance.onGameFull(new GameFullEvent());
verify(notificationService).addNotification(any(TransientNotification.class));
verify(executor).execute(any(Runnable.class));
}
use of com.faforever.client.fa.relay.event.GameFullEvent in project downlords-faf-client by FAForever.
the class IceAdapterImpl method onGpgGameMessage.
@Subscribe
public void onGpgGameMessage(GpgGameMessageEvent event) {
GpgGameMessage gpgGameMessage = event.getGpgGameMessage();
GpgClientCommand command = gpgGameMessage.getCommand();
if (command == GpgClientCommand.REHOST) {
eventBus.post(new RehostRequestEvent());
return;
}
if (command == GpgClientCommand.GAME_FULL) {
eventBus.post(new GameFullEvent());
return;
}
fafService.sendGpgGameMessage(gpgGameMessage);
}
use of com.faforever.client.fa.relay.event.GameFullEvent in project downlords-faf-client by FAForever.
the class OnGameFullNotifier method onGameFull.
@Subscribe
public void onGameFull(GameFullEvent event) {
executor.execute(() -> {
platformService.startFlashingWindow(faWindowTitle);
while (gameService.isGameRunning() && !platformService.isWindowFocused(faWindowTitle)) {
noCatch(() -> sleep(500));
}
platformService.stopFlashingWindow(faWindowTitle);
});
Game currentGame = gameService.getCurrentGame();
if (currentGame == null) {
throw new ProgrammingError("Got a GameFull notification but player is not in a game");
}
if (platformService.isWindowFocused(faWindowTitle)) {
return;
}
notificationService.addNotification(new TransientNotification(i18n.get("game.full"), i18n.get("game.full.action"), mapService.loadPreview(currentGame.getMapFolderName(), PreviewSize.SMALL), v -> platformService.focusWindow(faWindowTitle)));
}
Aggregations