Apply suggestions from code review
Co-authored-by: Alexander Cobleigh <cblgh@cblgh.org>
This commit is contained in:
parent
634f464d64
commit
939e7c1aaa
|
@ -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()
|
||||
|
|
|
@ -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))
|
||||
|
|
Loading…
Reference in New Issue