Classroom Videoplayer kısımları düzeltildi

This commit is contained in:
Sedat Öztürk 2025-08-30 01:38:32 +03:00
parent 3587446042
commit 29da0f2ea4

View file

@ -305,42 +305,35 @@ const RoomDetail: React.FC = () => {
) )
// Existing participants handler // Existing participants handler
signalRServiceRef.current.setExistingParticipantsHandler(async (existing) => { signalRServiceRef.current.setParticipantJoinHandler(
console.log('Existing participants:', existing) async (userId: string, name: string, isTeacher: boolean) => {
if (userId === user.id) return
console.log(`Participant joined: ${name}, isTeacher: ${isTeacher}`)
if (webRTCServiceRef.current) { if (webRTCServiceRef.current) {
for (const p of existing) { // 👇 duplicate connection engelle
const id = p.userId || p.UserId if (!webRTCServiceRef.current.getPeerConnection(userId)) {
const name = p.userName || p.UserName await webRTCServiceRef.current.createPeerConnection(userId)
const isTeacher = p.isTeacher ?? p.IsTeacher
await webRTCServiceRef.current.createPeerConnection(id)
// öğrenci → öğretmen
if (user.role === 'student' && isTeacher) {
const offer = await webRTCServiceRef.current.createOffer(id)
await signalRServiceRef.current?.sendOffer(classSession.id, id, offer)
}
// öğretmen → öğrenci
if (user.role === 'teacher' && !isTeacher) {
const offer = await webRTCServiceRef.current.createOffer(id)
await signalRServiceRef.current?.sendOffer(classSession.id, id, offer)
}
} }
} }
setParticipants((prev) => [ setParticipants((prev) => {
const existing = prev.find((p) => p.id === userId)
if (existing) return prev
return [
...prev, ...prev,
...existing.map((p) => ({ {
id: p.userId || p.UserId, id: userId,
name: p.userName || p.UserName, name,
isTeacher: p.isTeacher ?? p.IsTeacher, isTeacher,
isAudioMuted: classSettings.autoMuteNewParticipants, isAudioMuted: classSettings.autoMuteNewParticipants,
isVideoMuted: classSettings.defaultCameraState === 'off', isVideoMuted: classSettings.defaultCameraState === 'off',
})), },
]) ]
}) })
},
)
signalRServiceRef.current.setParticipantLeaveHandler((userId) => { signalRServiceRef.current.setParticipantLeaveHandler((userId) => {
console.log(`Participant left: ${userId}`) console.log(`Participant left: ${userId}`)