forked from pothtonswer/discordmuffin
Fix deadlock because I'm dumb.
This commit is contained in:
parent
2b4b19cfd8
commit
457b03f66e
2 changed files with 5 additions and 2 deletions
|
@ -196,11 +196,13 @@ func (s *Session) AddHandler(handler interface{}) func() {
|
||||||
// handle calls any handlers that match the event type and any handlers of
|
// handle calls any handlers that match the event type and any handlers of
|
||||||
// interface{}.
|
// interface{}.
|
||||||
func (s *Session) handle(event interface{}) {
|
func (s *Session) handle(event interface{}) {
|
||||||
s.initialize()
|
|
||||||
|
|
||||||
s.handlersMu.RLock()
|
s.handlersMu.RLock()
|
||||||
defer s.handlersMu.RUnlock()
|
defer s.handlersMu.RUnlock()
|
||||||
|
|
||||||
|
if s.handlers == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
handlerParameters := []reflect.Value{reflect.ValueOf(s), reflect.ValueOf(event)}
|
handlerParameters := []reflect.Value{reflect.ValueOf(s), reflect.ValueOf(event)}
|
||||||
|
|
||||||
if handlers, ok := s.handlers[reflect.TypeOf(event)]; ok {
|
if handlers, ok := s.handlers[reflect.TypeOf(event)]; ok {
|
||||||
|
|
1
wsapi.go
1
wsapi.go
|
@ -88,6 +88,7 @@ func (s *Session) Open() (err error) {
|
||||||
|
|
||||||
s.Unlock()
|
s.Unlock()
|
||||||
|
|
||||||
|
s.initialize()
|
||||||
s.handle(&Connect{})
|
s.handle(&Connect{})
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in a new issue