Check that websocket exists before trying to send VoiceSpeaking

This commit is contained in:
Bruce Marriner 2015-11-25 08:31:26 -06:00
parent ea647f9a61
commit 9d42bf1cc6

View file

@ -210,6 +210,12 @@ func (s *Session) VoiceCloseUDP() {
func (s *Session) VoiceSpeaking() {
if s.VwsConn == nil {
// TODO return an error
fmt.Println("No Voice websocket.")
return
}
jsonb := []byte(`{"op":5,"d":{"speaking":true,"delay":0}}`)
err := s.VwsConn.WriteMessage(websocket.TextMessage, jsonb)
if err != nil {