From a9e9ebdfdce8fb33182936b2ef6a21330aa39c49 Mon Sep 17 00:00:00 2001 From: Robbie Trencheny Date: Wed, 12 Apr 2017 14:41:55 -0700 Subject: [PATCH] Remove default close handler which caused abnormal closes --- melody.go | 2 +- session.go | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/melody.go b/melody.go index 00b1928..1342123 100644 --- a/melody.go +++ b/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) {}, diff --git a/session.go b/session.go index 477fe83..3997cef 100644 --- a/session.go +++ b/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()