Update dependencies to generic versions (#1259)
This commit is contained in:
@@ -8,7 +8,7 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
lru "github.com/hashicorp/golang-lru"
|
||||
lru "github.com/hashicorp/golang-lru/v2"
|
||||
"github.com/pion/rtcp"
|
||||
"github.com/pion/sdp/v3"
|
||||
"github.com/pion/webrtc/v3"
|
||||
@@ -97,7 +97,7 @@ type ParticipantImpl struct {
|
||||
|
||||
isClosed atomic.Bool
|
||||
state atomic.Value // livekit.ParticipantInfo_State
|
||||
updateCache *lru.Cache
|
||||
updateCache *lru.Cache[livekit.ParticipantID, uint32]
|
||||
resSink atomic.Value // routing.MessageSink
|
||||
resSinkValid atomic.Bool
|
||||
grants *auth.ClaimGrants
|
||||
@@ -207,7 +207,7 @@ func NewParticipant(params ParticipantParams) (*ParticipantImpl, error) {
|
||||
|
||||
var err error
|
||||
// keep last participants and when updates were sent
|
||||
if p.updateCache, err = lru.New(128); err != nil {
|
||||
if p.updateCache, err = lru.New[livekit.ParticipantID, uint32](128); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -909,7 +909,7 @@ func (p *ParticipantImpl) UpdateSubscribedTrackSettings(trackID livekit.TrackID,
|
||||
}
|
||||
|
||||
func (p *ParticipantImpl) VerifySubscribeParticipantInfo(pID livekit.ParticipantID, version uint32) {
|
||||
if v, ok := p.updateCache.Get(pID); ok && v.(uint32) >= version {
|
||||
if v, ok := p.updateCache.Get(pID); ok && v >= version {
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -47,18 +47,17 @@ func (p *ParticipantImpl) SendParticipantUpdate(participantsToUpdate []*livekit.
|
||||
validUpdates := make([]*livekit.ParticipantInfo, 0, len(participantsToUpdate))
|
||||
for _, pi := range participantsToUpdate {
|
||||
isValid := true
|
||||
if val, ok := p.updateCache.Get(pi.Sid); ok {
|
||||
if lastVersion, ok := val.(uint32); ok {
|
||||
// this is a message delivered out of order, a more recent version of the message had already been
|
||||
// sent.
|
||||
if pi.Version < lastVersion {
|
||||
p.params.Logger.Debugw("skipping outdated participant update", "version", pi.Version, "lastVersion", lastVersion)
|
||||
isValid = false
|
||||
}
|
||||
pID := livekit.ParticipantID(pi.Sid)
|
||||
if lastVersion, ok := p.updateCache.Get(pID); ok {
|
||||
// this is a message delivered out of order, a more recent version of the message had already been
|
||||
// sent.
|
||||
if pi.Version < lastVersion {
|
||||
p.params.Logger.Debugw("skipping outdated participant update", "version", pi.Version, "lastVersion", lastVersion)
|
||||
isValid = false
|
||||
}
|
||||
}
|
||||
if isValid {
|
||||
p.updateCache.Add(pi.Sid, pi.Version)
|
||||
p.updateCache.Add(pID, pi.Version)
|
||||
validUpdates = append(validUpdates, pi)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user