From e451cb36c3cf3fb10e0bf28b6560bc6b8de71c12 Mon Sep 17 00:00:00 2001 From: Bruce Marriner Date: Fri, 17 Jun 2016 10:24:15 -0500 Subject: [PATCH] Clear SessionID when reconnecting voice Also added some more logging.. --- voice.go | 9 ++++++++- wsapi.go | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/voice.go b/voice.go index 8076c19..66de123 100644 --- a/voice.go +++ b/voice.go @@ -114,6 +114,8 @@ func (v *VoiceConnection) Speaking(b bool) (err error) { // !!! NOTE !!! This function may be removed in favour of just using ChannelVoiceJoin func (v *VoiceConnection) ChangeChannel(channelID string, mute, deaf bool) (err error) { + v.log(LogInformational, "called") + data := voiceChannelJoinOp{4, voiceChannelJoinData{&v.GuildID, &channelID, mute, deaf}} v.wsMutex.Lock() err = v.session.wsConn.WriteJSON(data) @@ -224,6 +226,8 @@ type voiceOP2 struct { // become ready, if it does not become ready it retuns an err func (v *VoiceConnection) waitUntilConnected() error { + v.log(LogInformational, "called") + i := 0 for { if v.Ready { @@ -292,7 +296,7 @@ func (v *VoiceConnection) open() (err error) { err = v.wsConn.WriteJSON(data) if err != nil { - log.Println("VOICE error sending init packet:", err) + v.log(LogWarning, "error sending init packet, %s", err) return } @@ -310,6 +314,8 @@ func (v *VoiceConnection) open() (err error) { // to the voice event handler. This is automatically called by the Open func func (v *VoiceConnection) wsListen(wsConn *websocket.Conn, close <-chan struct{}) { + v.log(LogInformational, "called") + for { _, message, err := v.wsConn.ReadMessage() if err != nil { @@ -844,6 +850,7 @@ func (v *VoiceConnection) reconnect() { // TODO: Maybe find a better method. gID := v.GuildID v.GuildID = "" + v.sessionID = "" _, err := v.session.ChannelVoiceJoin(gID, v.ChannelID, v.mute, v.deaf) if err == nil { diff --git a/wsapi.go b/wsapi.go index 2e78bcd..112c16f 100644 --- a/wsapi.go +++ b/wsapi.go @@ -461,6 +461,7 @@ func (s *Session) ChannelVoiceJoin(gID, cID string, mute, deaf bool) (voice *Voi // doesn't exactly work perfect yet.. TODO err = voice.waitUntilConnected() if err != nil { + s.log(LogWarning, "error waiting for voice connecting, %s", err) voice.Close() s.log(LogInformational, "Deleting VoiceConnection %s", gID) delete(s.VoiceConnections, gID)