2017-10-26 11:14:00 +00:00
|
|
|
package server
|
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
"io"
|
2017-11-01 06:58:26 +00:00
|
|
|
"log"
|
2017-10-26 11:14:00 +00:00
|
|
|
"net"
|
|
|
|
)
|
|
|
|
|
|
|
|
type ServerHandlers struct {
|
|
|
|
}
|
|
|
|
|
2017-10-27 08:53:26 +00:00
|
|
|
func (sh *ServerHandlers) OnStart() {
|
|
|
|
// no op
|
|
|
|
}
|
|
|
|
|
|
|
|
func (sh *ServerHandlers) OnStop() {
|
|
|
|
// no op
|
|
|
|
}
|
|
|
|
|
2017-10-26 11:14:00 +00:00
|
|
|
func (sh *ServerHandlers) Listen() (net.Listener, error) {
|
|
|
|
return nil, errors.New("Server: Handler method[Listen] of Server is not implement")
|
|
|
|
}
|
|
|
|
|
2017-11-01 05:22:52 +00:00
|
|
|
func (sh *ServerHandlers) OnAccept(conn net.Conn) (net.Conn, error) {
|
|
|
|
return conn, nil
|
2017-10-27 07:14:20 +00:00
|
|
|
}
|
|
|
|
|
2017-11-01 05:22:52 +00:00
|
|
|
func (sh *ServerHandlers) Handle(conn net.Conn, stopChan <-chan struct{}, doneChan chan<- struct{}) {
|
2017-11-01 06:58:26 +00:00
|
|
|
log.Printf("Server.Handle")
|
2017-10-26 11:14:00 +00:00
|
|
|
}
|
|
|
|
|
2017-10-27 05:27:36 +00:00
|
|
|
func (sh *ServerHandlers) IsClientDisconnect(err error) bool {
|
|
|
|
return err == io.ErrUnexpectedEOF || err == io.EOF
|
|
|
|
}
|
|
|
|
|
2017-10-26 11:14:00 +00:00
|
|
|
func (sh *ServerHandlers) Validate() {
|
|
|
|
|
|
|
|
}
|