server/server_handlers.go

46 lines
900 B
Go
Raw Normal View History

2017-10-26 11:14:00 +00:00
package server
import (
"errors"
"net"
)
2017-11-15 04:16:31 +00:00
func NewServerHandler() ServerHandler {
sh := &ServerHandlers{}
return sh
2017-10-26 11:14:00 +00:00
}
2017-11-29 00:51:41 +00:00
func (sh *ServerHandlers) ServerContext() ServerContext {
2017-11-29 00:57:03 +00:00
return newServerContext()
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) OnError(serverCTX ServerContext, conn net.Conn, status int, reason error) {
}
2017-11-15 04:13:47 +00:00
// OnStop invoked when server is stopped
// If you override ths method, must call
2017-11-29 00:51:41 +00:00
func (sh *ServerHandlers) OnStop(serverCTX ServerContext) {
// no op
}
2017-11-15 04:13:47 +00:00
func (sh *ServerHandlers) GetName() string {
return sh.Name
2017-10-27 05:27:36 +00:00
}
2017-10-26 11:14:00 +00:00
func (sh *ServerHandlers) Validate() {
}