store participant res sink in interface typed field (#1567)
This commit is contained in:
@@ -93,12 +93,12 @@ type ParticipantParams struct {
|
|||||||
type ParticipantImpl struct {
|
type ParticipantImpl struct {
|
||||||
params ParticipantParams
|
params ParticipantParams
|
||||||
|
|
||||||
isClosed atomic.Bool
|
isClosed atomic.Bool
|
||||||
state atomic.Value // livekit.ParticipantInfo_State
|
state atomic.Value // livekit.ParticipantInfo_State
|
||||||
resSink atomic.Value // routing.MessageSink
|
resSinkMu sync.Mutex
|
||||||
resSinkValid atomic.Bool
|
resSink routing.MessageSink
|
||||||
grants *auth.ClaimGrants
|
grants *auth.ClaimGrants
|
||||||
isPublisher atomic.Bool
|
isPublisher atomic.Bool
|
||||||
|
|
||||||
// when first connected
|
// when first connected
|
||||||
connectedAt time.Time
|
connectedAt time.Time
|
||||||
|
|||||||
@@ -12,22 +12,15 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func (p *ParticipantImpl) getResponseSink() routing.MessageSink {
|
func (p *ParticipantImpl) getResponseSink() routing.MessageSink {
|
||||||
if !p.resSinkValid.Load() {
|
p.resSinkMu.Lock()
|
||||||
return nil
|
defer p.resSinkMu.Unlock()
|
||||||
}
|
return p.resSink
|
||||||
sink := p.resSink.Load()
|
|
||||||
if s, ok := sink.(routing.MessageSink); ok {
|
|
||||||
return s
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *ParticipantImpl) SetResponseSink(sink routing.MessageSink) {
|
func (p *ParticipantImpl) SetResponseSink(sink routing.MessageSink) {
|
||||||
p.resSinkValid.Store(sink != nil)
|
p.resSinkMu.Lock()
|
||||||
if sink != nil {
|
defer p.resSinkMu.Unlock()
|
||||||
// cannot store nil into atomic.Value
|
p.resSink = sink
|
||||||
p.resSink.Store(sink)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *ParticipantImpl) SendJoinResponse(joinResponse *livekit.JoinResponse) error {
|
func (p *ParticipantImpl) SendJoinResponse(joinResponse *livekit.JoinResponse) error {
|
||||||
|
|||||||
Reference in New Issue
Block a user