46 lines
900 B
Go
46 lines
900 B
Go
package server
|
|
|
|
import (
|
|
"errors"
|
|
"net"
|
|
)
|
|
|
|
func NewServerHandler() ServerHandler {
|
|
sh := &ServerHandlers{}
|
|
return sh
|
|
}
|
|
|
|
func (sh *ServerHandlers) ServerContext() ServerContext {
|
|
return newServerContext()
|
|
}
|
|
|
|
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) OnError(serverCTX ServerContext, conn net.Conn, status int, reason error) {
|
|
|
|
}
|
|
|
|
// OnStop invoked when server is stopped
|
|
// If you override ths method, must call
|
|
func (sh *ServerHandlers) OnStop(serverCTX ServerContext) {
|
|
// no op
|
|
}
|
|
|
|
func (sh *ServerHandlers) GetName() string {
|
|
return sh.Name
|
|
}
|
|
|
|
func (sh *ServerHandlers) Validate() {
|
|
|
|
}
|