From e76dafab780855f33b316a566d01f559b8c742d9 Mon Sep 17 00:00:00 2001 From: Bruce Marriner Date: Thu, 16 Jun 2016 14:53:05 -0500 Subject: [PATCH] Do spam unready session error on voice reconnec --- voice.go | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/voice.go b/voice.go index 21e96a4..8076c19 100644 --- a/voice.go +++ b/voice.go @@ -812,10 +812,6 @@ func (v *VoiceConnection) reconnect() { // Close websocket and udp connections v.Close() - // Take a short nap to allow everything to close. - // may not be needed but just extra protection for now. - time.Sleep(1 * time.Second) - wait := time.Duration(1) i := 0 @@ -828,6 +824,14 @@ func (v *VoiceConnection) reconnect() { return } + <-time.After(wait * time.Second) + wait *= 2 + if wait > 600 { + wait = 600 + } + + i++ + if v.session.DataReady == false { v.log(LogInformational, "cannot reconenct with unready session") continue @@ -858,11 +862,5 @@ func (v *VoiceConnection) reconnect() { return } - <-time.After(wait * time.Second) - wait *= 2 - if wait > 600 { - wait = 600 - } - i++ } }