server/server_handlers.go

60 lines
1.2 KiB
Go
Raw Normal View History

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-11-29 00:51:41 +00:00
func (sh *ServerHandlers) ServerContext() ServerContext {
2017-10-27 08:53:26 +00:00
}
2017-11-29 00:51:41 +00:00
func (sh *ServerHandlers) Init(serverCTX ServerContext) error {
2017-10-27 08:53:26 +00:00
// no op
}
2017-11-29 00:51:41 +00:00
func (sh *ServerHandlers) Listen(serverCTX ServerContext) (net.Listener, error) {
2017-10-26 11:14:00 +00:00
return nil, errors.New("Server: Handler method[Listen] of Server is not implement")
}
2017-11-29 00:51:41 +00:00
func (sh *ServerHandlers) OnStart(serverCTX ServerContext) {
// no op
}
func (sh *ServerHandlers) OnAccept(conn net.Conn) (net.Conn, error) {
}
func (sh *ServerHandlers) Handle(serverCTX ServerContext, conn net.Conn, stopChan <-chan struct{}, doneChan chan<- struct{}) {
}
func (sh *ServerHandlers) OnError(serverCTX ServerContext, conn net.Conn, status int, reason error) {
}
func (sh *ServerHandlers) OnStop(serverCTX ServerContext) {
// no op
}
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() {
}