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

fix: 테스트를 위한 빌드업 #39

Merged
merged 1 commit into from
Aug 15, 2023
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
Expand Up @@ -34,14 +34,14 @@ public void add(String teamBuildingUuid, SseEmitter emitter) {
emitterList.add(emitter);
emitterMap.put(teamBuildingUuid, emitterList);

log.info("new emitter added: {}", emitter);
log.info("new emitter added: {}, {}", teamBuildingUuid, emitter);
log.info("emitter list size: {}", emitterList.size());
emitter.onCompletion(() -> {
log.info("onCompletion callback");
log.info("onCompletion callback : {}", emitter);
emitterList.remove(emitter);
});
emitter.onTimeout(() -> {
log.info("onTimeout callback");
log.info("onTimeout callback : {}", emitter);
emitterList.remove(emitter);
});
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.nexters.moyeomoyeo.notification.service;

import com.nexters.moyeomoyeo.notification.handler.SseEmitterHandler;
import java.io.IOException;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
Expand All @@ -12,7 +11,8 @@
@RequiredArgsConstructor
public class NotificationService {

private static final Long DEFAULT_TIMEOUT = 60L * 1000 * 30;
//TODO 시간 원복
private static final Long DEFAULT_TIMEOUT = 60L * 1000 * 1;

private final SseEmitterHandler handler;

Expand All @@ -21,15 +21,15 @@ public void sendNotification(SseEmitter emitter, String name, Object data) {
emitter.send(SseEmitter.event()
.name(name)
.data(data));
} catch (IOException e) {
} catch (Exception e) {
log.error("fail to send message : {}", emitter);
}
}

public SseEmitter subscribe(String teamBuildingUuid) {
final SseEmitter emitter = new SseEmitter(DEFAULT_TIMEOUT);
sendNotification(emitter, "subscribe", "subscribe completed");
handler.add(teamBuildingUuid, emitter);
sendNotification(emitter, "subscribe", "subscribe completed");

return emitter;
}
Expand Down