summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sw-server/src/main/kotlin/org/luxons/sevenwonders/server/controllers/LobbyController.kt10
-rw-r--r--sw-server/src/test/kotlin/org/luxons/sevenwonders/server/controllers/GameBrowserControllerTest.kt2
-rw-r--r--sw-server/src/test/kotlin/org/luxons/sevenwonders/server/controllers/LobbyControllerTest.kt2
3 files changed, 6 insertions, 8 deletions
diff --git a/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/controllers/LobbyController.kt b/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/controllers/LobbyController.kt
index e4536df7..5005d6c9 100644
--- a/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/controllers/LobbyController.kt
+++ b/sw-server/src/main/kotlin/org/luxons/sevenwonders/server/controllers/LobbyController.kt
@@ -20,22 +20,20 @@ import org.springframework.validation.annotation.Validated
import java.security.Principal
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
-import org.springframework.core.env.Environment
+import org.springframework.beans.factory.annotation.Value
/**
* Handles actions in the game's lobby. The lobby is the place where players gather before a game.
*/
@Api(name = "Lobby")
@Controller
-class LobbyController @Autowired constructor(
+class LobbyController(
private val lobbyRepository: LobbyRepository,
private val playerRepository: PlayerRepository,
private val template: SimpMessagingTemplate,
- private val environment: Environment
-) {
+ @Value("\${server.port}")
private val serverPort: String
- get() = environment.getProperty("server.port")
-
+) {
private val Principal.player: Player
get() = playerRepository.find(name)
diff --git a/sw-server/src/test/kotlin/org/luxons/sevenwonders/server/controllers/GameBrowserControllerTest.kt b/sw-server/src/test/kotlin/org/luxons/sevenwonders/server/controllers/GameBrowserControllerTest.kt
index 88e04c14..d252e3f0 100644
--- a/sw-server/src/test/kotlin/org/luxons/sevenwonders/server/controllers/GameBrowserControllerTest.kt
+++ b/sw-server/src/test/kotlin/org/luxons/sevenwonders/server/controllers/GameBrowserControllerTest.kt
@@ -26,7 +26,7 @@ class GameBrowserControllerTest {
playerRepository = PlayerRepository()
val lobbyRepository = LobbyRepository()
val template = mockSimpMessagingTemplate()
- val lobbyController = LobbyController(lobbyRepository, playerRepository, template)
+ val lobbyController = LobbyController(lobbyRepository, playerRepository, template, "UNUSED")
gameBrowserController = GameBrowserController(lobbyController, lobbyRepository, playerRepository, template)
}
diff --git a/sw-server/src/test/kotlin/org/luxons/sevenwonders/server/controllers/LobbyControllerTest.kt b/sw-server/src/test/kotlin/org/luxons/sevenwonders/server/controllers/LobbyControllerTest.kt
index e8b2a9c0..31a3c9c9 100644
--- a/sw-server/src/test/kotlin/org/luxons/sevenwonders/server/controllers/LobbyControllerTest.kt
+++ b/sw-server/src/test/kotlin/org/luxons/sevenwonders/server/controllers/LobbyControllerTest.kt
@@ -35,7 +35,7 @@ class LobbyControllerTest {
val template = mockSimpMessagingTemplate()
playerRepository = PlayerRepository()
lobbyRepository = LobbyRepository()
- lobbyController = LobbyController(lobbyRepository, playerRepository, template)
+ lobbyController = LobbyController(lobbyRepository, playerRepository, template, "UNUSED")
}
@Test
bgstack15