Skip to content

Commit

Permalink
DRAW-275 feat: 빠른 시작 대기열 & 게임 시작 웹훅 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
SunwoongH committed Sep 5, 2024
1 parent c0d40a3 commit 7448064
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ dependencies {
implementation(project(":adapter:memory"))
implementation(project(":adapter:oauth"))
implementation(project(":adapter:rdb"))
implementation(project(":adapter:webhook:discord"))
implementation(project(":support:jwt"))
implementation(project(":support:time"))

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.xorker.draw.mafia

import com.xorker.draw.exception.InvalidRequestOtherPlayingException
import com.xorker.draw.notify.NotifyRepository
import com.xorker.draw.notify.NotifyType
import com.xorker.draw.websocket.WaitingQueueSession
import com.xorker.draw.websocket.WaitingQueueSessionEventListener
import org.springframework.stereotype.Service
Expand All @@ -10,6 +12,7 @@ internal class MafiaGameRandomMatchingService(
private val mafiaGameUseCase: MafiaGameUseCase,
private val mafiaGameWaitingQueueRepository: MafiaGameWaitingQueueRepository,
private val mafiaGameMessenger: MafiaGameMessenger,
private val notifyRepository: NotifyRepository,
) : WaitingQueueSessionEventListener {

override fun connectSession(session: WaitingQueueSession) {
Expand All @@ -22,6 +25,8 @@ internal class MafiaGameRandomMatchingService(
mafiaGameWaitingQueueRepository.enqueue(4, session)

mafiaGameMessenger.unicastRandomMatching(user.id)

notifyRepository.notifyMessage(NotifyType.DiscordRandomMatchingNotifyType(user.name, session.locale))
}

override fun exitSession(session: WaitingQueueSession) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package com.xorker.draw.mafia.phase
import com.xorker.draw.mafia.MafiaGameInfo
import com.xorker.draw.mafia.MafiaKeywordRepository
import com.xorker.draw.mafia.MafiaPhase
import com.xorker.draw.notify.NotifyRepository
import com.xorker.draw.notify.NotifyType
import com.xorker.draw.timer.TimerRepository
import org.springframework.stereotype.Component
import kotlin.random.Random
Expand All @@ -11,6 +13,7 @@ import kotlin.random.Random
internal class MafiaPhaseStartGameProcessor(
private val mafiaKeywordRepository: MafiaKeywordRepository,
private val timerRepository: TimerRepository,
private val notifyRepository: NotifyRepository,
) {
private val random: Random = Random(System.currentTimeMillis())

Expand All @@ -34,6 +37,8 @@ internal class MafiaPhaseStartGameProcessor(
)
gameInfo.phase = phase

notifyRepository.notifyMessage(NotifyType.DiscordStartGameNotifyType(room.id, room.locale))

return phase
}
}

0 comments on commit 7448064

Please sign in to comment.