1
0
Fork 0
mirror of https://github.com/diamondburned/arikawa.git synced 2025-12-01 08:37:23 +00:00

Gateway: Minor bug fixes

This commit is contained in:
diamondburned (Forefront) 2020-03-01 16:39:40 -08:00
parent 14b9d8f43a
commit 0aebea60bd
3 changed files with 15 additions and 11 deletions

View file

@ -329,7 +329,7 @@ func (g *Gateway) eventLoop() error {
return nil
}
return errors.New("Pacemaker died, reconnecting.")
return errors.Wrap(err, "Pacemaker died, reconnecting")
case ev := <-ch:
// Check for error

View file

@ -77,21 +77,22 @@ func (p *Pacemaker) start(stop chan struct{}, wg *sync.WaitGroup) error {
p.Echo()
for {
if err := p.Pace(); err != nil {
return err
}
// Paced, save:
atomic.StoreInt64(&p.SentBeat, time.Now().UnixNano())
if p.Dead() {
return ErrDead
}
select {
case <-stop:
return nil
case <-tick.C:
if err := p.Pace(); err != nil {
return err
}
// Paced, save:
atomic.StoreInt64(&p.SentBeat, time.Now().UnixNano())
if p.Dead() {
return ErrDead
}
}
}
}

View file

@ -58,6 +58,9 @@ func (ws *Websocket) Dial(ctx context.Context) error {
return errors.Wrap(err, "Failed to dial")
}
// Reset the SendLimiter:
ws.SendLimiter = NewSendLimiter()
return nil
}