Classroom güncellemesi

This commit is contained in:
Sedat Öztürk 2025-08-31 02:15:49 +03:00
parent 8bed966030
commit 22742966f1
2 changed files with 19 additions and 12 deletions

View file

@ -376,20 +376,14 @@ public class ClassroomHub : Hub
x => x.SessionId == sessionId && x.UserId == participantId x => x.SessionId == sessionId && x.UserId == participantId
); );
if (participant != null) if (participant != null && !string.IsNullOrEmpty(participant.ConnectionId))
{ {
// Önce SignalR grubundan çıkar
if (!string.IsNullOrEmpty(participant.ConnectionId))
{
// Kullanıcıya "zorunlu çıkış" sinyali gönder
await Clients.Client(participant.ConnectionId) await Clients.Client(participant.ConnectionId)
.SendAsync("ForceDisconnect", "You have been removed from the class."); .SendAsync("ForceDisconnect", "You have been removed from the class.");
await Groups.RemoveFromGroupAsync(participant.ConnectionId, sessionId.ToString()); await Groups.RemoveFromGroupAsync(participant.ConnectionId, sessionId.ToString());
}
// DBde pasife al
await DeactivateParticipantAsync(participant); await DeactivateParticipantAsync(participant);
await Clients.Group(sessionId.ToString()).SendAsync("ParticipantLeft", participantId);
} }
// 3. Diğerlerine duyur // 3. Diğerlerine duyur

View file

@ -12,6 +12,7 @@ export class SignalRService {
private connection!: signalR.HubConnection private connection!: signalR.HubConnection
private isConnected: boolean = false private isConnected: boolean = false
private currentSessionId?: string private currentSessionId?: string
private isKicked: boolean = false
private onAttendanceUpdate?: (record: ClassroomAttendanceDto) => void private onAttendanceUpdate?: (record: ClassroomAttendanceDto) => void
private onParticipantJoined?: ( private onParticipantJoined?: (
@ -117,10 +118,22 @@ export class SignalRService {
console.error('Hub error:', message) console.error('Hub error:', message)
}) })
this.connection.onreconnecting((err) => {
if (this.isKicked) {
console.warn('Reconnect blocked because user was kicked')
// ❌ otomatik reconnect'i iptal etmek için stop çağır
this.connection.stop()
throw new Error('Reconnect blocked after kick')
}
})
this.connection.on('ForceDisconnect', async (message: string) => { this.connection.on('ForceDisconnect', async (message: string) => {
console.warn('⚠️ ForceDisconnect received:', message) console.warn('⚠️ ForceDisconnect received:', message)
await this.disconnect() this.isKicked = true // ✅ kick yediğini işaretle
await this.connection.stop()
this.isConnected = false
window.location.href = ROUTES_ENUM.protected.admin.classroom.classes window.location.href = ROUTES_ENUM.protected.admin.classroom.classes
}) })
} }