Send event when ditto ping stops failing
This commit is contained in:
parent
6c98afb0cc
commit
e6f9c36d87
1 changed files with 7 additions and 0 deletions
|
@ -25,12 +25,18 @@ const phoneNotRespondingTimeout = 30 * time.Second
|
|||
|
||||
func (c *Client) doDittoPinger(log *zerolog.Logger, dittoPing <-chan struct{}, stopPinger <-chan struct{}) {
|
||||
notResponding := false
|
||||
pingFailed := false
|
||||
exit := false
|
||||
onRespond := func() {
|
||||
if notResponding {
|
||||
log.Debug().Msg("Ditto ping succeeded, phone is back online")
|
||||
c.triggerEvent(&events.PhoneRespondingAgain{})
|
||||
notResponding = false
|
||||
pingFailed = false
|
||||
} else if pingFailed {
|
||||
// TODO separate event?
|
||||
c.triggerEvent(&events.PhoneRespondingAgain{})
|
||||
pingFailed = false
|
||||
}
|
||||
}
|
||||
doPing := func() {
|
||||
|
@ -40,6 +46,7 @@ func (c *Client) doDittoPinger(log *zerolog.Logger, dittoPing <-chan struct{}, s
|
|||
c.triggerEvent(&events.PingFailed{
|
||||
Error: fmt.Errorf("failed to notify ditto activity: %w", err),
|
||||
})
|
||||
pingFailed = true
|
||||
return
|
||||
}
|
||||
select {
|
||||
|
|
Loading…
Reference in a new issue