Skip to content

Commit

Permalink
Merge pull request #51 from rosieisor/main
Browse files Browse the repository at this point in the history
update: 사용자 아이디로 실시간 알림 구독 기능 추가
  • Loading branch information
rosieisor authored Mar 13, 2024
2 parents bcede4f + 1090572 commit b6f921d
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,12 @@ public void sendData(@RequestParam(value = "token", required = false) String tok
notificationService.notify(userId, "data");
}

@GetMapping(value = "/subscribe/{userId}", produces = MediaType.TEXT_EVENT_STREAM_VALUE)
@ApiOperation(value = "클라이언트에서 구독하기 위한 subscribe 메서드 / 로그인 시 사용")
@ApiImplicitParam(name = "lastEventId", value = "SSE 연결이 끊겼을 때, 클라이언트가 수신한 마지막 데이터의 id")
public SseEmitter subscribeByUserId(@PathVariable String userId,
@RequestHeader(value = "Last-Event-ID", required = false, defaultValue = "") String lastEventId) {
return notificationService.subscribe(userId, lastEventId);
}

}

0 comments on commit b6f921d

Please sign in to comment.