Changed at how the run command starts TUI GUI and the server. This is neccessary so that TUI GUI and server start and the game from the TUI/GUI is registered in the server.
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
package de.nowchess.server
|
||||
|
||||
import cats.effect.IO
|
||||
import cats.effect.unsafe.implicits.global
|
||||
import com.comcast.ip4s.{host, port}
|
||||
import de.nowchess.api.player.{PlayerId, PlayerInfo}
|
||||
import de.nowchess.chess.engine.GameEngine
|
||||
import org.http4s.ember.server.EmberServerBuilder
|
||||
|
||||
object ServerLauncher:
|
||||
def start(engine: GameEngine): String =
|
||||
val white = PlayerInfo(PlayerId("white"), "Player 1")
|
||||
val black = PlayerInfo(PlayerId("black"), "Player 2")
|
||||
(for
|
||||
registry <- GameRegistry.make
|
||||
_ <- EmberServerBuilder
|
||||
.default[IO]
|
||||
.withHost(host"0.0.0.0")
|
||||
.withPort(port"8080")
|
||||
.withHttpApp(BoardRoutes(registry).routes.orNotFound)
|
||||
.build
|
||||
.useForever
|
||||
.start
|
||||
gameId <- registry.add(GameEntry(engine, white, black))
|
||||
yield gameId).unsafeRunSync()
|
||||
Reference in New Issue
Block a user