Skip to content

Commit fae956e

Browse files
committed
[FE] feat: 나간 유저에 대한 정보를 subscribe 및 불필요한 로직 개선 (#74)
1 parent c6011e3 commit fae956e

File tree

3 files changed

+10
-848
lines changed

3 files changed

+10
-848
lines changed

src/frontend/src/pages/ChannelPage/hooks/useStompWebRTC.ts

-92
This file was deleted.

src/frontend/src/pages/ChannelPage/index.tsx

+10-17
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import React, { useEffect, useRef, useState } from 'react';
33

44
import { getUserId } from '@/api/users';
55
import { useChannelActionStore } from '@/stores/channelAction';
6-
import { tokenAxios } from '@/utils/axios';
76
import { useUserInfoStore } from '@/stores/userInfo';
7+
import { tokenAxios } from '@/utils/axios';
88

99
const SERVER_URL = import.meta.env.VITE_SIGNALING;
1010

@@ -124,6 +124,11 @@ const WebRTC = () => {
124124
});
125125
});
126126

127+
client.subscribe(`/topic/removed/${roomId}`, (message) => {
128+
const recentUsers = JSON.parse(message.body);
129+
console.log('recentUsers', recentUsers);
130+
});
131+
127132
console.log(`✅ 구독 성공 하였습니다.`);
128133
},
129134
onDisconnect: () => {
@@ -223,9 +228,9 @@ const WebRTC = () => {
223228
};
224229

225230
// ✅ kurento ice 수집 요청
226-
const sendGetherIceCandidate = async () => {
231+
const sendGatherIceCandidate = async () => {
227232
if (!stompClient.current) {
228-
alert('gether STOMP WebSocket이 연결되지 않았습니다.');
233+
alert('gather STOMP WebSocket이 연결되지 않았습니다.');
229234
return;
230235
}
231236

@@ -235,15 +240,14 @@ const WebRTC = () => {
235240
destination: '/gather/candidate',
236241
body: JSON.stringify({
237242
data: {
238-
// ✅ data 내부에 room_id 포함
239243
room_id: roomId,
240244
},
241245
}),
242246
});
243247

244248
sendIceCandidates(); // 🔥 SDP Answer 수신 후 ICE Candidate 전송
245249
} catch (error) {
246-
console.error('Gether 요청 실패:', error);
250+
console.error('gather 요청 실패:', error);
247251
}
248252
};
249253

@@ -261,19 +265,8 @@ const WebRTC = () => {
261265
} catch (error) {
262266
console.error('Answer 요청 실패:', error);
263267
} finally {
264-
sendGetherIceCandidate();
265-
// sendIceCandidates();
268+
sendGatherIceCandidate();
266269
}
267-
268-
// sendGetherIceCandidate();
269-
};
270-
271-
// 예시: 특정 사용자(userId)의 remote stream을 업데이트
272-
const handleRemoteStream = (userId: string, stream: MediaStream) => {
273-
setRemoteStreams((prev) => ({
274-
...prev,
275-
[userId]: stream,
276-
}));
277270
};
278271

279272
// ✅ WebRTC Users 처리

0 commit comments

Comments
 (0)