Skip to content

Commit de112ba

Browse files
committed
♻️ refactor: SSE 하트비트 주기 30초로 변경
1 parent c146030 commit de112ba

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

backend/src/main/java/io/f1/backend/domain/game/sse/app/SseService.java

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public class SseService {
2121
private final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
2222

2323
public SseEmitter subscribe() {
24-
SseEmitter emitter = new SseEmitter(5_000L);
24+
SseEmitter emitter = new SseEmitter(1_800_000L);
2525
emitterRepository.save(emitter);
2626

2727
try {
@@ -44,16 +44,12 @@ public <T> void notifyLobbyUpdate(LobbySseEvent<T> event) {
4444
}
4545

4646
private void startHeartBeat(SseEmitter emitter) {
47-
scheduler.scheduleAtFixedRate(
48-
() -> {
49-
try {
50-
emitter.send(SseEmitter.event().name("heartbeat").data("sse-alive"));
51-
} catch (IOException e) {
52-
emitterRepository.remove(emitter);
53-
}
54-
},
55-
5,
56-
60,
57-
TimeUnit.SECONDS);
47+
scheduler.scheduleAtFixedRate(() -> {
48+
try {
49+
emitter.send(SseEmitter.event().name("heartbeat").data("sse-alive"));
50+
} catch (IOException e) {
51+
emitterRepository.remove(emitter);
52+
}
53+
}, 5, 30, TimeUnit.SECONDS);
5854
}
5955
}

0 commit comments

Comments
 (0)