Remove default close handler which caused abnormal closes

This commit is contained in:
Robbie Trencheny
2017-04-12 14:41:55 -07:00
parent 647ca280c6
commit a9e9ebdfdc
2 changed files with 6 additions and 5 deletions
+1 -1
View File
@@ -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) {},
+5 -4
View File
@@ -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()