Browse Source

Merge pull request #126 from iopred/docs

Fix for single threaded job queue feature.
Bruce 9 years ago
parent
commit
e244177d27
2 changed files with 5 additions and 2 deletions
  1. 4 2
      discord.go
  2. 1 0
      wsapi.go

+ 4 - 2
discord.go

@@ -196,11 +196,13 @@ func (s *Session) AddHandler(handler interface{}) func() {
 // handle calls any handlers that match the event type and any handlers of
 // interface{}.
 func (s *Session) handle(event interface{}) {
-	s.initialize()
-
 	s.handlersMu.RLock()
 	defer s.handlersMu.RUnlock()
 
+	if s.handlers == nil {
+		return
+	}
+
 	handlerParameters := []reflect.Value{reflect.ValueOf(s), reflect.ValueOf(event)}
 
 	if handlers, ok := s.handlers[reflect.TypeOf(event)]; ok {

+ 1 - 0
wsapi.go

@@ -88,6 +88,7 @@ func (s *Session) Open() (err error) {
 
 	s.Unlock()
 
+	s.initialize()
 	s.handle(&Connect{})
 
 	return