fix(voice): session id deadlock on open (#1408)
* Unlock when checking voice connection sessionID to prevent deadlock * Move lock to preserve concurrency safety, while allowing the sessionID to be populated * style: formatting Fix formatting of the documentation comment for VoiceConnection.Speaking function * feat: reword explanatory comment --------- Co-authored-by: Fedor Lapshin <fe.lap.prog@gmail.com>
This commit is contained in:
parent
393091b18c
commit
58193fbfaa
1 changed files with 5 additions and 1 deletions
4
voice.go
4
voice.go
|
@ -294,11 +294,15 @@ func (v *VoiceConnection) open() (err error) {
|
|||
if v.sessionID != "" {
|
||||
break
|
||||
}
|
||||
|
||||
if i > 20 { // only loop for up to 1 second total
|
||||
return fmt.Errorf("did not receive voice Session ID in time")
|
||||
}
|
||||
// Release the lock, so sessionID can be populated upon receiving a VoiceStateUpdate event.
|
||||
v.Unlock()
|
||||
time.Sleep(50 * time.Millisecond)
|
||||
i++
|
||||
v.Lock()
|
||||
}
|
||||
|
||||
// Connect to VoiceConnection Websocket
|
||||
|
|
Loading…
Reference in a new issue