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