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"
|
|
|
|
)
|
|
|
|
|
2024-07-30 08:59:14 +00:00
|
|
|
func FederatedWakeUp(k string, srv reveil.FederationServer, seed int64) {
|
2024-07-29 09:16:51 +00:00
|
|
|
if srv.Delay == 0 {
|
2024-07-30 08:59:14 +00:00
|
|
|
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)
|
2024-07-30 08:59:14 +00:00
|
|
|
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)
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
}
|
|
|
|
}
|