Classroom Video düzenlemesi
This commit is contained in:
parent
8e8bca6c5a
commit
8ffc6f6439
1 changed files with 62 additions and 1 deletions
|
|
@ -264,7 +264,55 @@ const RoomDetail: React.FC = () => {
|
||||||
await webRTCServiceRef.current?.addIceCandidate(fromUserId, candidate)
|
await webRTCServiceRef.current?.addIceCandidate(fromUserId, candidate)
|
||||||
})
|
})
|
||||||
|
|
||||||
// ExistingParticipants handler
|
signalRServiceRef.current.setParticipantJoinHandler(
|
||||||
|
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.getPeerConnection(userId)) {
|
||||||
|
await webRTCServiceRef.current.createPeerConnection(userId)
|
||||||
|
}
|
||||||
|
|
||||||
|
// student → teacher
|
||||||
|
if (user.role === 'student' && isTeacher) {
|
||||||
|
const offer = await webRTCServiceRef.current.createOffer(userId)
|
||||||
|
await signalRServiceRef.current?.sendOffer(classSession.id, userId, offer)
|
||||||
|
}
|
||||||
|
|
||||||
|
// teacher → student
|
||||||
|
if (user.role === 'teacher' && !isTeacher) {
|
||||||
|
const offer = await webRTCServiceRef.current.createOffer(userId)
|
||||||
|
await signalRServiceRef.current?.sendOffer(classSession.id, userId, offer)
|
||||||
|
}
|
||||||
|
|
||||||
|
// teacher ↔ teacher
|
||||||
|
if (user.role === 'teacher' && isTeacher) {
|
||||||
|
if (user.id < userId) {
|
||||||
|
const offer = await webRTCServiceRef.current.createOffer(userId)
|
||||||
|
await signalRServiceRef.current?.sendOffer(classSession.id, userId, offer)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
setParticipants((prev) => {
|
||||||
|
const exists = prev.find((p) => p.id === userId)
|
||||||
|
if (exists) return prev
|
||||||
|
return [
|
||||||
|
...prev,
|
||||||
|
{
|
||||||
|
id: userId,
|
||||||
|
name,
|
||||||
|
isTeacher,
|
||||||
|
isAudioMuted: classSettings.autoMuteNewParticipants,
|
||||||
|
isVideoMuted: classSettings.defaultCameraState === 'off',
|
||||||
|
},
|
||||||
|
]
|
||||||
|
})
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
// 🔑 ExistingParticipants handler
|
// 🔑 ExistingParticipants handler
|
||||||
signalRServiceRef.current.setExistingParticipantsHandler(
|
signalRServiceRef.current.setExistingParticipantsHandler(
|
||||||
async (existing: { userId: string; userName: string; isTeacher: boolean }[]) => {
|
async (existing: { userId: string; userName: string; isTeacher: boolean }[]) => {
|
||||||
|
|
@ -299,6 +347,19 @@ const RoomDetail: React.FC = () => {
|
||||||
offer,
|
offer,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 🔑 Öğretmen ↔ Öğretmen
|
||||||
|
if (user.role === 'teacher' && participant.isTeacher) {
|
||||||
|
// id’si küçük olan offer göndersin
|
||||||
|
if (user.id < participant.userId) {
|
||||||
|
const offer = await webRTCServiceRef.current.createOffer(participant.userId)
|
||||||
|
await signalRServiceRef.current?.sendOffer(
|
||||||
|
classSession.id,
|
||||||
|
participant.userId,
|
||||||
|
offer,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setParticipants((prev) => {
|
setParticipants((prev) => {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue