This commit is contained in:
crusader 2017-10-27 14:27:36 +09:00
parent 1104f7e270
commit d13384841b
3 changed files with 9 additions and 3 deletions

View File

@ -63,7 +63,7 @@ func (s *server) Stop() {
close(s.stopChan) close(s.stopChan)
s.stopWg.Wait() s.stopWg.Wait()
s.stopChan = nil s.stopChan = nil
s.serverHandler.Stopped() s.serverHandler.OnStopped()
} }
func (s *server) Serve() error { func (s *server) Serve() error {

View File

@ -8,7 +8,9 @@ import (
type ServerHandler interface { type ServerHandler interface {
Listen() (net.Listener, error) Listen() (net.Listener, error)
Handle(remoteAddr string, rwc io.ReadWriteCloser, stopChan chan struct{}) Handle(remoteAddr string, rwc io.ReadWriteCloser, stopChan chan struct{})
Stopped() OnStopped()
IsClientDisconnect(err error) bool
GetAddr() string GetAddr() string

View File

@ -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() {
} }