reveil/player/federation.go

30 lines
652 B
Go
Raw Permalink Normal View History

2024-07-25 17:38:02 +00:00
package player
import (
2024-07-29 09:16:51 +00:00
"log"
"time"
2024-07-25 17:38:02 +00:00
"git.nemunai.re/nemunaire/reveil/model"
)
func FederatedWakeUp(k string, srv reveil.FederationServer, seed int64) {
2024-07-29 09:16:51 +00:00
if srv.Delay == 0 {
err := srv.WakeUp(seed)
2024-07-29 09:16:51 +00:00
if err != nil {
log.Printf("Unable to do federated wakeup on %s: %s", k, err.Error())
} else {
log.Printf("Federated wakeup on %s: launched!", k)
}
} else {
go func() {
time.Sleep(time.Duration(srv.Delay) * time.Millisecond)
err := srv.WakeUp(seed)
2024-07-29 09:16:51 +00:00
if err != nil {
log.Printf("Unable to do federated wakeup on %s: %s", k, err.Error())
} else {
log.Printf("Federated wakeup on %s: launched!", k)
}
}()
}
}