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
if (webRTCServiceRef.current) { console.log(`Participant joined: ${name}, isTeacher: ${isTeacher}`)
for (const p of existing) {
const id = p.userId || p.UserId
const name = p.userName || p.UserName
const isTeacher = p.isTeacher ?? p.IsTeacher
await webRTCServiceRef.current.createPeerConnection(id) if (webRTCServiceRef.current) {
// 👇 duplicate connection engelle
// öğrenci → öğretmen if (!webRTCServiceRef.current.getPeerConnection(userId)) {
if (user.role === 'student' && isTeacher) { await webRTCServiceRef.current.createPeerConnection(userId)
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) => {
...prev, const existing = prev.find((p) => p.id === userId)
...existing.map((p) => ({ if (existing) return prev
id: p.userId || p.UserId, return [
name: p.userName || p.UserName, ...prev,
isTeacher: p.isTeacher ?? p.IsTeacher, {
isAudioMuted: classSettings.autoMuteNewParticipants, id: userId,
isVideoMuted: classSettings.defaultCameraState === 'off', name,
})), isTeacher,
]) isAudioMuted: classSettings.autoMuteNewParticipants,
}) isVideoMuted: classSettings.defaultCameraState === 'off',
},
]
})
},
)
signalRServiceRef.current.setParticipantLeaveHandler((userId) => { signalRServiceRef.current.setParticipantLeaveHandler((userId) => {
console.log(`Participant left: ${userId}`) console.log(`Participant left: ${userId}`)