Classroom Videoplayer kısımları düzeltildi3
This commit is contained in:
parent
79b0aa42e3
commit
25da8570e0
3 changed files with 50 additions and 2 deletions
|
|
@ -7,6 +7,7 @@ using Kurs.Platform.Entities;
|
|||
using Microsoft.Extensions.Logging;
|
||||
using Volo.Abp.Guids;
|
||||
using Volo.Abp.Users;
|
||||
using System.Linq;
|
||||
|
||||
namespace Kurs.Platform.Classrooms;
|
||||
|
||||
|
|
@ -82,6 +83,20 @@ public class ClassroomHub : Hub
|
|||
|
||||
await Groups.AddToGroupAsync(Context.ConnectionId, sessionId.ToString());
|
||||
|
||||
// 🔑 Yeni katılana mevcut katılımcıları gönder
|
||||
var existingParticipants = await _participantRepository.GetListAsync(x => x.SessionId == sessionId);
|
||||
var others = existingParticipants
|
||||
.Where(x => x.ConnectionId != Context.ConnectionId)
|
||||
.Select(x => new
|
||||
{
|
||||
UserId = x.UserId,
|
||||
UserName = x.UserName,
|
||||
IsTeacher = x.IsTeacher
|
||||
})
|
||||
.ToList();
|
||||
|
||||
await Clients.Caller.SendAsync("ExistingParticipants", others);
|
||||
|
||||
await Clients.Group(sessionId.ToString())
|
||||
.SendAsync("ParticipantJoined", userId, userName);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -383,6 +383,10 @@ export class SignalRService {
|
|||
await this.connection.invoke('SendIceCandidate', sessionId, targetUserId, candidate)
|
||||
}
|
||||
|
||||
setExistingParticipantsHandler(callback: (participants: any[]) => void) {
|
||||
this.connection.on('ExistingParticipants', callback)
|
||||
}
|
||||
|
||||
setAttendanceUpdatedHandler(callback: (record: ClassroomAttendanceDto) => void) {
|
||||
this.onAttendanceUpdate = callback
|
||||
}
|
||||
|
|
|
|||
|
|
@ -274,7 +274,7 @@ const RoomDetail: React.FC = () => {
|
|||
webRTCServiceRef.current.createPeerConnection(userId)
|
||||
|
||||
// ✅ Sadece teacher offer gönderecek
|
||||
if (user.role === 'student') {
|
||||
if (user.role === 'teacher') {
|
||||
const offer = await webRTCServiceRef.current.createOffer(userId)
|
||||
await signalRServiceRef.current?.sendOffer(classSession.id, userId, offer)
|
||||
}
|
||||
|
|
@ -296,6 +296,35 @@ const RoomDetail: React.FC = () => {
|
|||
})
|
||||
})
|
||||
|
||||
signalRServiceRef.current.setExistingParticipantsHandler(async (existing) => {
|
||||
console.log('Existing participants:', existing)
|
||||
|
||||
if (webRTCServiceRef.current) {
|
||||
for (const p of existing) {
|
||||
// Peer connection oluştur
|
||||
await webRTCServiceRef.current?.createPeerConnection(p.userId)
|
||||
|
||||
// Eğer ben öğretmensem → herkese offer gönder
|
||||
if (user.role === 'teacher') {
|
||||
const offer = await webRTCServiceRef.current.createOffer(p.userId)
|
||||
await signalRServiceRef.current?.sendOffer(classSession.id, p.userId, offer)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// State güncelle
|
||||
setParticipants((prev) => [
|
||||
...prev,
|
||||
...existing.map((p) => ({
|
||||
id: p.userId,
|
||||
name: p.userName,
|
||||
isTeacher: p.isTeacher,
|
||||
isAudioMuted: classSettings.autoMuteNewParticipants,
|
||||
isVideoMuted: classSettings.defaultCameraState === 'off',
|
||||
})),
|
||||
])
|
||||
})
|
||||
|
||||
signalRServiceRef.current.setParticipantLeaveHandler((userId) => {
|
||||
console.log(`Participant left: ${userId}`)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue