Fix timers

This commit is contained in:
Zoltán Papp
2024-06-18 11:20:01 +02:00
parent 5b86a7f3f2
commit f7d8d03e55
4 changed files with 18 additions and 5 deletions

View File

@@ -24,8 +24,11 @@ func NewGuard(context context.Context, relayClient *Client) *Guard {
}
func (g *Guard) OnDisconnected() {
timeout := time.NewTimer(reconnectingTimeout)
defer timeout.Stop()
select {
case <-time.After(time.Second):
case <-timeout.C:
_ = g.relayClient.Connect()
case <-g.ctx.Done():
return