Repository navigation
[FEAT] 라이브 공유 사회자 단일 세션 및 사회자 부재 통보 #268
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
f4e7609
[FEAT] 룸별 활성 사회자 세션 레지스트리 추가
coli-geonwoo b76df82
[FEAT] 사회자 중복 연결 차단 및 사회자 부재 즉시 통보
coli-geonwoo 90c05b9
[FIX] 사회자 토큰 최소 유효시간 보장 및 토론 시간 계산 보강
coli-geonwoo eab7410
[FIX] 사회자 채널 구독 권한 검증
coli-geonwoo a230510
[CHORE] CI job 타임아웃 3분에서 15분으로 상향
coli-geonwoo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
src/main/java/com/debatetimer/config/sharing/ChairmanAuthorizer.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| package com.debatetimer.config.sharing; | ||
|
|
||
| import com.debatetimer.controller.tool.jwt.AuthManager; | ||
| import com.debatetimer.domain.member.Member; | ||
| import com.debatetimer.exception.custom.DTClientErrorException; | ||
| import com.debatetimer.exception.errorcode.ClientErrorCode; | ||
| import com.debatetimer.service.auth.AuthService; | ||
| import com.debatetimer.service.customize.CustomizeService; | ||
| import jakarta.annotation.Nullable; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.stereotype.Component; | ||
|
|
||
| /** | ||
| * 사회자 채널 구독 권한을 확인한다. | ||
| * 사회자 채널을 구독하면 룸의 활성 사회자가 될 수 있으므로, 유효한 사회자 토큰을 가진 테이블 소유자만 허용한다. | ||
| */ | ||
| @Component | ||
| @RequiredArgsConstructor | ||
| public class ChairmanAuthorizer { | ||
|
|
||
| private final AuthManager authManager; | ||
| private final AuthService authService; | ||
| private final CustomizeService customizeService; | ||
|
|
||
| public void authorize(@Nullable String chairmanToken, long roomId) { | ||
| if (chairmanToken == null || chairmanToken.isBlank()) { | ||
| throw new DTClientErrorException(ClientErrorCode.UNAUTHORIZED_MEMBER); | ||
| } | ||
| String email = authManager.resolveChairmanToken(chairmanToken); | ||
| Member member = authService.getMember(email); | ||
| customizeService.validateTableOwner(roomId, member); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
src/main/java/com/debatetimer/domain/sharing/ChairmanNoticeType.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| package com.debatetimer.domain.sharing; | ||
|
|
||
| /** | ||
| * 서버가 사회자 채널(`/chairman/{roomId}`)로 보내는 알림 유형 | ||
| */ | ||
| public enum ChairmanNoticeType { | ||
|
|
||
| /** | ||
| * 새 청중이 입장해 현재 상태 공유가 필요하다. | ||
| */ | ||
| SYNC_REQUEST, | ||
|
|
||
| /** | ||
| * 다른 사회자 세션이 활성 사회자가 되어 발행 권한을 잃었다. | ||
| */ | ||
| REPLACED, | ||
| ; | ||
| } |
21 changes: 21 additions & 0 deletions
21
src/main/java/com/debatetimer/domain/sharing/ChairmanTokenExpiration.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| package com.debatetimer.domain.sharing; | ||
|
|
||
| import java.time.Duration; | ||
|
|
||
| /** | ||
| * 사회자 토큰 유효시간 정책 | ||
| * - 토론이 예상보다 길어져도 공유가 끊기지 않도록 전체 토론 시간의 2배를 준다. | ||
| * - 토론 시간이 짧거나 계산할 수 없는 테이블도 충분히 진행할 수 있도록 최소 유효시간을 보장한다. | ||
| */ | ||
| public final class ChairmanTokenExpiration { | ||
|
|
||
| static final Duration MIN_EXPIRATION = Duration.ofHours(3); | ||
| private static final int DEBATE_TIME_MULTIPLIER = 2; | ||
|
|
||
| private ChairmanTokenExpiration() { | ||
| } | ||
|
|
||
| public static long secondsFor(long debateTimeSeconds) { | ||
| return Math.max(debateTimeSeconds * DEBATE_TIME_MULTIPLIER, MIN_EXPIRATION.toSeconds()); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 16 additions & 1 deletion
17
src/main/java/com/debatetimer/dto/sharing/request/ChairmanSharingRequest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,22 @@ | ||
| package com.debatetimer.dto.sharing.request; | ||
|
|
||
| import com.debatetimer.domain.sharing.ChairmanNoticeType; | ||
| import jakarta.annotation.Nullable; | ||
|
|
||
| public record ChairmanSharingRequest( | ||
| long roomId | ||
| ChairmanNoticeType type, | ||
|
|
||
| long roomId, | ||
|
|
||
| @Nullable | ||
| String activeSessionId | ||
| ) { | ||
|
|
||
| public static ChairmanSharingRequest syncRequest(long roomId) { | ||
| return new ChairmanSharingRequest(ChairmanNoticeType.SYNC_REQUEST, roomId, null); | ||
| } | ||
|
|
||
| public static ChairmanSharingRequest replaced(long roomId, String activeSessionId) { | ||
| return new ChairmanSharingRequest(ChairmanNoticeType.REPLACED, roomId, activeSessionId); | ||
| } | ||
| } |
22 changes: 22 additions & 0 deletions
22
src/main/java/com/debatetimer/event/sharing/ChairmanDisconnectListener.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| package com.debatetimer.event.sharing; | ||
|
|
||
| import com.debatetimer.service.sharing.SharingService; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.context.event.EventListener; | ||
| import org.springframework.stereotype.Component; | ||
| import org.springframework.web.socket.messaging.SessionDisconnectEvent; | ||
|
|
||
| /** | ||
| * 사회자의 연결이 끊기면 활성 사회자 등록을 해제해, 이후 입장한 청중이 사회자 부재를 바로 알 수 있게 한다. | ||
| */ | ||
| @Component | ||
| @RequiredArgsConstructor | ||
| public class ChairmanDisconnectListener { | ||
|
|
||
| private final SharingService sharingService; | ||
|
|
||
| @EventListener | ||
| public void handleDisconnect(SessionDisconnectEvent event) { | ||
| sharingService.leave(event.getSessionId()); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.