You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
615 B

  1. package scene
  2. import (
  3. "git.aiterp.net/lucifer/new-server/models"
  4. "sync"
  5. )
  6. type Manager struct {
  7. mu sync.Mutex
  8. assignments map[int]*Scene
  9. scenes []*Scene
  10. }
  11. func (mgr *Manager) UpdateDevice(device *models.Device) {
  12. }
  13. func (mgr *Manager) GetUnassigned(devices []models.Device) []models.Device {
  14. mgr.mu.Lock()
  15. defer mgr.mu.Unlock()
  16. res := make([]models.Device, 0, len(devices))
  17. for _, device := range devices {
  18. if _, ok := mgr.assignments[device.ID]; !ok {
  19. res = append(res, device)
  20. }
  21. }
  22. return res
  23. }
  24. var globalManager = &Manager{}
  25. func Get() *Manager {
  26. return globalManager
  27. }