summaryrefslogtreecommitdiff
path: root/sw-server/src/main/kotlin
diff options
context:
space:
mode:
authorJoffrey Bion <joffrey.bion@booking.com>2020-05-24 17:03:53 +0200
committerJoffrey Bion <joffrey.bion@booking.com>2020-05-24 17:03:53 +0200
commit197b7c568e02a35817d1e767cf5bbbda114958ea (patch)
tree31c4cdc74720c0a5066f2a7758f711128684a122 /sw-server/src/main/kotlin
parentAttempt at fixing mixed content ws call (diff)
downloadseven-wonders-197b7c568e02a35817d1e767cf5bbbda114958ea.tar.gz
seven-wonders-197b7c568e02a35817d1e767cf5bbbda114958ea.tar.bz2
seven-wonders-197b7c568e02a35817d1e767cf5bbbda114958ea.zip
Remove hardcoded port in bot
Diffstat (limited to 'sw-server/src/main/kotlin')
-rw-r--r--sw-server/src/main/kotlin/org/luxons/sevenwonders/server/controllers/LobbyController.kt9
1 files changed, 7 insertions, 2 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 cdb636fb..e4536df7 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,6 +20,7 @@ import org.springframework.validation.annotation.Validated
import java.security.Principal
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
+import org.springframework.core.env.Environment
/**
* Handles actions in the game's lobby. The lobby is the place where players gather before a game.
@@ -29,8 +30,12 @@ import kotlinx.coroutines.launch
class LobbyController @Autowired constructor(
private val lobbyRepository: LobbyRepository,
private val playerRepository: PlayerRepository,
- private val template: SimpMessagingTemplate
+ private val template: SimpMessagingTemplate,
+ private val environment: Environment
) {
+ private val serverPort: String
+ get() = environment.getProperty("server.port")
+
private val Principal.player: Player
get() = playerRepository.find(name)
@@ -87,7 +92,7 @@ class LobbyController @Autowired constructor(
val lobby = principal.player.ownedLobby
val bot = SevenWondersBot(action.botDisplayName)
GlobalScope.launch {
- bot.play("localhost:8000", lobby.id)
+ bot.play("ws://localhost:$serverPort", lobby.id)
}
logger.info("Added bot {} to game '{}'", action.botDisplayName, lobby.name)
bgstack15