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