31 lines
615 B
Go
31 lines
615 B
Go
package server
|
|
|
|
import (
|
|
"net"
|
|
)
|
|
|
|
type ServerHandler interface {
|
|
ServerContext() ServerContext
|
|
Init(serverCTX ServerContext) error
|
|
Listen(serverCTX ServerContext) (net.Listener, error)
|
|
OnStart(serverCTX ServerContext)
|
|
|
|
OnError(serverCTX ServerContext, conn net.Conn, status int, reason error)
|
|
|
|
OnStop(serverCTX ServerContext)
|
|
|
|
// Destroy invoked when server will destroy
|
|
// If you override ths method, must call
|
|
//
|
|
// func (sh *ServerHandler) Destroy() {
|
|
// ...
|
|
// sh.ServerHandler.Destroy()
|
|
// }
|
|
Destroy(serverCTX ServerContext)
|
|
|
|
GetName() string
|
|
GetSocketHandler() SocketHandler
|
|
|
|
Validate()
|
|
}
|