mirror of
https://github.com/livekit/livekit.git
synced 2026-05-30 03:04:38 +00:00
feat: customizable participant disconnect timeout
This commit is contained in:
@@ -223,6 +223,8 @@ type RoomConfig struct {
|
||||
MaxMetadataSize uint32 `yaml:"max_metadata_size,omitempty"`
|
||||
PlayoutDelay PlayoutDelayConfig `yaml:"playout_delay,omitempty"`
|
||||
SyncStreams bool `yaml:"sync_streams,omitempty"`
|
||||
// amount of time to wait after a transport failure before considering a participant to be disconnected
|
||||
ParticipantDisconnectTimeout uint32 `yaml:"participant_disconnect_timeout,omitempty"`
|
||||
}
|
||||
|
||||
type CodecSpec struct {
|
||||
|
||||
@@ -64,7 +64,7 @@ func (c ClientInfo) SupportsICETCP() bool {
|
||||
if c.ClientInfo == nil {
|
||||
return false
|
||||
}
|
||||
if c.ClientInfo.Sdk == livekit.ClientInfo_GO {
|
||||
if c.isGo() {
|
||||
// Go does not support active TCP
|
||||
return false
|
||||
}
|
||||
|
||||
+12
-3
@@ -56,8 +56,8 @@ const (
|
||||
sdBatchSize = 30
|
||||
rttUpdateInterval = 5 * time.Second
|
||||
|
||||
disconnectCleanupDuration = 5 * time.Second
|
||||
migrationWaitDuration = 3 * time.Second
|
||||
defaultParticipantDisconnectTimeout = 5 * time.Second
|
||||
migrationWaitDuration = 3 * time.Second
|
||||
|
||||
PingIntervalSeconds = 5
|
||||
PingTimeoutSeconds = 15
|
||||
@@ -126,6 +126,7 @@ type ParticipantParams struct {
|
||||
SubscriptionLimitVideo int32
|
||||
PlayoutDelay *livekit.PlayoutDelay
|
||||
SyncStreams bool
|
||||
DisconnectTimeout time.Duration
|
||||
}
|
||||
|
||||
type ParticipantImpl struct {
|
||||
@@ -1407,7 +1408,7 @@ func (p *ParticipantImpl) setupDisconnectTimer() {
|
||||
p.clearDisconnectTimer()
|
||||
|
||||
p.lock.Lock()
|
||||
p.disconnectTimer = time.AfterFunc(disconnectCleanupDuration, func() {
|
||||
p.disconnectTimer = time.AfterFunc(p.getDisconnectTimeout(), func() {
|
||||
p.clearDisconnectTimer()
|
||||
|
||||
if p.IsClosed() || p.IsDisconnected() {
|
||||
@@ -2309,3 +2310,11 @@ func (p *ParticipantImpl) SendDataPacket(dp *livekit.DataPacket, data []byte) er
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (p *ParticipantImpl) getDisconnectTimeout() time.Duration {
|
||||
timeout := defaultParticipantDisconnectTimeout
|
||||
if p.params.DisconnectTimeout > 0 {
|
||||
timeout = p.params.DisconnectTimeout
|
||||
}
|
||||
return timeout
|
||||
}
|
||||
|
||||
@@ -410,6 +410,7 @@ func (r *RoomManager) StartSession(
|
||||
SubscriptionLimitVideo: r.config.Limit.SubscriptionLimitVideo,
|
||||
PlayoutDelay: roomInternal.GetPlayoutDelay(),
|
||||
SyncStreams: roomInternal.GetSyncStreams(),
|
||||
DisconnectTimeout: time.Duration(r.config.Room.ParticipantDisconnectTimeout) * time.Second,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -33,7 +33,7 @@ import (
|
||||
"github.com/livekit/protocol/rpc"
|
||||
)
|
||||
|
||||
// A rooms service that supports a single node
|
||||
// RoomService handles room related APIs
|
||||
type RoomService struct {
|
||||
roomConf config.RoomConfig
|
||||
apiConf config.APIConfig
|
||||
|
||||
Reference in New Issue
Block a user