2024-02-08 14:14:09 +00:00
|
|
|
package libbox
|
|
|
|
|
|
|
|
import (
|
|
|
|
"sync"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
type servicePauseFields struct {
|
|
|
|
pauseAccess sync.Mutex
|
|
|
|
pauseTimer *time.Timer
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *BoxService) Pause() {
|
|
|
|
s.pauseAccess.Lock()
|
|
|
|
defer s.pauseAccess.Unlock()
|
|
|
|
if s.pauseTimer != nil {
|
|
|
|
s.pauseTimer.Stop()
|
|
|
|
}
|
2024-06-08 12:27:08 +00:00
|
|
|
s.pauseTimer = time.AfterFunc(3*time.Second, s.ResetNetwork)
|
2024-02-08 14:14:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (s *BoxService) Wake() {
|
|
|
|
s.pauseAccess.Lock()
|
|
|
|
defer s.pauseAccess.Unlock()
|
|
|
|
if s.pauseTimer != nil {
|
|
|
|
s.pauseTimer.Stop()
|
|
|
|
}
|
2024-06-08 12:27:08 +00:00
|
|
|
s.pauseTimer = time.AfterFunc(3*time.Minute, s.ResetNetwork)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *BoxService) ResetNetwork() {
|
2024-11-10 04:11:21 +00:00
|
|
|
s.instance.Router().ResetNetwork()
|
2024-02-08 14:14:09 +00:00
|
|
|
}
|