Added VoiceReady support to voice

This commit is contained in:
Bruce Marriner 2015-11-25 19:29:22 -06:00
parent c77f7f3ff8
commit 106c69f28a

View file

@ -198,6 +198,7 @@ func (s *Session) VoiceOpenUDP() {
fmt.Println("error:", err)
return
}
s.UDPReady = true
// continue to listen for future packets
// go s.VoiceListenUDP()
@ -289,15 +290,18 @@ func (s *Session) VoiceUDPKeepalive(i time.Duration) {
func (s *Session) VoiceHeartbeat(i time.Duration) {
ticker := time.NewTicker(i * time.Millisecond)
for range ticker.C {
for {
timestamp := int(time.Now().Unix())
err := s.VwsConn.WriteJSON(map[string]int{
"op": 3,
"d": timestamp,
})
if err != nil {
s.VoiceReady = false
fmt.Println(err)
return // log error?
}
s.VoiceReady = true
<-ticker.C
}
}