-
Notifications
You must be signed in to change notification settings - Fork 7
5. Turn Process
TODO: Introduction to TTTServer/GameStream process turns
XXXXXX Commit 32 here
|
---|
TODO: Exposition of the exercise 22
In previous exercises, we prepared the WebSocket to listening to the Game events, and that way, the app reacts accordingly.
But it's shown in the next diagram, we are not propagating the Msg.RequestNewMovement
to the server via the
WebSocket.
In the file ScalaDaysClient.scala
, implement the method:
def publishWs(playerId: PlayerId, gameId: GameId, movement: Movement, ws: WebSocket[F]): Cmd[F, Msg]
taking into account the following tips:
Tip 1: WS.publish
Tyrian.WebSocket
implements the functiondef publish[Msg](message: String): Cmd[F, Msg]
Tip 2:
ClientAction
The
ClientAction
that the server expects isTurn
.
Tip 3:
Turn
encoder
turn.asJson.noSpacesSortKeys
encodes aTurn
into aString
In the file Update.scala
, please react to the event Msg.RequestNewMovement(game, newMovement)
.
Tip 1: New Model
The Model evolves with a new Game, which has the state
GameState.Processing
and the list of movements includes thenewMovement
Tip 2: New Cmd
We have to publish the new movement via WebSocket by calling
scalaDaysClient.publishWs(playerId, game.gameId, newMovement, ws)
TODO: Introduction to Client implement restart game
TODO: Exposition of the exercise 24