Skip to content

Commit 374dca5

Browse files
committed
feat : 알림 웹 소켓 구현 (#18)
1 parent d0ea9a2 commit 374dca5

File tree

3 files changed

+4
-28
lines changed

3 files changed

+4
-28
lines changed

src/pages/Home.jsx

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -71,30 +71,6 @@ useEffect(() => {
7171
}
7272
};
7373
}, []);
74-
75-
// useEffect(() => {
76-
// const fetchNotifications = async () => {
77-
// try {
78-
// const response = await fetch('/api/notifications', { credentials: 'include' });
79-
// if (!response.ok) {
80-
// throw new Error('알림 데이터를 가져오는데 실패했습니다');
81-
// }
82-
83-
// const data = await response.json();
84-
// console.log(data.data);
85-
// setNotifications(data.data);
86-
87-
// // 새로운 알림이 있는지 확인
88-
// if (data.length > 0) {
89-
// setHasNewNotification(true);
90-
// }
91-
// } catch (error) {
92-
// console.error('알림 데이터 가져오기 오류:', error);
93-
// }
94-
// };
95-
96-
// fetchNotifications();
97-
// }, []);
9874

9975
useEffect(() => {
10076
const fetchCommitData = async () => {

src/services/NotiService.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,16 +63,16 @@ const NotiService = {
6363
getNotis: async () => {
6464
try {
6565
const url = `/api/notifications`;
66-
console.log('Fetching messages from:', url);
66+
console.log('Fetching Notis from:', url);
6767
const response = await apiClient.get(url);
6868
console.log('Noti response:', response);
6969
return response;
7070
} catch (error) {
71-
console.error('Error fetching messages:', error);
71+
console.error('Error fetching Notis:', error);
7272

7373
// 다른 종류의 에러인 경우 빈 메시지 목록 반환
7474
if (error.status === 500) {
75-
console.log('Server error, returning empty messages');
75+
console.log('Server error, returning empty Notis');
7676
return {
7777
success: true,
7878
message: "알림을 불러오는데 문제가 발생했습니다.",

src/services/WebSocketService.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ class WebSocketService {
236236
try {
237237
console.log('Subscribing to notification channel...');
238238

239-
const notificationSubscription = this.stompClient.subscribe(`/sub/notification`, (message) => {
239+
const notificationSubscription = this.stompClient.subscribe(`/topic/notification`, (message) => {
240240
try {
241241
console.log('Received notification:', message);
242242
const notification = JSON.parse(message.body);

0 commit comments

Comments
 (0)