瀏覽代碼

Check that websocket exists before trying to send VoiceSpeaking

Bruce Marriner 9 年之前
父節點
當前提交
9d42bf1cc6
共有 1 個文件被更改,包括 6 次插入0 次删除
  1. 6 0
      voice.go

+ 6 - 0
voice.go

@@ -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 {