diff --git a/socket/server-readwriter.go b/socket/server-readwriter.go index 7640e45..303d984 100644 --- a/socket/server-readwriter.go +++ b/socket/server-readwriter.go @@ -33,8 +33,6 @@ func (srw *ServerReadWriter) HandleConnection(servlet Servlet, servletCtx server if nil != conn { conn.Close() } - servlet.OnDisconnect(servletCtx) - olog.Logger().Info("Client has been disconnected", zap.String("Address", addr.String())) srw.ServerStopWg.Done() }() @@ -46,6 +44,10 @@ func (srw *ServerReadWriter) HandleConnection(servlet Servlet, servletCtx server servlet.OnConnect(servletCtx, conn) conn.SetCloseHandler(func(code int, text string) error { olog.Logger().Debug("close") + + servlet.OnDisconnect(servletCtx) + olog.Logger().Info("Client has been disconnected", zap.String("Address", addr.String())) + return nil })