Add Comments
This commit is contained in:
@@ -31,6 +31,9 @@ class GameRoute(
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* API route to send a request to play card.
|
||||
*/
|
||||
fun Routing.playNewCard() {
|
||||
val commandStream by inject<GameCommandStream>()
|
||||
|
||||
|
||||
@@ -7,6 +7,9 @@ import eventDemo.shared.entity.Game
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
/**
|
||||
* A command to perform an action to play a new card
|
||||
*/
|
||||
@Serializable
|
||||
@SerialName("PlayCard")
|
||||
data class PlayCardCommand(
|
||||
|
||||
@@ -9,13 +9,17 @@ import kotlinx.coroutines.launch
|
||||
|
||||
/**
|
||||
* Listen [PlayCardCommand] on [GameCommandStream], check the validity and execute the action.
|
||||
*
|
||||
* This action produces a new [CardIsPlayedEvent]
|
||||
*/
|
||||
class PlayCardCommandHandler(
|
||||
private val commandStream: GameCommandStream,
|
||||
private val eventStream: GameEventStream,
|
||||
) {
|
||||
operator fun invoke() {
|
||||
/**
|
||||
* Init the handler
|
||||
*/
|
||||
fun init() {
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
commandStream.process {
|
||||
// TODO check the command can be executed
|
||||
|
||||
@@ -27,6 +27,9 @@ class Game(
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* API route to read the last card played.
|
||||
*/
|
||||
fun Routing.readLastPlayedCard() {
|
||||
val eventStream by inject<GameEventStream>()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user