Hata bulunamadı Loglar dahil edildi.
This commit is contained in:
parent
e042fc49bd
commit
bbd2f338b6
3 changed files with 24 additions and 9 deletions
|
|
@ -117,6 +117,8 @@ public class ClassroomHub : Hub
|
|||
[HubMethodName("JoinClass")]
|
||||
public async Task JoinClassAsync(Guid sessionId, Guid userId, string userName, bool isTeacher, bool isActive)
|
||||
{
|
||||
_logger.LogInformation("🔵 JoinClass çağrıldı: User={UserId}, Session={SessionId}, IsTeacher={IsTeacher}", userId, sessionId, isTeacher);
|
||||
|
||||
var classroom = await _classSessionRepository.GetAsync(sessionId);
|
||||
if (classroom == null)
|
||||
{
|
||||
|
|
@ -398,14 +400,17 @@ public class ClassroomHub : Hub
|
|||
x => x.SessionId == sessionId && x.UserId == participantId
|
||||
);
|
||||
|
||||
_logger.LogInformation("👢 KickParticipant çağrıldı: Session={SessionId}, Target={ParticipantId}", sessionId, participantId);
|
||||
|
||||
if (participant == null)
|
||||
{
|
||||
_logger.LogWarning(
|
||||
"KickParticipant: Session {SessionId} için participant {ParticipantId} bulunamadı",
|
||||
sessionId, participantId);
|
||||
_logger.LogWarning("⚠️ KickParticipant: participant bulunamadı (Session={SessionId}, Target={ParticipantId})", sessionId, participantId);
|
||||
return;
|
||||
}
|
||||
|
||||
_logger.LogInformation("✅ Kick öncesi durum: IsActive={IsActive}, IsKicked={IsKicked}, ConnId={ConnId}", participant.IsActive, participant.IsKicked, participant.ConnectionId);
|
||||
|
||||
|
||||
// ConnectionId'yi cache et (null yazmadan önce)
|
||||
var connectionId = participant.ConnectionId;
|
||||
|
||||
|
|
@ -519,6 +524,8 @@ public class ClassroomHub : Hub
|
|||
return;
|
||||
}
|
||||
|
||||
_logger.LogInformation("🔴 OnDisconnectedAsync: User={UserId}, ConnId={ConnId}, Exception={Exception}", userId, Context.ConnectionId, exception?.Message);
|
||||
|
||||
// 🔑 Aynı anda birden fazla session olabilir (tab senaryosu)
|
||||
var participants = await _participantRepository
|
||||
.GetListAsync(x => x.UserId == userId.Value && x.ConnectionId == Context.ConnectionId);
|
||||
|
|
|
|||
|
|
@ -102,7 +102,8 @@ export class SignalRService {
|
|||
|
||||
this.connection.onreconnected(async () => {
|
||||
this.isConnected = true
|
||||
console.warn('🔄 SignalR reconnected')
|
||||
console.log("🔄 SignalR reconnected. currentSessionId=", this.currentSessionId)
|
||||
|
||||
toast.push(<Notification title="🔄 Bağlantı tekrar kuruldu" type="success" />, {
|
||||
placement: 'top-center',
|
||||
})
|
||||
|
|
@ -115,7 +116,7 @@ export class SignalRService {
|
|||
})
|
||||
|
||||
this.connection.onclose(async (err) => {
|
||||
console.warn('🔥 onclose triggered, isKicked=', this.isKicked)
|
||||
console.warn("🔥 onclose triggered", { isKicked: this.isKicked, error: err })
|
||||
|
||||
if (this.isKicked) {
|
||||
toast.push(
|
||||
|
|
@ -158,7 +159,8 @@ export class SignalRService {
|
|||
})
|
||||
|
||||
this.connection.on('ForceDisconnect', async (message: string) => {
|
||||
console.warn('🚨 ForceDisconnect geldi:', message)
|
||||
console.warn("🚨 ForceDisconnect event alındı", message)
|
||||
|
||||
this.isKicked = true
|
||||
toast.push(<Notification title={`❌ Sınıftan çıkarıldınız: ${message}`} type="danger" />, {
|
||||
placement: 'top-center',
|
||||
|
|
@ -191,6 +193,8 @@ export class SignalRService {
|
|||
|
||||
async start(): Promise<void> {
|
||||
try {
|
||||
console.log('🔌 SignalR start() çağrıldı')
|
||||
|
||||
const startPromise = this.connection.start()
|
||||
const timeout = new Promise((_, reject) =>
|
||||
setTimeout(() => reject(new Error('Bağlantı zaman aşımına uğradı')), 10000),
|
||||
|
|
@ -221,6 +225,7 @@ export class SignalRService {
|
|||
console.log('Error starting SignalR connection join class for', userName)
|
||||
return
|
||||
}
|
||||
console.log(`📡 joinClass: sessionId=${sessionId}, userId=${userId}, isTeacher=${isTeacher}`)
|
||||
|
||||
//Global değişkene yazılıyor.
|
||||
this.currentSessionId = sessionId
|
||||
|
|
@ -426,6 +431,8 @@ export class SignalRService {
|
|||
return
|
||||
}
|
||||
|
||||
console.log(`👢 kickParticipant çağrıldı: sessionId=${sessionId}, participantId=${participantId}`)
|
||||
|
||||
try {
|
||||
await this.connection.invoke('KickParticipant', sessionId, participantId)
|
||||
} catch (error) {
|
||||
|
|
|
|||
|
|
@ -364,7 +364,8 @@ const RoomDetail: React.FC = () => {
|
|||
})
|
||||
|
||||
signalRServiceRef.current.setParticipantLeaveHandler(({ userId, sessionId }) => {
|
||||
console.log(`Participant left: ${userId} from session ${sessionId}`)
|
||||
console.log(`👋 Participant left handler: ${userId}, sessionId=${sessionId}`)
|
||||
|
||||
toast.push(<Notification title={`Katılımcı ayrıldı: ${participants.find((p) => p.id === userId)?.name}`} type="warning" />, {
|
||||
placement: 'top-center',
|
||||
})
|
||||
|
|
@ -560,9 +561,9 @@ const RoomDetail: React.FC = () => {
|
|||
|
||||
const handleKickParticipant = async (participantId: string) => {
|
||||
if (signalRServiceRef.current && user.role === 'teacher') {
|
||||
console.log(`👢 handleKickParticipant UI’den çağrıldı: ${participantId}`)
|
||||
|
||||
await signalRServiceRef.current.kickParticipant(classSession.id, participantId)
|
||||
// ❌ state’den manuel silme yok
|
||||
// attendance update kısmı aynı kalabilir
|
||||
setAttendanceRecords((prev) =>
|
||||
prev.map((r) => {
|
||||
if (r.studentId === participantId && !r.leaveTime) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue