Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DRAW-416 빠른 매칭 유저 중복 등록 오류 수정 #18

Merged
merged 4 commits into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.xorker.draw.mafia

import com.xorker.draw.exception.AlreadyWaitingUserException
import com.xorker.draw.exception.UnSupportedException
import com.xorker.draw.user.User
import java.util.concurrent.ConcurrentHashMap
Expand All @@ -16,6 +17,9 @@ internal class MafiaGameWaitingQueueAdapter : MafiaGameWaitingQueueRepository {

override fun enqueue(user: User, locale: String) {
val queue = waitingQueue.getOrPut(locale) { ConcurrentLinkedQueue() }

queue.forEach { if (it.id == user.id) throw AlreadyWaitingUserException }

queue.add(user)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ fun XorkerException.getButtons(): List<ExceptionButtonType> {
AlreadyLinkedAccountException,
NotFoundLockKeyException,
AlreadyPlayingPlayerException,
AlreadyWaitingUserException,
-> buttonOk
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ internal class MafiaGameInfoWebSocketListener(
mafiaGameMessenger.broadcastPlayerList(gameInfo)
}

if (gameInfo.room.isRandomMatching) {
if (gameInfo.room.isRandomMatching && gameInfo.phase is MafiaPhase.End) {
for (player in gameInfo.room.players) {
val session = sessionManager.getSession(player.userId) ?: continue
session.origin.close()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ data object AlreadyJoinRoomException : ClientException("c005", "이미 참여한
data object InvalidRequestOnlyMyTurnException : ClientException("c006", "요청자의 차례가 아니라서 처리 불가능") { private fun readResolve(): Any = InvalidRequestOnlyMyTurnException }
data object InvalidRequestOtherPlayingException : ClientException("c007", "진행 중인 게임 방이 있습니다.") { private fun readResolve(): Any = InvalidRequestOtherPlayingException }
data object AlreadyPlayingRoomException : ClientException("c008", "진행 중인 게임 방에는 참여할 수 없습니다.") { private fun readResolve(): Any = AlreadyPlayingRoomException }
data object AlreadyPlayingPlayerException : ClientException("c010", "한 유저가 여러번 접속 시도를 하고 있습니다.") { private fun readResolve(): Any = AlreadyPlayingPlayerException }
data object AlreadyLinkedAccountException : ClientException("c009", "이미 소셜 계정이 연동되어 있습니다.") { private fun readResolve(): Any = AlreadyLinkedAccountException }
data object AlreadyPlayingPlayerException : ClientException("c010", "한 유저가 여러번 접속 시도를 하고 있습니다.") { private fun readResolve(): Any = AlreadyPlayingPlayerException }
data object AlreadyWaitingUserException : ClientException("c011", "이미 빠른 게임 대기열에 등록된 유저입니다.") { private fun readResolve(): Any = AlreadyWaitingUserException }

//endregion

Expand Down
Loading