]>
code.octet-stream.net Git - broadcaster/blob - server/status.go
4 "code.octet-stream.net/broadcaster/protocol"
8 type ServerStatus
struct {
9 statuses
map[int]protocol
.StatusMessage
10 statusesMutex sync
.Mutex
14 var status ServerStatus
16 func InitServerStatus() {
17 status
= ServerStatus
{
18 statuses
: make(map[int]protocol
.StatusMessage
),
19 changeWait
: make(chan bool),
23 func (s
*ServerStatus
) MergeStatus(radioId
int, status protocol
.StatusMessage
) {
24 s
.statusesMutex
.Lock()
25 defer s
.statusesMutex
.Unlock()
26 s
.statuses
[radioId
] = status
30 func (s
*ServerStatus
) RadioDisconnected(radioId
int) {
31 s
.statusesMutex
.Lock()
32 defer s
.statusesMutex
.Unlock()
33 delete(s
.statuses
, radioId
)
37 func (s
*ServerStatus
) TriggerChange() {
39 s
.changeWait
= make(chan bool)
42 func (s
*ServerStatus
) Statuses() map[int]protocol
.StatusMessage
{
43 s
.statusesMutex
.Lock()
44 defer s
.statusesMutex
.Unlock()
45 c
:= make(map[int]protocol
.StatusMessage
)
46 for k
, v
:= range s
.statuses
{
52 func (s
*ServerStatus
) ChangeChannel() chan bool {