mirror of
https://github.com/livekit/livekit.git
synced 2026-05-12 21:05:26 +00:00
Clear disconnect timer on ICERestart (#932)
* Clear disconnect timer on ICERestart Disconnect timer is set up when a transport fails. But, it is possible that the connection is resumed. So, clear disconnect timer on resume. * clean up
This commit is contained in:
+19
-9
@@ -672,6 +672,8 @@ func (p *ParticipantImpl) MigrateState() types.MigrateState {
|
||||
|
||||
// ICERestart restarts subscriber ICE connections
|
||||
func (p *ParticipantImpl) ICERestart(iceConfig *types.IceConfig) error {
|
||||
p.clearDisconnectTimer()
|
||||
|
||||
for _, t := range p.GetPublishedTracks() {
|
||||
t.(types.LocalMediaTrack).Restart()
|
||||
}
|
||||
@@ -1178,21 +1180,21 @@ func (p *ParticipantImpl) onPrimaryTransportFullyEstablished() {
|
||||
p.updateState(livekit.ParticipantInfo_ACTIVE)
|
||||
}
|
||||
|
||||
func (p *ParticipantImpl) onAnyTransportFailed() {
|
||||
// clients support resuming of connections when websocket becomes disconnected
|
||||
p.closeSignalConnection()
|
||||
|
||||
// detect when participant has actually left.
|
||||
func (p *ParticipantImpl) clearDisconnectTimer() {
|
||||
p.lock.Lock()
|
||||
if p.disconnectTimer != nil {
|
||||
p.disconnectTimer.Stop()
|
||||
p.disconnectTimer = nil
|
||||
}
|
||||
p.lock.Unlock()
|
||||
}
|
||||
|
||||
func (p *ParticipantImpl) setupDisconnectTimer() {
|
||||
p.clearDisconnectTimer()
|
||||
|
||||
p.lock.Lock()
|
||||
p.disconnectTimer = time.AfterFunc(disconnectCleanupDuration, func() {
|
||||
p.lock.Lock()
|
||||
p.disconnectTimer.Stop()
|
||||
p.disconnectTimer = nil
|
||||
p.lock.Unlock()
|
||||
p.clearDisconnectTimer()
|
||||
|
||||
if p.isClosed.Load() || p.State() == livekit.ParticipantInfo_DISCONNECTED {
|
||||
return
|
||||
@@ -1203,6 +1205,14 @@ func (p *ParticipantImpl) onAnyTransportFailed() {
|
||||
p.lock.Unlock()
|
||||
}
|
||||
|
||||
func (p *ParticipantImpl) onAnyTransportFailed() {
|
||||
// clients support resuming of connections when websocket becomes disconnected
|
||||
p.closeSignalConnection()
|
||||
|
||||
// detect when participant has actually left.
|
||||
p.setupDisconnectTimer()
|
||||
}
|
||||
|
||||
// subscriberRTCPWorker sends SenderReports periodically when the participant is subscribed to
|
||||
// other publishedTracks in the room.
|
||||
func (p *ParticipantImpl) subscriberRTCPWorker() {
|
||||
|
||||
Reference in New Issue
Block a user