server/server_handler.go

49 lines
942 B
Go
Raw Normal View History

2017-10-26 11:14:00 +00:00
package server
import (
"net"
)
type ServerHandler interface {
2017-11-15 04:13:47 +00:00
// 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
2017-11-01 05:22:52 +00:00
2017-11-15 04:13:47 +00:00
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
// }
2017-10-27 08:53:26 +00:00
OnStart()
2017-11-15 04:13:47 +00:00
OnConnect(conn net.Conn) (net.Conn, error)
2017-10-27 08:53:26 +00:00
2017-11-01 05:22:52 +00:00
Handle(conn net.Conn, stopChan <-chan struct{}, doneChan chan<- struct{})
2017-10-27 05:27:36 +00:00
2017-11-15 04:13:47 +00:00
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
2017-10-26 11:14:00 +00:00
Validate()
}