Expose Participant.IsPublisher to differentiate pubs from subs (#643)

This commit is contained in:
David Zhao
2022-04-21 22:15:01 -07:00
committed by GitHub
parent 8bb46637bb
commit 57e2321a18
9 changed files with 56 additions and 23 deletions
+6 -4
View File
@@ -314,10 +314,12 @@ func (c *RTCClient) Run() error {
case *livekit.SignalResponse_Update:
c.lock.Lock()
for _, p := range msg.Update.Participants {
if p.State != livekit.ParticipantInfo_DISCONNECTED {
c.remoteParticipants[livekit.ParticipantID(p.Sid)] = p
} else {
delete(c.remoteParticipants, livekit.ParticipantID(p.Sid))
if livekit.ParticipantID(p.Sid) != c.id {
if p.State != livekit.ParticipantInfo_DISCONNECTED {
c.remoteParticipants[livekit.ParticipantID(p.Sid)] = p
} else {
delete(c.remoteParticipants, livekit.ParticipantID(p.Sid))
}
}
}
c.lock.Unlock()
+6 -2
View File
@@ -116,8 +116,12 @@ func scenarioReceiveBeforePublish(t *testing.T) {
// now leave, and ensure that it's immediate
c2.Stop()
time.Sleep(testutils.ConnectTimeout)
require.Empty(t, c1.RemoteParticipants())
testutils.WithTimeout(t, func() string {
if len(c1.RemoteParticipants()) > 0 {
return fmt.Sprintf("expected no remote participants, actual: %v", c1.RemoteParticipants())
}
return ""
})
}
func scenarioDataPublish(t *testing.T) {