update name of participant (#1213)

This commit is contained in:
Haibo Chen
2022-12-15 22:03:59 -08:00
committed by GitHub
parent c9cc45c8b0
commit 8a6c6de1db
5 changed files with 100 additions and 1 deletions
+22 -1
View File
@@ -266,6 +266,27 @@ func (p *ParticipantImpl) GetBufferFactory() *buffer.Factory {
return p.params.Config.BufferFactory
}
// SetName attaches name to the participant
func (p *ParticipantImpl) SetName(name string) {
p.lock.Lock()
changed := p.grants.Name != name
p.grants.Name = name
onParticipantUpdate := p.onParticipantUpdate
onClaimsChanged := p.onClaimsChanged
p.lock.Unlock()
if !changed {
return
}
if onParticipantUpdate != nil {
onParticipantUpdate(p)
}
if onClaimsChanged != nil {
onClaimsChanged(p)
}
}
// SetMetadata attaches metadata to the participant
func (p *ParticipantImpl) SetMetadata(metadata string) {
p.lock.Lock()
@@ -351,7 +372,7 @@ func (p *ParticipantImpl) ToProto() *livekit.ParticipantInfo {
info := &livekit.ParticipantInfo{
Sid: string(p.params.SID),
Identity: string(p.params.Identity),
Name: string(p.params.Name),
Name: p.grants.Name,
State: p.State(),
JoinedAt: p.ConnectedAt().Unix(),
Version: p.version.Inc(),