device ready handling.
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
lucifer3 "git.aiterp.net/lucifer3/server"
|
||||
"git.aiterp.net/lucifer3/server/commands"
|
||||
"git.aiterp.net/lucifer3/server/device"
|
||||
"git.aiterp.net/lucifer3/server/events"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
@@ -35,7 +36,18 @@ func (s *effectEnforcer) Active() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (s *effectEnforcer) HandleEvent(_ *lucifer3.EventBus, _ lucifer3.Event) {}
|
||||
func (s *effectEnforcer) HandleEvent(_ *lucifer3.EventBus, event lucifer3.Event) {
|
||||
switch event := event.(type) {
|
||||
case events.DeviceReady:
|
||||
// If the device is managed by the effect enforcer, cause the effect to be
|
||||
// re-ran.
|
||||
s.mu.Lock()
|
||||
if run, ok := s.index[event.ID]; ok && run.due.IsZero() {
|
||||
run.due = time.Now()
|
||||
}
|
||||
s.mu.Unlock()
|
||||
}
|
||||
}
|
||||
|
||||
func (s *effectEnforcer) HandleCommand(bus *lucifer3.EventBus, command lucifer3.Command) {
|
||||
switch command := command.(type) {
|
||||
|
||||
Reference in New Issue
Block a user