From d15efce5958bf98e03aeb811d7f961e46c928710 Mon Sep 17 00:00:00 2001 From: Zemke Date: Sat, 16 Jan 2021 00:45:40 +0100 Subject: [PATCH] GH-168 Last is still a replay --- .../com/cwtsite/cwt/domain/game/view/GameRestController.kt | 5 ++--- .../cwtsite/cwt/domain/game/view/GameRestControllerTest.kt | 2 -- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/cwt-spring/src/main/java/com/cwtsite/cwt/domain/game/view/GameRestController.kt b/cwt-spring/src/main/java/com/cwtsite/cwt/domain/game/view/GameRestController.kt index 8a890630..cb66d943 100644 --- a/cwt-spring/src/main/java/com/cwtsite/cwt/domain/game/view/GameRestController.kt +++ b/cwt-spring/src/main/java/com/cwtsite/cwt/domain/game/view/GameRestController.kt @@ -50,12 +50,11 @@ constructor(private val gameService: GameService, private val userService: UserS val emitter = sseEmitterFactory.createInstance(1000 * 60 * 4) var emissions = 0 val emit = { data: String, isLast: Boolean -> + emitter.send("EVENT", data) + logger.info("Emitted game stats event of length ${data.length} to game $gameId") if (isLast) { emitter.send("DONE", "DONE") emitter.complete() - } else { - emitter.send("EVENT", data) - logger.info("Emitted game stats event of length ${data.length} to game $gameId") } } val subscription = GameStatSubscription(gameId, emit) diff --git a/cwt-spring/src/test/java/com/cwtsite/cwt/domain/game/view/GameRestControllerTest.kt b/cwt-spring/src/test/java/com/cwtsite/cwt/domain/game/view/GameRestControllerTest.kt index 5e442985..437ab67d 100644 --- a/cwt-spring/src/test/java/com/cwtsite/cwt/domain/game/view/GameRestControllerTest.kt +++ b/cwt-spring/src/test/java/com/cwtsite/cwt/domain/game/view/GameRestControllerTest.kt @@ -1,5 +1,4 @@ package com.cwtsite.cwt.domain.game.view - import com.cwtsite.cwt.controller.RestException import com.cwtsite.cwt.core.ClockInstance import com.cwtsite.cwt.core.event.SseEmitterFactory @@ -169,7 +168,6 @@ class GameRestControllerTest { @Test fun listenToStats() { val game = EntityDefaults.game() - game.replayQuantity = 3 val sseEmitter = mock(SseEmitterWrapper::class.java) `when`(sseEmitterFactory.createInstance(anyLong())).thenReturn(sseEmitter) cut.listenToStats(game.id!!)