func (m *Manager) Remove(who refs.FeedRef) {
	m.roomMu.Lock()
	delete(m.room, who.Ref())
	currentMembers := m.room.AsList()
	m.roomMu.Unlock()
	m.endpointsUpdater.Update(currentMembers)
	m.attendantsUpdater.Left(who)
}
Remove removes the peer from the room
package roomstate
import (
	"fmt"
	"sort"
	"sync"
	"go.cryptoscope.co/muxrpc/v2"
	kitlog "go.mindeco.de/log"
	"github.com/ssb-ngi-pointer/go-ssb-room/v2/internal/broadcasts"
	refs "go.mindeco.de/ssb-refs"
)
type Manager struct {
	logger kitlog.Logger
	endpointsUpdater     broadcasts.EndpointsEmitter
	endpointsbroadcaster *broadcasts.EndpointsBroadcast
	attendantsUpdater     broadcasts.AttendantsEmitter
	attendantsbroadcaster *broadcasts.AttendantsBroadcast
	roomMu *sync.Mutex
	room   roomStateMap
}
func NewManager(log kitlog.Logger) *Manager {
	var m Manager
	m.logger = log
	m.endpointsUpdater, m.endpointsbroadcaster = broadcasts.NewEndpointsEmitter()
	m.attendantsUpdater, m.attendantsbroadcaster = broadcasts.NewAttendantsEmitter()
	m.roomMu = new(sync.Mutex)
	m.room = make(roomStateMap)
	return &m
}
type roomStateMap map[string]muxrpc.Endpoint
func (rsm roomStateMap) AsList() []string {
	memberList := make([]string, 0, len(rsm))
	for m := range rsm {
		memberList = append(memberList, m)
	}
	sort.Strings(memberList)
	return memberList
}
func (m *Manager) RegisterLegacyEndpoints(sink broadcasts.EndpointsEmitter) {
	m.endpointsbroadcaster.Register(sink)
}
func (m *Manager) RegisterAttendantsUpdates(sink broadcasts.AttendantsEmitter) {
	m.attendantsbroadcaster.Register(sink)
}
func (m *Manager) List() []string {
	m.roomMu.Lock()
	defer m.roomMu.Unlock()
	return m.room.AsList()
}
func (m *Manager) ListAsRefs() []refs.FeedRef {
	m.roomMu.Lock()
	lst := m.room.AsList()
	m.roomMu.Unlock()
	rlst := make([]refs.FeedRef, len(lst))
	for i, s := range lst {
		fr, err := refs.ParseFeedRef(s)
		if err != nil {
			panic(fmt.Errorf("invalid feed ref in room state: %d: %s", i, err))
		}
		rlst[i] = *fr
	}
	return rlst
}
func (m *Manager) AddEndpoint(who refs.FeedRef, edp muxrpc.Endpoint) {
	m.roomMu.Lock()
	m.room[who.Ref()] = edp
	currentMembers := m.room.AsList()
	m.roomMu.Unlock()
	m.endpointsUpdater.Update(currentMembers)
	m.attendantsUpdater.Joined(who)
}