Ver código fonte

Only close chans if they are open, closes #80

Bruce Marriner 9 anos atrás
pai
commit
61b3b8122c
1 arquivos alterados com 7 adições e 2 exclusões
  1. 7 2
      discord.go

+ 7 - 2
discord.go

@@ -125,8 +125,13 @@ func (s *Session) Close() {
 
 	s.DataReady = false
 
-	close(s.listenChan)
-	close(s.heartbeatChan)
+	if s.listenChan != nil {
+		close(s.listenChan)
+	}
+
+	if s.heartbeatChan != nil {
+		close(s.heartbeatChan)
+	}
 
 	if s.wsConn != nil {
 		s.wsConn.Close()