X-Git-Url: https://code.octet-stream.net/broadcaster/blobdiff_plain/7423c6c97eb5d6dc063e7185c50137bbb5e25a23..7b615b3c71825b5b229b78509a16db37e1d3f38d:/broadcaster-server/status.go diff --git a/broadcaster-server/status.go b/broadcaster-server/status.go deleted file mode 100644 index b2edd49..0000000 --- a/broadcaster-server/status.go +++ /dev/null @@ -1,54 +0,0 @@ -package main - -import ( - "code.octet-stream.net/broadcaster/internal/protocol" - "sync" -) - -type ServerStatus struct { - statuses map[int]protocol.StatusMessage - statusesMutex sync.Mutex - changeWait chan bool -} - -var status ServerStatus - -func InitServerStatus() { - status = ServerStatus{ - statuses: make(map[int]protocol.StatusMessage), - changeWait: make(chan bool), - } -} - -func (s *ServerStatus) MergeStatus(radioId int, status protocol.StatusMessage) { - s.statusesMutex.Lock() - defer s.statusesMutex.Unlock() - s.statuses[radioId] = status - s.TriggerChange() -} - -func (s *ServerStatus) RadioDisconnected(radioId int) { - s.statusesMutex.Lock() - defer s.statusesMutex.Unlock() - delete(s.statuses, radioId) - s.TriggerChange() -} - -func (s *ServerStatus) TriggerChange() { - close(s.changeWait) - s.changeWait = make(chan bool) -} - -func (s *ServerStatus) Statuses() map[int]protocol.StatusMessage { - s.statusesMutex.Lock() - defer s.statusesMutex.Unlock() - c := make(map[int]protocol.StatusMessage) - for k, v := range s.statuses { - c[k] = v - } - return c -} - -func (s *ServerStatus) ChangeChannel() chan bool { - return s.changeWait -}