Skip to content

feat: 알림 실시간 수신 (SSE 클라이언트) - #94

Merged
RosieOh merged 1 commit into
mainfrom
feat/notification-stream
Sep 22, 2026
Merged

RosieOh merged 1 commit into
mainfrom
feat/notification-stream

Conversation

@RosieOh

@RosieOh RosieOh commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

Closes #93
서버: CareCode-Repo/CareCode_Interface#117 (서버 PR 을 먼저 배포해야 연결된다. 서버가 없으면 404 로 실패하고 30초 간격으로 재시도만 한다 — 화면에는 영향 없음)

변경

  • apis/notificationStream.ts — fetch 스트림 + SseParser
  • NotificationStreamListener — 루트 레이아웃에 마운트, 이벤트 수신 시 notificationQueries 무효화, 지수 백오프 재연결
  • 새 의존성 없음

테스트

  • notificationStream.test.ts — 서버가 실제로 보낸 바이트(로컬 Tomcat 에서 캡처)로 파싱, 7바이트 조각 입력, CRLF·공백
  • typecheck, lint, 198 tests 통과

서버 GET /notifications/stream 에 연결해 새 알림이 오면 알림 목록·배지를 다시 불러온다.

- EventSource 는 Authorization 헤더를 못 붙이므로(토큰은 메모리에만 있다) fetch 스트림으로 읽는다.
- SseParser: 조각난 네트워크 입력을 이벤트 단위로 모은다. heartbeat 주석은 건너뛴다.
- 이벤트 내용을 캐시에 끼워 넣지 않고 목록을 다시 불러온다 — 끊긴 사이의 알림도 connected 때 채워지고,
  같은 알림을 두 번 받아도 두 번 보이지 않는다.
- 끊기면 1초부터 최대 30초까지 늘려 가며 재연결. 로그인 전에는 연결하지 않는다.
@RosieOh
RosieOh merged commit bdb60ac into main Sep 22, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ 알림 ] 실시간 알림 수신 (SSE 클라이언트)

1 participant