Classroom uyarı mesajları eklendi.
This commit is contained in:
parent
cba9bdf228
commit
e042fc49bd
4 changed files with 30 additions and 1 deletions
|
|
@ -423,7 +423,7 @@ public class ClassroomHub : Hub
|
|||
.SendAsync("ForceDisconnect", "You have been removed from the class.");
|
||||
|
||||
// 🔑 Mesajın client’a ulaşmasını bekle
|
||||
await Task.Delay(200);
|
||||
await Task.Delay(300);
|
||||
|
||||
await Groups.RemoveFromGroupAsync(connectionId, sessionId.ToString());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import { toast } from '@/components/ui'
|
||||
import {
|
||||
ClassroomAttendanceDto,
|
||||
ClassroomChatDto,
|
||||
|
|
@ -7,6 +8,7 @@ import {
|
|||
import { ROUTES_ENUM } from '@/routes/route.constant'
|
||||
import { store } from '@/store/store'
|
||||
import * as signalR from '@microsoft/signalr'
|
||||
import Notification from '@/components/ui/Notification'
|
||||
|
||||
export class SignalRService {
|
||||
private connection!: signalR.HubConnection
|
||||
|
|
@ -101,6 +103,9 @@ export class SignalRService {
|
|||
this.connection.onreconnected(async () => {
|
||||
this.isConnected = true
|
||||
console.warn('🔄 SignalR reconnected')
|
||||
toast.push(<Notification title="🔄 Bağlantı tekrar kuruldu" type="success" />, {
|
||||
placement: 'top-center',
|
||||
})
|
||||
|
||||
// Eğer sınıftayken bağlantı koptuysa → tekrar join et
|
||||
if (this.currentSessionId && store.getState().auth.user) {
|
||||
|
|
@ -113,6 +118,13 @@ export class SignalRService {
|
|||
console.warn('🔥 onclose triggered, isKicked=', this.isKicked)
|
||||
|
||||
if (this.isKicked) {
|
||||
toast.push(
|
||||
<Notification title="⚠️ Bağlantı koptu, yeniden bağlanılıyor..." type="warning" />,
|
||||
{
|
||||
placement: 'top-center',
|
||||
},
|
||||
)
|
||||
|
||||
this.isConnected = false
|
||||
this.currentSessionId = undefined
|
||||
return // ❗ Kick durumunda kesinlikle LeaveClass çağırma
|
||||
|
|
@ -132,6 +144,9 @@ export class SignalRService {
|
|||
|
||||
this.connection.on('Error', (message: string) => {
|
||||
console.error('Hub error:', message)
|
||||
toast.push(<Notification title={`❌ Hata: ${message}`} type="danger" />, {
|
||||
placement: 'top-center',
|
||||
})
|
||||
})
|
||||
|
||||
this.connection.onreconnecting((err) => {
|
||||
|
|
@ -145,6 +160,9 @@ export class SignalRService {
|
|||
this.connection.on('ForceDisconnect', async (message: string) => {
|
||||
console.warn('🚨 ForceDisconnect geldi:', message)
|
||||
this.isKicked = true
|
||||
toast.push(<Notification title={`❌ Sınıftan çıkarıldınız: ${message}`} type="danger" />, {
|
||||
placement: 'top-center',
|
||||
})
|
||||
|
||||
if (this.onForceCleanup) {
|
||||
console.warn('⚡ ForceCleanup callback çağrılıyor')
|
||||
|
|
@ -180,6 +198,9 @@ export class SignalRService {
|
|||
|
||||
await Promise.race([startPromise, timeout])
|
||||
this.isConnected = true
|
||||
toast.push(<Notification title="✅ Bağlantı kuruldu" type="success" />, {
|
||||
placement: 'top-center',
|
||||
})
|
||||
} catch (error) {
|
||||
console.error('Error starting SignalR connection:', error)
|
||||
alert(
|
||||
|
|
@ -55,6 +55,8 @@ import DocumentsPanel from '@/components/classroom/panels/DocumentsPanel'
|
|||
import LayoutPanel from '@/components/classroom/panels/LayoutPanel'
|
||||
import { ScreenSharePanel } from '@/components/classroom/panels/ScreenSharePanel'
|
||||
import { ParticipantGrid } from '@/components/classroom/ParticipantGrid'
|
||||
import toast from '@/components/ui/toast/toast'
|
||||
import Notification from '@/components/ui/Notification'
|
||||
|
||||
type SidePanelType =
|
||||
| 'chat'
|
||||
|
|
@ -282,6 +284,9 @@ const RoomDetail: React.FC = () => {
|
|||
if (!isActive) return
|
||||
|
||||
console.log(`Participant joined: ${name}, isTeacher: ${isTeacher}`)
|
||||
toast.push(<Notification title={`${name} sınıfa katıldı`} type="success" />, {
|
||||
placement: 'top-center',
|
||||
})
|
||||
|
||||
// State’e ekle
|
||||
setParticipants((prev) => {
|
||||
|
|
@ -360,6 +365,9 @@ const RoomDetail: React.FC = () => {
|
|||
|
||||
signalRServiceRef.current.setParticipantLeaveHandler(({ userId, sessionId }) => {
|
||||
console.log(`Participant left: ${userId} from session ${sessionId}`)
|
||||
toast.push(<Notification title={`Katılımcı ayrıldı: ${participants.find((p) => p.id === userId)?.name}`} type="warning" />, {
|
||||
placement: 'top-center',
|
||||
})
|
||||
|
||||
// peer connection’ı kapat
|
||||
webRTCServiceRef.current?.closePeerConnection(userId)
|
||||
|
|
|
|||
Loading…
Reference in a new issue