Rename listeners
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
package eventDemo.app.command
|
||||
|
||||
import eventDemo.app.entity.Player
|
||||
import eventDemo.app.eventListener.GameEventPlayerNotificationListener
|
||||
import eventDemo.app.eventListener.PlayerNotificationEventListener
|
||||
import eventDemo.app.notification.Notification
|
||||
import eventDemo.libs.fromFrameChannel
|
||||
import eventDemo.libs.toObjectChannel
|
||||
@@ -18,7 +18,7 @@ import kotlinx.coroutines.launch
|
||||
|
||||
@DelicateCoroutinesApi
|
||||
fun Route.gameSocket(
|
||||
playerNotificationListener: GameEventPlayerNotificationListener,
|
||||
playerNotificationListener: PlayerNotificationEventListener,
|
||||
commandHandler: GameCommandHandler,
|
||||
) {
|
||||
authenticate {
|
||||
|
||||
@@ -27,7 +27,7 @@ import io.github.oshai.kotlinlogging.KotlinLogging
|
||||
import kotlinx.coroutines.channels.SendChannel
|
||||
import kotlinx.coroutines.channels.trySendBlocking
|
||||
|
||||
class GameEventPlayerNotificationListener(
|
||||
class PlayerNotificationEventListener(
|
||||
private val eventBus: GameEventBus,
|
||||
private val gameStateRepository: GameStateRepository,
|
||||
) {
|
||||
@@ -10,7 +10,7 @@ import eventDemo.app.event.projection.GameState
|
||||
import eventDemo.app.event.projection.GameStateRepository
|
||||
import io.github.oshai.kotlinlogging.KotlinLogging
|
||||
|
||||
class GameEventReactionListener(
|
||||
class ReactionEventListener(
|
||||
private val eventBus: GameEventBus,
|
||||
private val eventHandler: GameEventHandler,
|
||||
private val gameStateRepository: GameStateRepository,
|
||||
@@ -6,7 +6,7 @@ import eventDemo.app.event.GameEventBus
|
||||
import eventDemo.app.event.GameEventHandler
|
||||
import eventDemo.app.event.GameEventStream
|
||||
import eventDemo.app.event.projection.GameStateRepository
|
||||
import eventDemo.app.eventListener.GameEventPlayerNotificationListener
|
||||
import eventDemo.app.eventListener.PlayerNotificationEventListener
|
||||
import eventDemo.libs.command.CommandStreamChannelBuilder
|
||||
import eventDemo.libs.event.EventBusInMemory
|
||||
import eventDemo.libs.event.EventStreamInMemory
|
||||
@@ -41,5 +41,5 @@ val appKoinModule =
|
||||
|
||||
singleOf(::GameEventHandler)
|
||||
singleOf(::GameCommandHandler)
|
||||
singleOf(::GameEventPlayerNotificationListener)
|
||||
singleOf(::PlayerNotificationEventListener)
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package eventDemo.configuration
|
||||
|
||||
import eventDemo.app.eventListener.GameEventReactionListener
|
||||
import eventDemo.app.eventListener.ReactionEventListener
|
||||
import io.ktor.server.application.Application
|
||||
import org.koin.ktor.ext.get
|
||||
|
||||
fun Application.configureGameListener() {
|
||||
GameEventReactionListener(get(), get(), get())
|
||||
ReactionEventListener(get(), get(), get())
|
||||
.init()
|
||||
}
|
||||
|
||||
@@ -2,14 +2,14 @@ package eventDemo.configuration
|
||||
|
||||
import eventDemo.app.command.GameCommandHandler
|
||||
import eventDemo.app.command.gameSocket
|
||||
import eventDemo.app.eventListener.GameEventPlayerNotificationListener
|
||||
import eventDemo.app.eventListener.PlayerNotificationEventListener
|
||||
import io.ktor.server.application.Application
|
||||
import io.ktor.server.routing.routing
|
||||
import kotlinx.coroutines.DelicateCoroutinesApi
|
||||
|
||||
@OptIn(DelicateCoroutinesApi::class)
|
||||
fun Application.declareWebSocketsGameRoute(
|
||||
playerNotificationListener: GameEventPlayerNotificationListener,
|
||||
playerNotificationListener: PlayerNotificationEventListener,
|
||||
commandHandler: GameCommandHandler,
|
||||
) {
|
||||
routing {
|
||||
|
||||
@@ -4,8 +4,8 @@ import eventDemo.app.command.command.GameCommand
|
||||
import eventDemo.app.command.command.IWantToJoinTheGameCommand
|
||||
import eventDemo.app.entity.GameId
|
||||
import eventDemo.app.entity.Player
|
||||
import eventDemo.app.eventListener.GameEventPlayerNotificationListener
|
||||
import eventDemo.app.eventListener.GameEventReactionListener
|
||||
import eventDemo.app.eventListener.PlayerNotificationEventListener
|
||||
import eventDemo.app.eventListener.ReactionEventListener
|
||||
import eventDemo.app.notification.Notification
|
||||
import eventDemo.app.notification.WelcomeToTheGameNotification
|
||||
import eventDemo.configuration.appKoinModule
|
||||
@@ -22,12 +22,12 @@ class GameCommandHandlerTest :
|
||||
test("handle a command should execute the command") {
|
||||
koinApplication { modules(appKoinModule) }.koin.apply {
|
||||
val commandHandler by inject<GameCommandHandler>()
|
||||
val notificationListener by inject<GameEventPlayerNotificationListener>()
|
||||
val notificationListener by inject<PlayerNotificationEventListener>()
|
||||
val gameId = GameId()
|
||||
val player = Player("Tesla")
|
||||
val channelCommand = Channel<GameCommand>(Channel.BUFFERED)
|
||||
val channelNotification = Channel<Notification>(Channel.BUFFERED)
|
||||
GameEventReactionListener(get(), get(), get()).init()
|
||||
ReactionEventListener(get(), get(), get()).init()
|
||||
notificationListener.startListening(channelNotification, player)
|
||||
|
||||
GlobalScope.launch {
|
||||
|
||||
@@ -12,8 +12,8 @@ import eventDemo.app.event.GameEventStream
|
||||
import eventDemo.app.event.event.disableShuffleDeck
|
||||
import eventDemo.app.event.projection.GameState
|
||||
import eventDemo.app.event.projection.buildStateFromEventStream
|
||||
import eventDemo.app.eventListener.GameEventPlayerNotificationListener
|
||||
import eventDemo.app.eventListener.GameEventReactionListener
|
||||
import eventDemo.app.eventListener.PlayerNotificationEventListener
|
||||
import eventDemo.app.eventListener.ReactionEventListener
|
||||
import eventDemo.app.notification.ItsTheTurnOfNotification
|
||||
import eventDemo.app.notification.Notification
|
||||
import eventDemo.app.notification.PlayerAsJoinTheGameNotification
|
||||
@@ -131,8 +131,8 @@ class GameStateTest :
|
||||
koinApplication { modules(appKoinModule) }.koin.apply {
|
||||
val commandHandler by inject<GameCommandHandler>()
|
||||
val eventStream by inject<GameEventStream>()
|
||||
val playerNotificationListener by inject<GameEventPlayerNotificationListener>()
|
||||
GameEventReactionListener(get(), get(), get()).init()
|
||||
val playerNotificationListener by inject<PlayerNotificationEventListener>()
|
||||
ReactionEventListener(get(), get(), get()).init()
|
||||
playerNotificationListener.startListening(channelNotification1, player1)
|
||||
playerNotificationListener.startListening(channelNotification2, player2)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user