update name of participant (#1213)
This commit is contained in:
+22
-1
@@ -266,6 +266,27 @@ func (p *ParticipantImpl) GetBufferFactory() *buffer.Factory {
|
|||||||
return p.params.Config.BufferFactory
|
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
|
// SetMetadata attaches metadata to the participant
|
||||||
func (p *ParticipantImpl) SetMetadata(metadata string) {
|
func (p *ParticipantImpl) SetMetadata(metadata string) {
|
||||||
p.lock.Lock()
|
p.lock.Lock()
|
||||||
@@ -351,7 +372,7 @@ func (p *ParticipantImpl) ToProto() *livekit.ParticipantInfo {
|
|||||||
info := &livekit.ParticipantInfo{
|
info := &livekit.ParticipantInfo{
|
||||||
Sid: string(p.params.SID),
|
Sid: string(p.params.SID),
|
||||||
Identity: string(p.params.Identity),
|
Identity: string(p.params.Identity),
|
||||||
Name: string(p.params.Name),
|
Name: p.grants.Name,
|
||||||
State: p.State(),
|
State: p.State(),
|
||||||
JoinedAt: p.ConnectedAt().Unix(),
|
JoinedAt: p.ConnectedAt().Unix(),
|
||||||
Version: p.version.Inc(),
|
Version: p.version.Inc(),
|
||||||
|
|||||||
@@ -176,6 +176,7 @@ type Participant interface {
|
|||||||
|
|
||||||
ToProto() *livekit.ParticipantInfo
|
ToProto() *livekit.ParticipantInfo
|
||||||
|
|
||||||
|
SetName(name string)
|
||||||
SetMetadata(metadata string)
|
SetMetadata(metadata string)
|
||||||
|
|
||||||
GetPublishedTrack(sid livekit.TrackID) MediaTrack
|
GetPublishedTrack(sid livekit.TrackID) MediaTrack
|
||||||
|
|||||||
@@ -612,6 +612,11 @@ type FakeLocalParticipant struct {
|
|||||||
setICEConfigArgsForCall []struct {
|
setICEConfigArgsForCall []struct {
|
||||||
arg1 types.IceConfig
|
arg1 types.IceConfig
|
||||||
}
|
}
|
||||||
|
SetNameStub func(string)
|
||||||
|
setNameMutex sync.RWMutex
|
||||||
|
setNameArgsForCall []struct {
|
||||||
|
arg1 string
|
||||||
|
}
|
||||||
SetMetadataStub func(string)
|
SetMetadataStub func(string)
|
||||||
setMetadataMutex sync.RWMutex
|
setMetadataMutex sync.RWMutex
|
||||||
setMetadataArgsForCall []struct {
|
setMetadataArgsForCall []struct {
|
||||||
@@ -4006,6 +4011,38 @@ func (fake *FakeLocalParticipant) SetICEConfigArgsForCall(i int) types.IceConfig
|
|||||||
return argsForCall.arg1
|
return argsForCall.arg1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (fake *FakeLocalParticipant) SetName(arg1 string) {
|
||||||
|
fake.setNameMutex.Lock()
|
||||||
|
fake.setNameArgsForCall = append(fake.setNameArgsForCall, struct {
|
||||||
|
arg1 string
|
||||||
|
}{arg1})
|
||||||
|
stub := fake.SetNameStub
|
||||||
|
fake.recordInvocation("SetName", []interface{}{arg1})
|
||||||
|
fake.setNameMutex.Unlock()
|
||||||
|
if stub != nil {
|
||||||
|
fake.SetNameStub(arg1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (fake *FakeLocalParticipant) SetNameCallCount() int {
|
||||||
|
fake.setNameMutex.RLock()
|
||||||
|
defer fake.setNameMutex.RUnlock()
|
||||||
|
return len(fake.setNameArgsForCall)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (fake *FakeLocalParticipant) SetNameCalls(stub func(string)) {
|
||||||
|
fake.setNameMutex.Lock()
|
||||||
|
defer fake.setNameMutex.Unlock()
|
||||||
|
fake.SetNameStub = stub
|
||||||
|
}
|
||||||
|
|
||||||
|
func (fake *FakeLocalParticipant) SetNameArgsForCall(i int) string {
|
||||||
|
fake.setNameMutex.RLock()
|
||||||
|
defer fake.setNameMutex.RUnlock()
|
||||||
|
argsForCall := fake.setNameArgsForCall[i]
|
||||||
|
return argsForCall.arg1
|
||||||
|
}
|
||||||
|
|
||||||
func (fake *FakeLocalParticipant) SetMetadata(arg1 string) {
|
func (fake *FakeLocalParticipant) SetMetadata(arg1 string) {
|
||||||
fake.setMetadataMutex.Lock()
|
fake.setMetadataMutex.Lock()
|
||||||
fake.setMetadataArgsForCall = append(fake.setMetadataArgsForCall, struct {
|
fake.setMetadataArgsForCall = append(fake.setMetadataArgsForCall, struct {
|
||||||
|
|||||||
@@ -120,6 +120,11 @@ type FakeParticipant struct {
|
|||||||
arg2 livekit.TrackID
|
arg2 livekit.TrackID
|
||||||
arg3 bool
|
arg3 bool
|
||||||
}
|
}
|
||||||
|
SetNameStub func(string)
|
||||||
|
setNameMutex sync.RWMutex
|
||||||
|
setNameArgsForCall []struct {
|
||||||
|
arg1 string
|
||||||
|
}
|
||||||
SetMetadataStub func(string)
|
SetMetadataStub func(string)
|
||||||
setMetadataMutex sync.RWMutex
|
setMetadataMutex sync.RWMutex
|
||||||
setMetadataArgsForCall []struct {
|
setMetadataArgsForCall []struct {
|
||||||
@@ -754,6 +759,38 @@ func (fake *FakeParticipant) RemoveSubscriberArgsForCall(i int) (types.LocalPart
|
|||||||
return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3
|
return argsForCall.arg1, argsForCall.arg2, argsForCall.arg3
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (fake *FakeParticipant) SetName(arg1 string) {
|
||||||
|
fake.setNameMutex.Lock()
|
||||||
|
fake.setNameArgsForCall = append(fake.setNameArgsForCall, struct {
|
||||||
|
arg1 string
|
||||||
|
}{arg1})
|
||||||
|
stub := fake.SetNameStub
|
||||||
|
fake.recordInvocation("SetName", []interface{}{arg1})
|
||||||
|
fake.setNameMutex.Unlock()
|
||||||
|
if stub != nil {
|
||||||
|
fake.SetNameStub(arg1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (fake *FakeParticipant) SetNameCallCount() int {
|
||||||
|
fake.setNameMutex.RLock()
|
||||||
|
defer fake.setNameMutex.RUnlock()
|
||||||
|
return len(fake.setNameArgsForCall)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (fake *FakeParticipant) SetNameCalls(stub func(string)) {
|
||||||
|
fake.setNameMutex.Lock()
|
||||||
|
defer fake.setNameMutex.Unlock()
|
||||||
|
fake.SetNameStub = stub
|
||||||
|
}
|
||||||
|
|
||||||
|
func (fake *FakeParticipant) SetNameArgsForCall(i int) string {
|
||||||
|
fake.setNameMutex.RLock()
|
||||||
|
defer fake.setNameMutex.RUnlock()
|
||||||
|
argsForCall := fake.setNameArgsForCall[i]
|
||||||
|
return argsForCall.arg1
|
||||||
|
}
|
||||||
|
|
||||||
func (fake *FakeParticipant) SetMetadata(arg1 string) {
|
func (fake *FakeParticipant) SetMetadata(arg1 string) {
|
||||||
fake.setMetadataMutex.Lock()
|
fake.setMetadataMutex.Lock()
|
||||||
fake.setMetadataArgsForCall = append(fake.setMetadataArgsForCall, struct {
|
fake.setMetadataArgsForCall = append(fake.setMetadataArgsForCall, struct {
|
||||||
|
|||||||
@@ -559,6 +559,9 @@ func (r *RoomManager) handleRTCMessage(ctx context.Context, roomName livekit.Roo
|
|||||||
}
|
}
|
||||||
pLogger.Debugw("updating participant", "metadata", rm.UpdateParticipant.Metadata,
|
pLogger.Debugw("updating participant", "metadata", rm.UpdateParticipant.Metadata,
|
||||||
"permission", rm.UpdateParticipant.Permission)
|
"permission", rm.UpdateParticipant.Permission)
|
||||||
|
if rm.UpdateParticipant.Name != "" {
|
||||||
|
participant.SetName(rm.UpdateParticipant.Name)
|
||||||
|
}
|
||||||
if rm.UpdateParticipant.Metadata != "" {
|
if rm.UpdateParticipant.Metadata != "" {
|
||||||
participant.SetMetadata(rm.UpdateParticipant.Metadata)
|
participant.SetMetadata(rm.UpdateParticipant.Metadata)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user