Classroom Kick problemleri
This commit is contained in:
parent
dfd05cbf57
commit
b0566b7c6b
2 changed files with 21 additions and 5 deletions
|
|
@ -29,6 +29,7 @@ export class SignalRService {
|
||||||
private onOfferReceived?: (fromUserId: string, offer: RTCSessionDescriptionInit) => void
|
private onOfferReceived?: (fromUserId: string, offer: RTCSessionDescriptionInit) => void
|
||||||
private onAnswerReceived?: (fromUserId: string, answer: RTCSessionDescriptionInit) => void
|
private onAnswerReceived?: (fromUserId: string, answer: RTCSessionDescriptionInit) => void
|
||||||
private onIceCandidateReceived?: (fromUserId: string, candidate: RTCIceCandidateInit) => void
|
private onIceCandidateReceived?: (fromUserId: string, candidate: RTCIceCandidateInit) => void
|
||||||
|
private onForceCleanup?: () => void
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
const { auth } = store.getState()
|
const { auth } = store.getState()
|
||||||
|
|
@ -109,19 +110,20 @@ export class SignalRService {
|
||||||
})
|
})
|
||||||
|
|
||||||
this.connection.onclose(async (err) => {
|
this.connection.onclose(async (err) => {
|
||||||
this.isConnected = false
|
// 🚨 İlk satırda kontrol et
|
||||||
|
|
||||||
// Eğer kick sebebiyle kapandıysa tekrar LeaveClass deneme
|
|
||||||
if (this.isKicked) {
|
if (this.isKicked) {
|
||||||
|
this.isConnected = false
|
||||||
this.currentSessionId = undefined
|
this.currentSessionId = undefined
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.isConnected = false
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (this.currentSessionId) {
|
if (this.currentSessionId) {
|
||||||
await this.connection.invoke('LeaveClass', this.currentSessionId)
|
await this.connection.invoke('LeaveClass', this.currentSessionId)
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch {
|
||||||
console.warn('LeaveClass could not be sent, connection was already closed')
|
console.warn('LeaveClass could not be sent, connection was already closed')
|
||||||
} finally {
|
} finally {
|
||||||
this.currentSessionId = undefined
|
this.currentSessionId = undefined
|
||||||
|
|
@ -144,10 +146,15 @@ export class SignalRService {
|
||||||
console.warn('⚠️ ForceDisconnect received:', message)
|
console.warn('⚠️ ForceDisconnect received:', message)
|
||||||
|
|
||||||
this.isKicked = true
|
this.isKicked = true
|
||||||
|
|
||||||
|
// 🔑 Cleanup’u dışarıya delege et
|
||||||
|
if (this.onForceCleanup) {
|
||||||
|
this.onForceCleanup()
|
||||||
|
}
|
||||||
|
|
||||||
await this.connection.stop()
|
await this.connection.stop()
|
||||||
this.isConnected = false
|
this.isConnected = false
|
||||||
|
|
||||||
// ✅ frontend state’den de çıkar
|
|
||||||
if (this.currentSessionId && store.getState().auth.user) {
|
if (this.currentSessionId && store.getState().auth.user) {
|
||||||
this.onParticipantLeft?.({
|
this.onParticipantLeft?.({
|
||||||
userId: store.getState().auth.user.id,
|
userId: store.getState().auth.user.id,
|
||||||
|
|
@ -516,4 +523,8 @@ export class SignalRService {
|
||||||
getConnectionState(): boolean {
|
getConnectionState(): boolean {
|
||||||
return this.isConnected
|
return this.isConnected
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setForceCleanupHandler(callback: () => void) {
|
||||||
|
this.onForceCleanup = callback
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -353,6 +353,11 @@ const RoomDetail: React.FC = () => {
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
signalRServiceRef.current.setForceCleanupHandler(() => {
|
||||||
|
webRTCServiceRef.current?.closeAllConnections()
|
||||||
|
localStream?.getTracks().forEach((track) => track.stop())
|
||||||
|
})
|
||||||
|
|
||||||
signalRServiceRef.current.setParticipantLeaveHandler(({ userId, sessionId }) => {
|
signalRServiceRef.current.setParticipantLeaveHandler(({ userId, sessionId }) => {
|
||||||
console.log(`Participant left: ${userId} from session ${sessionId}`)
|
console.log(`Participant left: ${userId} from session ${sessionId}`)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue