-
Notifications
You must be signed in to change notification settings - Fork 2
/
participant.go
45 lines (36 loc) · 946 Bytes
/
participant.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package models
import (
"github.com/aukilabs/hagall-common/messages/hagallpb"
hwebsocket "github.com/aukilabs/hagall-common/websocket"
)
// A session participant.
type Participant struct {
ID uint32
Responder hwebsocket.ResponseSender
entityIDs map[uint32]struct{}
SignedLatency *SignedLatency
}
func (p *Participant) AddEntity(e *Entity) {
if p.entityIDs == nil {
p.entityIDs = make(map[uint32]struct{})
}
p.entityIDs[e.ID] = struct{}{}
}
func (p *Participant) RemoveEntity(e *Entity) {
delete(p.entityIDs, e.ID)
}
func (p *Participant) EntityIDs() map[uint32]struct{} {
return p.entityIDs
}
func (p *Participant) ToProtobuf() *hagallpb.Participant {
return &hagallpb.Participant{
Id: p.ID,
}
}
func ParticipantsToProtobuf(participants []*Participant) []*hagallpb.Participant {
res := make([]*hagallpb.Participant, len(participants))
for i, p := range participants {
res[i] = p.ToProtobuf()
}
return res
}