1
0
Fork 0
mirror of https://github.com/diamondburned/arikawa.git synced 2024-11-30 18:53:30 +00:00

Gateway: Possible bug fix, added more verbose debugging

This commit is contained in:
diamondburned (Forefront) 2020-04-11 17:47:09 -07:00
parent 3d47bada07
commit 01e52334c6
2 changed files with 12 additions and 3 deletions

View file

@ -173,6 +173,10 @@ func (g *Gateway) Close() error {
WSDebug("Stopped pacemaker.")
}
WSDebug("Closing the websocket.")
err := g.WS.Close()
g.AfterClose(err)
WSDebug("Waiting for WaitGroup to be done.")
// This should work, since Pacemaker should signal its loop to stop, which
@ -182,10 +186,8 @@ func (g *Gateway) Close() error {
// Mark g.waitGroup as empty:
g.waitGroup = nil
WSDebug("WaitGroup is done. Closing the websocket.")
WSDebug("WaitGroup is done.")
err := g.WS.Close()
g.AfterClose(err)
return err
}
@ -335,6 +337,7 @@ func (g *Gateway) start() error {
func (g *Gateway) handleWS() {
err := g.eventLoop()
g.waitGroup.Done()
WSDebug("Event loop stopped.")
if err != nil {
g.ErrorLog(err)

View file

@ -75,10 +75,14 @@ func (p *Pacemaker) start() error {
p.Echo()
for {
WSDebug("Pacemaker loop restarted.")
if err := p.Pace(); err != nil {
return err
}
WSDebug("Paced.")
// Paced, save:
atomic.StoreInt64(&p.SentBeat, time.Now().UnixNano())
@ -88,9 +92,11 @@ func (p *Pacemaker) start() error {
select {
case <-p.stop:
WSDebug("Received stop signal.")
return nil
case <-tick.C:
WSDebug("Ticked. Restarting.")
}
}
}