Skip to content

Commit de8b3b2

Browse files
committed
✨ feat : Room에 타이머 업데이트 해주기
1 parent 0b2689e commit de8b3b2

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

backend/src/main/java/io/f1/backend/domain/game/app/TimerService.java

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,15 @@ public class TimerService {
2727

2828
public void startTimer(Room room, int delaySec) {
2929
cancelTimer(room);
30-
ScheduledFuture<?> timer = room.getTimer();
31-
timer =
32-
room.getScheduler()
33-
.schedule(
34-
() -> {
35-
handleTimeout(room);
36-
},
37-
delaySec + room.getGameSetting().getTimeLimit(),
38-
TimeUnit.SECONDS);
30+
31+
ScheduledFuture<?> timer = room.getScheduler().schedule(() -> {
32+
handleTimeout(room);
33+
}, delaySec + room.getGameSetting().getTimeLimit(), TimeUnit.SECONDS);
34+
35+
room.updateTimer(timer);
3936
}
4037

4138
private void handleTimeout(Room room) {
42-
4339
String destination = getDestination(room.getId());
4440

4541
messageSender.send(

backend/src/main/java/io/f1/backend/domain/game/model/GameSetting.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public class GameSetting {
1111

1212
private Long quizId;
1313
private Integer round; // 게임 변경 시 해당 게임의 총 문제 수로 설정
14-
private int timeLimit = 60;
14+
private int timeLimit;
1515

1616
public boolean validateQuizId(Long quizId) {
1717
return Objects.equals(this.quizId, quizId);

backend/src/main/java/io/f1/backend/domain/game/model/Room.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ public void updateRoomState(RoomState newState) {
6363
this.state = newState;
6464
}
6565

66+
public void updateTimer(ScheduledFuture<?> timer) {
67+
this.timer = timer;
68+
}
69+
6670
public void removeUserId(Long id) {
6771
this.userIdSessionMap.remove(id);
6872
}

0 commit comments

Comments
 (0)