Fix loop in voice reconnect

This commit is contained in:
Bruce Marriner 2016-05-28 10:50:18 -05:00
parent 754d64d339
commit 32aa5718d1

View file

@ -320,20 +320,7 @@ func (v *VoiceConnection) wsListen(wsConn *websocket.Conn, close <-chan struct{}
v.RUnlock()
if sameConnection {
log.Println("voice endpoint %s websocket closed unexpectantly,", v.endpoint, err)
// temp code.
neterr, ok := err.(net.Error)
if ok {
if neterr.Timeout() {
v.log(LogDebug, "neterr udp timeout error")
}
if neterr.Temporary() {
v.log(LogDebug, "neterr udp tempoary error")
}
v.log(LogDebug, "neterr udp error %s", neterr.Error())
}
v.log(LogError, "voice endpoint %s websocket closed unexpectantly,i %s", v.endpoint, err)
// Start reconnect goroutine then exit.
go v.reconnect()
@ -820,6 +807,7 @@ func (v *VoiceConnection) reconnect() {
v.Lock()
if v.reconnecting {
v.log(LogInformational, "Already reconnecting...")
return
}
v.reconnecting = true
@ -848,8 +836,7 @@ func (v *VoiceConnection) reconnect() {
if v.session.DataReady == false {
v.log(LogInformational, "cannot reconenct with unready session")
continue
}
} else {
v.log(LogInformational, "trying to reconnect to voice")
@ -858,6 +845,7 @@ func (v *VoiceConnection) reconnect() {
v.log(LogInformational, "successfully reconnected to voice")
return
}
}
<-time.After(wait * time.Second)
wait *= 2