From d13384841b645e76be7e3a4d60ca969c5f0e22e6 Mon Sep 17 00:00:00 2001 From: crusader Date: Fri, 27 Oct 2017 14:27:36 +0900 Subject: [PATCH] ing --- server.go | 2 +- server_handler.go | 4 +++- server_handlers.go | 6 +++++- 3 files changed, 9 insertions(+), 3 deletions(-) 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() { }