ing
This commit is contained in:
parent
4163705d49
commit
ee5c8cf463
|
@ -119,6 +119,13 @@ func runServer(s *server) {
|
|||
|
||||
func handleServerConnection(s *server, conn io.ReadWriteCloser, clientAddr string) {
|
||||
defer s.stopWg.Done()
|
||||
|
||||
if err := s.serverHandler.OnHandshake(clientAddr, conn); nil != err {
|
||||
logging.Logger.Error(fmt.Sprintf("Server: [%s]. handshake error: [%s]", clientAddr, err))
|
||||
conn.Close()
|
||||
return
|
||||
}
|
||||
|
||||
logging.Logger.Debug(fmt.Sprintf("Server: Client[%s] is connected.", clientAddr))
|
||||
clientStopChan := make(chan struct{})
|
||||
go s.serverHandler.Handle(clientAddr, conn, clientStopChan)
|
||||
|
|
|
@ -7,6 +7,7 @@ import (
|
|||
|
||||
type ServerHandler interface {
|
||||
Listen() (net.Listener, error)
|
||||
OnHandshake(remoteAddr string, rwc io.ReadWriteCloser) error
|
||||
Handle(remoteAddr string, rwc io.ReadWriteCloser, stopChan chan struct{})
|
||||
OnStopped()
|
||||
|
||||
|
|
|
@ -27,6 +27,10 @@ func (sh *ServerHandlers) Listen() (net.Listener, error) {
|
|||
return nil, errors.New("Server: Handler method[Listen] of Server is not implement")
|
||||
}
|
||||
|
||||
func (sh *ServerHandlers) OnHandshake(remoteAddr string, rwc io.ReadWriteCloser) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (sh *ServerHandlers) Handle(remoteAddr string, rwc io.ReadWriteCloser, stopChan chan struct{}) {
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user