server/server_handlers.go
crusader ec72c171fb ing
2017-11-29 09:51:41 +09:00

60 lines
1.2 KiB
Go

package server
import (
"errors"
"io"
"log"
"net"
)
type ServerHandlers struct {
}
func (sh *ServerHandlers) ServerContext() ServerContext {
}
func (sh *ServerHandlers) Init(serverCTX ServerContext) error {
// no op
}
func (sh *ServerHandlers) Listen(serverCTX ServerContext) (net.Listener, error) {
return nil, errors.New("Server: Handler method[Listen] of Server is not implement")
}
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
}
func (sh *ServerHandlers) OnAccept(conn net.Conn) (net.Conn, error) {
return conn, nil
}
func (sh *ServerHandlers) Handle(conn net.Conn, stopChan <-chan struct{}, doneChan chan<- struct{}) {
log.Printf("Server.Handle")
}
func (sh *ServerHandlers) IsClientDisconnect(err error) bool {
return err == io.ErrUnexpectedEOF || err == io.EOF
}
func (sh *ServerHandlers) Validate() {
}