mirror of
https://github.com/matrix-org/dendrite.git
synced 2024-11-30 02:01:56 -06:00
make PeekingDeviceSet private
This commit is contained in:
parent
b9342d9ee2
commit
d7bdf71bef
|
@ -34,7 +34,7 @@ type Notifier struct {
|
||||||
// A map of RoomID => Set<UserID> : Must only be accessed by the OnNewEvent goroutine
|
// A map of RoomID => Set<UserID> : Must only be accessed by the OnNewEvent goroutine
|
||||||
roomIDToJoinedUsers map[string]userIDSet
|
roomIDToJoinedUsers map[string]userIDSet
|
||||||
// A map of RoomID => Set<UserID> : Must only be accessed by the OnNewEvent goroutine
|
// A map of RoomID => Set<UserID> : Must only be accessed by the OnNewEvent goroutine
|
||||||
roomIDToPeekingDevices map[string]PeekingDeviceSet
|
roomIDToPeekingDevices map[string]peekingDeviceSet
|
||||||
// Protects currPos and userStreams.
|
// Protects currPos and userStreams.
|
||||||
streamLock *sync.Mutex
|
streamLock *sync.Mutex
|
||||||
// The latest sync position
|
// The latest sync position
|
||||||
|
@ -52,7 +52,7 @@ func NewNotifier(pos types.StreamingToken) *Notifier {
|
||||||
return &Notifier{
|
return &Notifier{
|
||||||
currPos: pos,
|
currPos: pos,
|
||||||
roomIDToJoinedUsers: make(map[string]userIDSet),
|
roomIDToJoinedUsers: make(map[string]userIDSet),
|
||||||
roomIDToPeekingDevices: make(map[string]PeekingDeviceSet),
|
roomIDToPeekingDevices: make(map[string]peekingDeviceSet),
|
||||||
userDeviceStreams: make(map[string]map[string]*UserDeviceStream),
|
userDeviceStreams: make(map[string]map[string]*UserDeviceStream),
|
||||||
streamLock: &sync.Mutex{},
|
streamLock: &sync.Mutex{},
|
||||||
}
|
}
|
||||||
|
@ -225,7 +225,7 @@ func (n *Notifier) setPeekingDevices(roomIDToPeekingDevices map[string][]Peeking
|
||||||
// This is just the bulk form of addPeekingDevice
|
// This is just the bulk form of addPeekingDevice
|
||||||
for roomID, peekingDevices := range roomIDToPeekingDevices {
|
for roomID, peekingDevices := range roomIDToPeekingDevices {
|
||||||
if _, ok := n.roomIDToPeekingDevices[roomID]; !ok {
|
if _, ok := n.roomIDToPeekingDevices[roomID]; !ok {
|
||||||
n.roomIDToPeekingDevices[roomID] = make(PeekingDeviceSet)
|
n.roomIDToPeekingDevices[roomID] = make(peekingDeviceSet)
|
||||||
}
|
}
|
||||||
for _, peekingDevice := range peekingDevices {
|
for _, peekingDevice := range peekingDevices {
|
||||||
n.roomIDToPeekingDevices[roomID].add(peekingDevice)
|
n.roomIDToPeekingDevices[roomID].add(peekingDevice)
|
||||||
|
@ -335,7 +335,7 @@ func (n *Notifier) joinedUsers(roomID string) (userIDs []string) {
|
||||||
// Not thread-safe: must be called on the OnNewEvent goroutine only
|
// Not thread-safe: must be called on the OnNewEvent goroutine only
|
||||||
func (n *Notifier) addPeekingDevice(roomID, userID, deviceID string) {
|
func (n *Notifier) addPeekingDevice(roomID, userID, deviceID string) {
|
||||||
if _, ok := n.roomIDToPeekingDevices[roomID]; !ok {
|
if _, ok := n.roomIDToPeekingDevices[roomID]; !ok {
|
||||||
n.roomIDToPeekingDevices[roomID] = make(PeekingDeviceSet)
|
n.roomIDToPeekingDevices[roomID] = make(peekingDeviceSet)
|
||||||
}
|
}
|
||||||
n.roomIDToPeekingDevices[roomID].add(PeekingDevice{deviceID, userID})
|
n.roomIDToPeekingDevices[roomID].add(PeekingDevice{deviceID, userID})
|
||||||
}
|
}
|
||||||
|
@ -343,7 +343,7 @@ func (n *Notifier) addPeekingDevice(roomID, userID, deviceID string) {
|
||||||
// Not thread-safe: must be called on the OnNewEvent goroutine only
|
// Not thread-safe: must be called on the OnNewEvent goroutine only
|
||||||
func (n *Notifier) removePeekingDevice(roomID, userID, deviceID string) {
|
func (n *Notifier) removePeekingDevice(roomID, userID, deviceID string) {
|
||||||
if _, ok := n.roomIDToPeekingDevices[roomID]; !ok {
|
if _, ok := n.roomIDToPeekingDevices[roomID]; !ok {
|
||||||
n.roomIDToPeekingDevices[roomID] = make(PeekingDeviceSet)
|
n.roomIDToPeekingDevices[roomID] = make(peekingDeviceSet)
|
||||||
}
|
}
|
||||||
// XXX: is this going to work as a key?
|
// XXX: is this going to work as a key?
|
||||||
n.roomIDToPeekingDevices[roomID].remove(PeekingDevice{deviceID, userID})
|
n.roomIDToPeekingDevices[roomID].remove(PeekingDevice{deviceID, userID})
|
||||||
|
@ -404,3 +404,22 @@ func (s userIDSet) values() (vals []string) {
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// A set of PeekingDevices, similar to userIDSet
|
||||||
|
|
||||||
|
type peekingDeviceSet map[PeekingDevice]bool
|
||||||
|
|
||||||
|
func (s peekingDeviceSet) add(d PeekingDevice) {
|
||||||
|
s[d] = true
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s peekingDeviceSet) remove(d PeekingDevice) {
|
||||||
|
delete(s, d)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s peekingDeviceSet) values() (vals []PeekingDevice) {
|
||||||
|
for d := range s {
|
||||||
|
vals = append(vals, d)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
|
@ -508,26 +508,8 @@ type SendToDeviceEvent struct {
|
||||||
SentByToken *StreamingToken
|
SentByToken *StreamingToken
|
||||||
}
|
}
|
||||||
|
|
||||||
// For tracking peeking devices
|
|
||||||
|
|
||||||
type PeekingDevice struct {
|
type PeekingDevice struct {
|
||||||
ID string
|
ID string
|
||||||
UserID string
|
UserID string
|
||||||
}
|
}
|
||||||
|
|
||||||
type PeekingDeviceSet map[PeekingDevice]bool
|
|
||||||
|
|
||||||
func (s PeekingDeviceSet) add(d PeekingDevice) {
|
|
||||||
s[d] = true
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s PeekingDeviceSet) remove(d PeekingDevice) {
|
|
||||||
delete(s, d)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s PeekingDeviceSet) values() (vals []PeekingDevice) {
|
|
||||||
for d := range s {
|
|
||||||
vals = append(vals, d)
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in a new issue