diff --git a/server.go b/server.go index 9ccbe1e..a7ec306 100644 --- a/server.go +++ b/server.go @@ -63,7 +63,7 @@ func (s *server) Stop() { close(s.stopChan) s.stopWg.Wait() s.stopChan = nil - s.serverHandler.Stopped() + s.serverHandler.OnStopped() } func (s *server) Serve() error { diff --git a/server_handler.go b/server_handler.go index 62f2a4a..59750cd 100644 --- a/server_handler.go +++ b/server_handler.go @@ -8,7 +8,9 @@ import ( type ServerHandler interface { Listen() (net.Listener, error) Handle(remoteAddr string, rwc io.ReadWriteCloser, stopChan chan struct{}) - Stopped() + OnStopped() + + IsClientDisconnect(err error) bool GetAddr() string diff --git a/server_handlers.go b/server_handlers.go index b302fb2..0086ca7 100644 --- a/server_handlers.go +++ b/server_handlers.go @@ -54,7 +54,11 @@ func (sh *ServerHandlers) Handle(remoteAddr string, rwc io.ReadWriteCloser, stop } -func (sh *ServerHandlers) Stopped() { +func (sh *ServerHandlers) IsClientDisconnect(err error) bool { + return err == io.ErrUnexpectedEOF || err == io.EOF +} + +func (sh *ServerHandlers) OnStopped() { }