Apply suggestions from code review

Co-authored-by: Alexander Cobleigh <cblgh@cblgh.org>
This commit is contained in:
Henry 2021-05-18 15:20:18 +02:00 committed by GitHub
parent 634f464d64
commit 939e7c1aaa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 4 deletions

View File

@ -52,7 +52,6 @@ func (bcst *AttendantsBroadcast) Register(sink AttendantsEmitter) func() {
type attendantsSink AttendantsBroadcast
func (bcst *attendantsSink) Joined(member refs.FeedRef) error {
bcst.mu.Lock()
for s := range bcst.sinks {
err := (*s).Joined(member)
@ -66,7 +65,6 @@ func (bcst *attendantsSink) Joined(member refs.FeedRef) error {
}
func (bcst *attendantsSink) Left(member refs.FeedRef) error {
bcst.mu.Lock()
for s := range bcst.sinks {
err := (*s).Left(member)
@ -81,7 +79,13 @@ func (bcst *attendantsSink) Left(member refs.FeedRef) error {
// Close implements the Sink interface.
func (bcst *attendantsSink) Close() error {
var sinks []AttendantsEmitter
bcst.mu.Lock()
defer bcst.mu.Unlock()
sinks := make([]AttendantsEmitter, 0, len(bcst.sinks))
for sink := range bcst.sinks {
sinks = append(sinks, *sink)
}
bcst.mu.Lock()
defer bcst.mu.Unlock()

View File

@ -50,7 +50,7 @@ func TestRoomAttendants(t *testing.T) {
carlsSource, err := carl.Source(ctx, muxrpc.TypeJSON, muxrpc.Method{"room", "attendants"})
r.NoError(err)
t.Log("sarah opened endpoints")
t.Log("carl opened attendants")
// first message should be initial state
a.True(carlsSource.Next(ctx))