53 lines
941 B
Go
53 lines
941 B
Go
|
package server
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
|
||
|
"git.loafle.net/commons_go/logging"
|
||
|
|
||
|
"git.loafle.net/commons_go/server"
|
||
|
)
|
||
|
|
||
|
func newServerHandler(addr string, socketHandler SocketHandler) ServerHandler {
|
||
|
sh := &ServerHandlers{
|
||
|
addr: addr,
|
||
|
}
|
||
|
|
||
|
sh.Name = "Network Container"
|
||
|
sh.SocketHandler = socketHandler
|
||
|
return sh
|
||
|
}
|
||
|
|
||
|
type ServerHandlers struct {
|
||
|
server.ServerHandlers
|
||
|
|
||
|
addr string
|
||
|
}
|
||
|
|
||
|
func (sh *ServerHandlers) Init(serverCTX server.ServerContext) error {
|
||
|
if err := sh.ServerHandlers.Init(serverCTX); nil != err {
|
||
|
return err
|
||
|
}
|
||
|
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
func (sh *ServerHandlers) OnStart(serverCTX server.ServerContext) {
|
||
|
sh.ServerHandlers.OnStart(serverCTX)
|
||
|
|
||
|
}
|
||
|
|
||
|
func (sh *ServerHandlers) OnStop(serverCTX server.ServerContext) {
|
||
|
|
||
|
sh.ServerHandlers.OnStop(serverCTX)
|
||
|
}
|
||
|
|
||
|
func (sh *ServerHandlers) Validate() {
|
||
|
sh.ServerHandlers.Validate()
|
||
|
|
||
|
if "" == sh.addr {
|
||
|
logging.Logger().Panic(fmt.Sprintf("Server: Address of server must be specified"))
|
||
|
}
|
||
|
|
||
|
}
|