Procházet zdrojové kódy

Do spam unready session error on voice reconnec

Bruce Marriner před 8 roky
rodič
revize
e76dafab78
1 změnil soubory, kde provedl 8 přidání a 10 odebrání
  1. 8 10
      voice.go

+ 8 - 10
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++
 	}
 }