Browse Source

Remove default close handler which caused abnormal closes

master
Robbie Trencheny 8 years ago
parent
commit
a9e9ebdfdc
No known key found for this signature in database GPG Key ID: 57406F414538A33B
  1. 2
      melody.go
  2. 9
      session.go

2
melody.go

@ -89,7 +89,7 @@ func New() *Melody {
messageSentHandler: func(*Session, []byte) {},
messageSentHandlerBinary: func(*Session, []byte) {},
errorHandler: func(*Session, error) {},
closeHandler: func(*Session, int, string) error { return nil },
closeHandler: nil,
connectHandler: func(*Session) {},
disconnectHandler: func(*Session) {},
pongHandler: func(*Session) {},

9
session.go

@ -115,10 +115,11 @@ func (s *Session) readPump() {
return nil
})
s.conn.SetCloseHandler(func(code int, text string) error {
s.melody.closeHandler(s, code, text)
return nil
})
if s.melody.closeHandler != nil {
s.conn.SetCloseHandler(func(code int, text string) error {
return s.melody.closeHandler(s, code, text)
})
}
for {
t, message, err := s.conn.ReadMessage()

Loading…
Cancel
Save