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
36 lines
615 B
package scene
|
|
|
|
import (
|
|
"git.aiterp.net/lucifer/new-server/models"
|
|
"sync"
|
|
)
|
|
|
|
type Manager struct {
|
|
mu sync.Mutex
|
|
assignments map[int]*Scene
|
|
scenes []*Scene
|
|
}
|
|
|
|
func (mgr *Manager) UpdateDevice(device *models.Device) {
|
|
|
|
}
|
|
|
|
func (mgr *Manager) GetUnassigned(devices []models.Device) []models.Device {
|
|
mgr.mu.Lock()
|
|
defer mgr.mu.Unlock()
|
|
|
|
res := make([]models.Device, 0, len(devices))
|
|
for _, device := range devices {
|
|
if _, ok := mgr.assignments[device.ID]; !ok {
|
|
res = append(res, device)
|
|
}
|
|
}
|
|
|
|
return res
|
|
}
|
|
|
|
var globalManager = &Manager{}
|
|
|
|
func Get() *Manager {
|
|
return globalManager
|
|
}
|