49 lines
942 B
Go
49 lines
942 B
Go
package server
|
|
|
|
import (
|
|
"net"
|
|
)
|
|
|
|
type ServerHandler interface {
|
|
// Init invoked before the server is started
|
|
// If you override ths method, must call
|
|
//
|
|
// func (sh *ServerHandler) Init() error {
|
|
// if err := sh.ServerHandler.Init(); nil != err {
|
|
// return err
|
|
// }
|
|
// ...
|
|
// return nil
|
|
// }
|
|
Init() error
|
|
|
|
Listen() (net.Listener, error)
|
|
// OnStart invoked when server is started
|
|
// If you override ths method, must call
|
|
//
|
|
// func (sh *ServerHandler) OnStart() error {
|
|
// sh.ServerHandler.OnStart()
|
|
// ...
|
|
// return nil
|
|
// }
|
|
OnStart()
|
|
|
|
OnConnect(conn net.Conn) (net.Conn, error)
|
|
|
|
Handle(conn net.Conn, stopChan <-chan struct{}, doneChan chan<- struct{})
|
|
|
|
OnError(status int, reason error)
|
|
// OnStop invoked when server is stopped
|
|
// If you override ths method, must call
|
|
//
|
|
// func (sh *ServerHandler) OnStop() {
|
|
// ...
|
|
// sh.ServerHandler.OnStop()
|
|
// }
|
|
OnStop()
|
|
|
|
GetName() string
|
|
|
|
Validate()
|
|
}
|