mirror of
https://github.com/livekit/livekit.git
synced 2026-10-22 10:52:27 +00:00
store participant res sink in interface typed field (#1567)
This commit is contained in:
1 parent
b5b896a6c6
commit
c45e23be3f
2 files changed
+12
-19
No files matched your search
@@ -93,12 +93,12 @@ type ParticipantParams struct {
|
||||
type ParticipantImpl struct {
|
||||
params ParticipantParams
|
||||
|
||||
isClosed atomic.Bool
|
||||
state atomic.Value // livekit.ParticipantInfo_State
|
||||
resSink atomic.Value // routing.MessageSink
|
||||
resSinkValid atomic.Bool
|
||||
grants *auth.ClaimGrants
|
||||
isPublisher atomic.Bool
|
||||
isClosed atomic.Bool
|
||||
state atomic.Value // livekit.ParticipantInfo_State
|
||||
resSinkMu sync.Mutex
|
||||
resSink routing.MessageSink
|
||||
grants *auth.ClaimGrants
|
||||
isPublisher atomic.Bool
|
||||
|
||||
// when first connected
|
||||
connectedAt time.Time
|
||||
|
||||
@@ -12,22 +12,15 @@ import (
|
||||
)
|
||||
|
||||
func (p *ParticipantImpl) getResponseSink() routing.MessageSink {
|
||||
if !p.resSinkValid.Load() {
|
||||
return nil
|
||||
}
|
||||
sink := p.resSink.Load()
|
||||
if s, ok := sink.(routing.MessageSink); ok {
|
||||
return s
|
||||
}
|
||||
return nil
|
||||
p.resSinkMu.Lock()
|
||||
defer p.resSinkMu.Unlock()
|
||||
return p.resSink
|
||||
}
|
||||
|
||||
func (p *ParticipantImpl) SetResponseSink(sink routing.MessageSink) {
|
||||
p.resSinkValid.Store(sink != nil)
|
||||
if sink != nil {
|
||||
// cannot store nil into atomic.Value
|
||||
p.resSink.Store(sink)
|
||||
}
|
||||
p.resSinkMu.Lock()
|
||||
defer p.resSinkMu.Unlock()
|
||||
p.resSink = sink
|
||||
}
|
||||
|
||||
func (p *ParticipantImpl) SendJoinResponse(joinResponse *livekit.JoinResponse) error {
|
||||
|
||||
Reference in new issue
Block a user